I am using the following command to create a database using windows command and connect to it but I am getting java.net.SocketException: Unrecognized Windows Sockets error: 0: JVM_Bind error.
Command used to create a database named xdb and connect to it:
java -cp ./lib/hsqldb.jar org.hsqldb.Server -database.0 file:mydb -dbname.0 xdb
Complete error:
[Server#83cc67]: [Thread[main,5,main]]: checkRunning(false) entered
[Server#83cc67]: [Thread[main,5,main]]: checkRunning(false) exited
[Server#83cc67]: Startup sequence initiated from main() method
[Server#83cc67]: Loaded properties from [C:\Home\hsqldb\server.properties]
[Server#83cc67]: Initiating startup sequence...
[Server#83cc67]: [Thread[HSQLDB Server #83cc67,5,main]]: run()/openServerSocket(
):
java.net.SocketException: Unrecognized Windows Sockets error: 0: JVM_Bind
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:365)
at java.net.ServerSocket.bind(ServerSocket.java:319)
at java.net.ServerSocket.<init>(ServerSocket.java:185)
at java.net.ServerSocket.<init>(ServerSocket.java:97)
at org.hsqldb.HsqlSocketFactory.createServerSocket(Unknown Source)
at org.hsqldb.Server.openServerSocket(Unknown Source)
at org.hsqldb.Server.run(Unknown Source)
at org.hsqldb.Server.access$000(Unknown Source)
at org.hsqldb.Server$ServerThread.run(Unknown Source)
[Server#83cc67]: Initiating shutdown sequence...
[Server#83cc67]: Shutdown sequence completed in 6 ms.
[Server#83cc67]: 2012-05-18 01:31:59.184 SHUTDOWN : System.exit() is called next
Could someone help me understand why am I getting this error and how to solve it?
Thanks
The default port for hsqldb is 9001
Run netstat -an check to see if there is something is LISTENING on port 9001
netstat -an | grep LISTENING to check for all servers listening for incoming connections
netstat -an | grep 9001 to check for a specific port number.
If there is something already there then the new of hsqldb that you are trying to start will fail to bind a socket to the 9001 port.
On Windows 7 you can run TCPView to see what process is currently listening on the "overcrowded" port. Then it's a matter of deciding to terminate that process which is using 9001 or reconfiguring hsqldb and your client application to use a different (unused) port.
It is possible to change the port that hsqldb listens on using the --port XXXX, where XXXX is the new port number.
Also from the java -cp ./lib/hsqldb.jar org.hsqldb.Server --help output...
The server looks for a 'server.properties' file in the current directory and loads properties from it if it exists. Command line options override those loaded from the 'server.properties' file.
There are other possible causes of this error so it would be useful to know what operating system the hsqldb is running on.
Failure to bind to a socket is a problem that can afflict any server application so you can review the answers provided for other server software that return this error such as the question asked about JBOSS here ...
java.net.SocketException: Unrecognized Windows Sockets error: 0: JVM_Bind (JBOSS)
It looks like you try to bind to port 0 and it doesn't exist. Try to config a different port
Related
I am trying to connect socket for communication java with android using this example:https://github.com/user370305/Android-USB-Communication
I have run a command from readMe file:
adb forward tcp:38300 tcp:38300
When I try to run Java code from an example I get the error: Couldn't get I/O for the connection to: LocalHost. The full stacktrace is
java.io.EOFException
at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2675)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:3150)
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:859)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:355)
at USBClient.main(USBClient.java:24)
Can you say what I am doing wrong?
When I tried:
netstat -ano | findstr :38300
TCP 127.0.0.1:38300 0.0.0.0:0 LISTENING 15540
Is it Ok?
I've been following this tutorial which is how to setup remote debugging.
I have my Jar running debug mode listening on port 6065 on my server with the following setting:
-Xrunjdwp\:transport\=dt_socket,server\=y,address\=6065,suspend\=n
I start the JAR on my server with jar in debug mode with:
myApplicationThatContainsJar.exe -debug "my application"
> Now Starting JVM
> Listening for transport dt_socket at address: 6065
I have psping tool installed which I use to ping (IPaddress:port). I am able to ping my ipaddress example: 44.66.33.66:6065 from my dev box and get a reply. But when I try to initiate remote debug in Eclipse I get:
Failed to connect to remote VM. Connection refused. Connection
refused: connect
I have verified I've added permission for both inbound and outbound traffic for that port on both my DEV box and server.
When I start my JAR on my server and before I try to connect with Eclipse I do a:
psping 44.66.33.66:6065
And I get a response stating that it sent and recieved with 0% loss, meaning I am indeed getting a response.
In the eclipse debug configuration, which in the 'Debug Configurations' window I have the host and port listed properly and the 'Connection Type: Standard(Socket Attach)'.
As soon as I try to connect with Eclipse and get the connection refused error I try psping again from the command line, but now eclipse did something to the connection and I get in the command line:
The remote computer refused the network connection.
Any suggestions where else I should check? or where else I should troubleshoot? I'm trying to do remote-debugging for my JAR from the DEV box to my server.
-Xrunjdwp\:transport\=dt_socket,server\=y,address\=6065,suspend\=n
should be:
-Xrunjdwp\:transport\=dt_socket,server\=y,address\=6065,suspend\=y
notice the suspend\=y keep in mind I need to escape the equals and others may not need to do this. Once I set to suspend\=y the application waited for me to connect from eclipse and I was able to begin remote debugging.
Don't forget to open inbound and outbound traffic for the port you used for address\=6065
Check network setting in VM and set Attached to: Bridged Adapter
Check VM IP using ipconfig command
Run Java Application using following command
> java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=4000,suspend=n myapp
Above command myapp replace to your application name
In eclipse go to debug configuration -> remote java Application -> New
Host: remote VM ip
Port: given port that given in command
Apply -> Debug
I recently installed the H2 database in Windows7. To start the H2 command line, I faced the following problem. There is already a process running on 8082 port. To resolve this I need to stop this process.
The Web Console server could not be started. Possible cause: another server is a
lready running at http://169.254.216.99:8082
Root cause: Exception opening port "8082" (port may be in use), cause: "java.net
.BindException: Address already in use: JVM_Bind" [90061-184]
Exception in thread "main" org.h2.jdbc.JdbcSQLException: Exception opening port
"8082" (port may be in use), cause: "java.net.BindException: Address already in
use: JVM_Bind" [90061-184]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
at org.h2.message.DbException.get(DbException.java:168)
at org.h2.util.NetUtils.createServerSocketTry(NetUtils.java:194)
at org.h2.util.NetUtils.createServerSocket(NetUtils.java:160)
at org.h2.server.web.WebServer.start(WebServer.java:357)
at org.h2.tools.Server.start(Server.java:474)
at org.h2.tools.Console.runTool(Console.java:231)
at org.h2.tools.Console.main(Console.java:99)
Caused by: java.net.BindException: Address already in use: JVM_Bind
at java.net.DualStackPlainSocketImpl.bind0(Native Method)
at java.net.DualStackPlainSocketImpl.socketBind(Unknown Source)
at java.net.AbstractPlainSocketImpl.bind(Unknown Source)
at java.net.PlainSocketImpl.bind(Unknown Source)
at java.net.ServerSocket.bind(Unknown Source)
at java.net.ServerSocket.<init>(Unknown Source)
at java.net.ServerSocket.<init>(Unknown Source)
at org.h2.util.NetUtils.createServerSocketTry(NetUtils.java:190)
... 5 more
Press any key to continue . . .
Now I checked which process is running on 8082 port.
netstat -a -n -o | find "8082"
TCP 0.0.0.0:8082 0.0.0.0:0 LISTENING 4472
TCP [::]:8082 [::]:0 LISTENING 4472
I find it that the javaw.exe process is running on port 8082.
tasklist
javaw.exe 4472
I found out few info about java/javaw/javaws from this link Java/Javaw/Javaws.
Now my question is if I closed the 'javaw.exe' process, will I face any further problem to run other applications/program ?
Or can I run the javaw.exe on different port or change H2 port (vice versa) ? How?
EDIT
I know to kill the process -(in command line)
Taskkill /PID 4472 /F
javaw is a similar to java, but it does not shown the black ("DOS") window. You can use the process monitor to find out which process is it, but it can be just another H2 instance running...
In any case, if you want to run your H2 you should either
Kill the other process
Choose another port
I assumed that you had H2 server start already (somehow), and the first server used the 8082 port. So when you try to start another H2 server, it noticed the port was already taken by the first H2 server.
You can check if H2 server already started or not by accessing http://localhost:8082/.
If you would like to change H2 port anyway, you can change it by editing a file called .h2.server.properties which is usually placed at C:\Users\[username] or C:\Documents and Settings\[username].
If you can't find the file .h2.server.properties there, you can create one at C:\Users\[username] by simply copying the code below.
#H2 Server Properties
#Wed Aug 01 16:26:15 JST 2018
0=Generic JNDI Data Source|javax.naming.InitialContext|java\:comp/env/jdbc/Test|sa
1=Generic Firebird Server|org.firebirdsql.jdbc.FBDriver|jdbc\:firebirdsql\:localhost\:c\:/temp/firebird/test|sysdba
10=Generic Derby (Server)|org.apache.derby.jdbc.ClientDriver|jdbc\:derby\://localhost\:1527/test;create\=true|sa
11=Generic Derby (Embedded)|org.apache.derby.jdbc.EmbeddedDriver|jdbc\:derby\:test;create\=true|sa
12=Generic H2 (Server)|org.h2.Driver|jdbc\:h2\:tcp\://localhost/~/test|sa
13=Generic H2 (Embedded)|org.h2.Driver|jdbc\:h2\:~/test|sa
2=Generic SQLite|org.sqlite.JDBC|jdbc\:sqlite\:test|sa
3=Generic DB2|COM.ibm.db2.jdbc.net.DB2Driver|jdbc\:db2\://localhost/test|
4=Generic Oracle|oracle.jdbc.driver.OracleDriver|jdbc\:oracle\:thin\:#localhost\:1521\:XE|sa
5=Generic MS SQL Server 2000|com.microsoft.jdbc.sqlserver.SQLServerDriver|jdbc\:microsoft\:sqlserver\://localhost\:1433;DatabaseName\=sqlexpress|sa
6=Generic MS SQL Server 2005|com.microsoft.sqlserver.jdbc.SQLServerDriver|jdbc\:sqlserver\://localhost;DatabaseName\=test|sa
7=Generic PostgreSQL|org.postgresql.Driver|jdbc\:postgresql\:test|
8=Generic MySQL|com.mysql.jdbc.Driver|jdbc\:mysql\://localhost\:3306/test|
9=Generic HSQLDB|org.hsqldb.jdbcDriver|jdbc\:hsqldb\:test;hsqldb.default_table_type\=cached|sa
webAllowOthers=true
webPort=8082
webSSL=false
If you would like to change H2 port, edit webPort=8082.
I'm a newbie in Java EE 7.
I have Netbeans 7.4 with GlassFish 4.0 and Java EE 7. In a 64-bit Windows 8.1 Pro machine. I want to start the GlassFish 4.0 Server, so I clicked on the services tab in Netbeans and then in the Servers option I right-clicked GlassFish Server 4.0 and then clicked Start.
When I did that I got the following message: "Could not start GlassFish Server 4.0: HTTP or HTTPS listener port is occupied while server is not running". I have also the IIS server, but I stopped it. After stopping IIS I tried to start again the GlassFish but it showed me the same message.
Also there is a window in Netbeans called Output - Java DB Database Process and it showed me the following:
Tue May 06 22:03:11 GMT-05:00 2014 : Security manager installed using the Basic server security policy.
Tue May 06 22:03:11 GMT-05:00 2014 Thread[main,5,main] java.io.FileNotFoundException: D:\Users\Juan Jose\.netbeans-derby\derby.log (Access is denied)
Tue May 06 22:03:12 GMT-05:00 2014 : Could not listen on port 1527 on host localhost:
java.net.BindException: Address already in use: JVM_Bind
Tue May 06 22:03:12 GMT-05:00 2014 : Could not listen on port 1527 on host localhost:
java.net.BindException: Address already in use: JVM_Bind
I ran a netstat -a in Windows to see what was happening with the 1527 port and that port is in LISTENING mode.
So how can I know what application or process is ocuppying the 1527 port?
Thanks for your help !!
To find the process1 that keeps the busy port, try the following command:
netstat -ano | find "1527"
This will show a line with the port and the identifier of the process. e.g.:
TCP 127.0.0.1:1527 0.0.0.0:0 LISTENING 2268
Once you have the process ID (e.g. 2268), run the following command for release the port (this will kill the process):
taskkill /F /PID 2268
Now, try to start Glassfish.
On Linux:
lsof -Pnl +M -i6 | grep 1527
Produces:
java 31139 1001 32u IPv6 114916062 0t0 TCP 127.0.0.1:1527 (LISTEN)
Killed with:
kill -9 31139
1 If you want to know the associated program, see How do I find out what service is using a certain port?
If the above doesn't work for anyone pls follow the below steps.. Sure It will work..
Go to C:\Program Files\glassfish-4.1\glassfish\domains\domain1\config
Open "domain.xml" in a xml editor or u can use notepad++
Find "8080"(below highlighted for ur reference)
network-listener port="8080" protocol="http-listener-1"
transport="tcp" name="http-listener-1" thread-pool="http-thread-pool"
Replace "8080" with any open port. If you don't know how to find out open port try to use port no "3702" then save your file
now run your project
After running the project please have an eye on the URL
http://localhost:8080/...... should be http://localhost:3702/.....
To get open ports follow the below steps
open cmd.exe
execute cmd "netstat -ano"
Pick any one which you find is free(Like inside the green box above )
This is not an error you need to worry about. When you start GlassFish, NetBeans will also start the JavaDB (aka, Derby) database, which listens on port 1527 by default. When you shut down NetBeans, it will shut down GlassFish but will not shut down JavaDB. Therefore, when you start NetBeans a second time, NetBeans will try to start JavaDB again and fail because it is already running and listening on port 1527.
To shut down the database, you can use the NetBeans Services(Tab)->Databases->JavaDB(right click->Stop Server. To shut down from the command line use $NETBEANS_HOME/glassfish-4.0/javadb/bin/stopNetworkServer, where $NETBEANS_HOME is the top-level directory where NetBeans is installed (at least on Mac/Linux/Unix).
I'm trying to connect my best debugger to a remote Glassfish instance (by remote I mean not running on the same physical machine, and not only not in the same VM).
My glassfish domain configuration has the "debug" flag checked, and server.log reports during startup
-Xdebug
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9009
Which indicates (to my mind), debugging is indeed enabled.
However, when I try to connect a debugger, it fails. The following session is an example (done with PuTTy) :
$ jdb -connect com.sun.jdi.SocketAttach:port=9009
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:385)
at java.net.Socket.connect(Socket.java:529)
at com.sun.tools.jdi.SocketTransportService.attach(SocketTransportService.java:204)
at com.sun.tools.jdi.GenericAttachingConnector.attach(GenericAttachingConnector.java:98)
at com.sun.tools.jdi.SocketAttachingConnector.attach(SocketAttachingConnector.java:72)
at com.sun.tools.example.debug.tty.VMConnection.attachTarget(VMConnection.java:358)
at com.sun.tools.example.debug.tty.VMConnection.open(VMConnection.java:168)
at com.sun.tools.example.debug.tty.Env.init(Env.java:64)
at com.sun.tools.example.debug.tty.TTY.main(TTY.java:1010)
Fatal error:
Unable to attach to target VM.
What could cause that behaviour ?
EDIT
Notice this jdb command-line has been given as an example of Glassfish debug testing on the web, here is why I used it
Also notice I'm doing this jdb debug session locally (that's to say when connected to that machine using PuTTy, so invoking jdb on the machine Glassifh is running on).
Since you're on the same machine, try jdb -attach 9009 instead.
If that doesn't work, have a look at the jdb documentation because it uses very different
options to prepare the VM for debugging.
If the JVM that you want to debug is on a remote machine (a machine with a different IP address) you have to include the host name or IP address as part of the attach option.
jdb -attach <hostname-or-address>:<port-number>
jdb is smart, but it won't search your network just to find a port that is waiting for a JPDA client.
You may want to look at this document about jdb.