Please find below stacktrace for the exception
2016-12-28 16:22:15.685:INFO:osjs.Server:jetty-7.x.y-SNAPSHOT
2016-12-28 16:22:15.706:INFO:osjsh.ContextHandler:started o.s.j.s.ServletContextHandler{/,null}
2016-12-28 16:22:15.711:WARN:osjuc.AbstractLifeCycle:FAILED SocketConnector#0.0.0.0:4444: java.net.BindException: Address already
in use: JVM_Bind
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.(Unknown Source)
at java.net.ServerSocket.(Unknown Source)
The above stacktrace explain about the exception in cmd.
The exception suggests that you've got another process bound to the same port.
I assume you're running it on Windows :
The below would list all the ports and processes which are being listened:
netstat -ano
And then you could kill the process by using the pid:
taskkill -pid 011 /f <-- 011 is just a sample pid
Maybe you might have to have a look at this blog post for a better understanding.
Related
I have a seemingly strange problem with the Java 8 Policy.
I used the following permission in Java 7 up to update 51 and it worked fine:
grant {
(...)
java.net.SocketPermission "localhost:1024-", "accept,connect,listen,resolve";
};
But now I'm checking Java 8 Support, and i get this Exception:
Exception in thread "RMI TCP Connection(idle)" java.security.AccessControlException: access denied ("java.net.SocketPermission" "10.1.17.112:55703" "accept,resolve")
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at sun.plugin2.applet.AWTAppletSecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkAccept(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.checkAcceptPermission(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.checkAcceptPermission(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Running IPConfig shows me that 10.1.17.122 is the IP of my local machine:
Ethernet adapter Local Area Connection:
IPv4 Address. . . . . . . . . . . : 10.1.17.112
Subnet Mask . . . . . . . . . . . : 255.255.252.0
Default Gateway . . . . . . . . . : 10.1.19.254
If I change the permission to 127.0.0.1 it dosent work neither:
grant {
(...)
java.net.SocketPermission "127.0.0.1:1024-", "accept,connect,listen,resolve";
};
BUT, if I enter my IP Address, all works fine again:
grant {
(...)
java.net.SocketPermission "10.1.17.112:1024-", "accept,connect,listen,resolve";
};
Any ideas why?
Edit:
For me it seems like a Bug in Java 8, can anyone confirm this?
"localhost" is 127.0.0.1. "10.1.17.112" is something else entirely. You're lucky it ever worked at all.
I think i found what i was looking for: http://bugs.java.com/bugdatabase/view_bug.do?bug_id=7077696
The suggested workaround there works for me.
2011-11-09
WORK AROUND
Run with -Djava.net.preferIPv4Stack=true
Thanks for your help!
I'm trying to connect a client and remote server through RMI and I get this error message:
java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.net.MalformedURLException: unknown protocol: c
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Unknown Source)
at RmiClient.getMessage(RmiClient.java:11)
at RmiClient.main(RmiClient.java:26)
Caused by: java.net.MalformedURLException: unknown protocol: c
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at sun.rmi.server.LoaderHandler.pathToURLs(Unknown Source)
at sun.rmi.server.LoaderHandler.getDefaultCodebaseURLs(Unknown Source)
at sun.rmi.server.LoaderHandler.loadClass(Unknown Source)
at java.rmi.server.RMIClassLoader$2.loadClass(Unknown Source)
at java.rmi.server.RMIClassLoader.loadClass(Unknown Source)
at sun.rmi.server.MarshalInputStream.resolveClass(Unknown Source)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
... 4 more
The following may be the cause of the problem:
The server has this line:
Naming.rebind("rmi://172.31.24.66:1099/RmiServer", obj);
which refers to the private IP address of an EC2 instance. The client on the other hand has this line - which is line 11 from above:
RmiServerIntf obj = (RmiServerIntf)Naming.lookup("rmi://54.229.66.114:1099/RmiServer");
which is the public IP of that instance. Also, on the client side I set the codebase property as:
System.setProperty("java.rmi.server.codebase", "C:\\Users\\spacitron\\Projects\\RMIClient\\bin");
If I try to add the same line on the server I get a "permission denied" error.
A codebase is a list of URLs. What you have specified is a file name, not a URL.
It is also a rather useless filename, unless the client is on the same host as the server, in which case it is difficult to see why you're using the codebase feature at all. Even if you have a shared drive it is just as easy to specify directories in the client's CLASSPATH as it is to use java.rmi.server.codebase. A codebase URL needs to be usable by the recipient. That's why they are almost always HTTP URLs, or maybe FTP URLs.
try down grading your jdk7 below update 21/jdk6 below update 45.
compile and test again of this work problem is java.rmi.server.useCodebaseOnly system property
please check below link for solution for both version of jdk's
http://docs.oracle.com/javase/7/docs/technotes/guides/rmi/relnotes.html
I have a java program Read which reads file from an URL looks like this:
file://myhost/system.log
On Windows I use this command:
java Read "file://myhost/system.log"
and it works flawlessly.
But on Linux when I try to use the same command it gives me this error:
Exception in thread "main" java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.ftp.impl.FtpClient.doConnect(Unknown Source)
at sun.net.ftp.impl.FtpClient.tryConnect(Unknown Source)
at sun.net.ftp.impl.FtpClient.connect(Unknown Source)
at sun.net.ftp.impl.FtpClient.connect(Unknown Source)
at sun.net.www.protocol.ftp.FtpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(Unknown Source)
at java.net.URL.openStream(Unknown Source)
at read.readInput(ReadHTML.java:53)
at read.readInput.main(ReadHTML.java:76)
Any ideas?
UPDATE:
I think I found the problem:
myhost is not mounted on the Linux machine so that it cannot connect to it by using file://...
Thanks for all the answers, guys!
This is because your program (by virtue of using a file URL on a Linux OS) is attempting to open an FTP connection to the host specified in the URL. The establishment of the FTP connection fails.
This could be due to a variety of issues. Try connecting with ftp directly:
ftp myhost
And I'm guessing it'd fail as well. Do you have an FTP server installed & running?
One of the possible reason can be that hosts.allow does not have entry of your machine.
I suspect you just need a third /. The correct syntax for file uris is file://[path] but [path] should begin with a /.
On a fresh installation of CruiseControl, every single time I start CruiseControl, I get the following two exceptions thrown:
ontrollerAgent- Exception starting httpAdaptor
java.net.BindException: Address already in use: JVM_Bind
at java.net.PlainSocketImpl.socketBind(Native Method)
ontrollerAgent- Exception starting connectorServer
java.io.IOException: Cannot bind to URL [jrmp]: javax.naming.NameAlreadyBoundException: jrmp [Root exception is java.rmi.AlreadyBoundException: jrmp]
at javax.management.remote.rmi.RMIConnectorServer.newIOException(Unknown Source)
Before and after these nothing seems to (obviously) go wrong. And as a result, I cannot view the web dashboard of CruiseControl. Any ideas on what is going wrong here?
Full stack traces:
[cc]Feb-25 16:33:49 ontrollerAgent- Starting HttpAdaptor with CC-Stylesheets
[cc]Feb-25 16:33:49 ontrollerAgent- starting httpAdaptor
[cc]Feb-25 16:33:49 ontrollerAgent- Exception starting httpAdaptor
java.net.BindException: Address already in use: JVM_Bind
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(Unknown Source)
at java.net.ServerSocket.bind(Unknown Source)
at java.net.ServerSocket.<init>(Unknown Source)
at mx4j.tools.adaptor.PlainAdaptorServerSocketFactory.createServerSocket (PlainAdaptorServerSocketFactory.java:24)
at mx4j.tools.adaptor.http.HttpAdaptor.createServerSocket(HttpAdaptor.java:672)
at mx4j.tools.adaptor.http.HttpAdaptor.start(HttpAdaptor.java:478)
at net.sourceforge.cruisecontrol.jmx.CruiseControlControllerAgent.start(CruiseControlControllerAgent.java:172)
[truncated]
[cc]Feb-25 16:33:49 ontrollerAgent- starting rmiRegistry
[cc]Feb-25 16:33:49 ontrollerAgent- Port 1099 is already in use, so no new rmiRe
gistry is started
[cc]Feb-25 16:33:49 ontrollerAgent- starting connectorServer
[cc]Feb-25 16:33:50 ontrollerAgent- Exception starting connectorServer
java.io.IOException: Cannot bind to URL [jrmp]: javax.naming.NameAlreadyBoundException: jrmp [Root exception is java.rmi.AlreadyBoundException: jrmp]
at javax.management.remote.rmi.RMIConnectorServer.newIOException(Unknown Source)
at javax.management.remote.rmi.RMIConnectorServer.start(Unknown Source)
at net.sourceforge.cruisecontrol.jmx.CruiseControlControllerAgent.start(CruiseControlControllerAgent.java:190)
at net.sourceforge.cruisecontrol.Main.startJmxAgent(Main.java:137)
at net.sourceforge.cruisecontrol.Main.start(Main.java:115)
at net.sourceforge.cruisecontrol.launch.Launcher.run(Launcher.java:259)
at net.sourceforge.cruisecontrol.launch.Launcher.main(Launcher.java:117)
Caused by: javax.naming.NameAlreadyBoundException: jrmp [Root exception is java.
rmi.AlreadyBoundException: jrmp]
at com.sun.jndi.rmi.registry.RegistryContext.bind(Unknown Source)
at com.sun.jndi.rmi.registry.RegistryContext.bind(Unknown Source)
at javax.naming.InitialContext.bind(Unknown Source)
at javax.management.remote.rmi.RMIConnectorServer.bind(Unknown Source)
... 6 more
Caused by: java.rmi.AlreadyBoundException: jrmp
at sun.rmi.registry.RegistryImpl.bind(Unknown Source)
at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.oldDispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
[truncated]
2010-02-25 16:33:50.710::INFO: Logging to STDERR via org.mortbay.log.StdErrLog
2010-02-25 16:33:50.850::INFO: jetty-6.1.11
2010-02-25 16:33:51.161:/dashboard:INFO: Initializing Spring root WebApplicationContext
Do you have any Java program still running at the time of CC starting?
As illustrated in this thread:
I've noticed when I restart cruisecontrol I need to kill any remaining java programs or a port class error will occur.
The solution is to:
Stop cruisecontrol
Kill any remaining cvs and java programs.
Wait 30 seconds.
Start cruisecontrol.
The OP bguiz adds in the comments his own recipe:
Stop CruiseControl
Kill any remaining cvs and java programs.
Restart computer,
sc delete CruiseControl,
wrapper -i wrapper.conf.
Start CruiseControl
It looks like you just have another application server running on your machine that uses the same ports as your cruise control server.
Do you deploy Cruise Control on a new server? What server is it?
Try to stop all the servers on your machine and try to launch cruise control again.
If you are using the windows service wrapper to launch CruiseControl, the RMI port is set to 1099 by default. You can alter this port by editing the wrapper.conf file in your CruiseControl installation directory. You might want to run 'netstat' at a command prompt to list all the ports your system is currently using. Then pick one that doesn't conflict with any other server or process.
Killing all other processes isn't always an option.
I'm trying to implement Sun Tutorials RMI application that calculates Pi. I'm having some serious problems and I cant find the solution eventhough I've been searching the entire web and several javaskilled people.
I'm hoping you can put an end to my frustrations.
The crazy thing is that I can run the application from the cmd on my desktop computer. Trying the exact same thing with the exact same code in the exact same directories on my laptop produces the following errors. The problem occures when I try to connect the client to the server.
I don't believe that the error is due to my policyfile as I can run it on the desktop. It must be elsewhere. Have anyone tried the same and can you give me a hint as to where my problem is, please?
POLICYFILE SERVER:
grant
{
permission java.security.AllPermissions;
permission java.net.SocketPermission"*", "connect, resolve";
};
POLICYFILE CLIENT:
grant
{
permission java.security.AllPermissions;
permission java.net.SocketPermission"*", "connect, resolve";
};
______________________________________________
SERVERSIDE ERRORS:
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\STUDENT>cd\
C:\>start rmiregistry
C:\>java -cp c:\java;c:\java\compute.jar -Djava.rmi.server.codebase=file:/c:/jav
a/compute.jar -Djava.rmi.server.hostname=localhost -Djava.security.policy=c:/jav
a/servertest.policy engine.ComputeEngine
ComputeEngine bound
Exception in thread "RMI TCP Connection(idle)" java.security.AccessControlExcept
ion: access denied (java.net.SocketPermission 127.0.0.1:1440 accept,resolve)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkAccept(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.checkAcceptPermi
ssion(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.checkAcceptPermission(Unknown Sour
ce)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Sou
rce)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Sour
ce)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source
)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
_______________________________
CLIENTSIDE ERRORS:
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\STUDENT>cd\
C:\>java -cp c:\java;c:\java\compute.jar -Djava.rmi.server.codebase=file:\C:\jav
a\files\ -Djava.security.policy=c:/java/clienttest.policy client.ComputePi local
host 45
ComputePi exception:
java.rmi.UnmarshalException: Error unmarshaling return header; nested exception
is:
java.io.EOFException
at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(Unkn
own Source)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(Unknown Source)
at $Proxy0.executeTask(Unknown Source)
at client.ComputePi.main(ComputePi.java:18)
Caused by: java.io.EOFException
at java.io.DataInputStream.readByte(Unknown Source)
... 6 more
C:\>
Thanks in advance
Perry
Your server didn't have permission to accept a connection from that client.
Ergo your policy file wasn't where you said it was, or wasn't loaded for some other reason.
Run it with -Djava.security.debug=access,failure and you will see what protection domain you were in when the security exception occurred, and what permissions it had.
java -cp c:\java;c:\java\compute.jar -Djava.rmi.server.codebase=file:/c:/java/compute.jar -Djava.rmi.server.hostname=localhost -Djava.security.policy=c:/java/servertest.policy engine.ComputeEngine
NB a file: codebase cannot work if it refers to a local filesystem, unless the client is also in the same machine, which makes RMI fairly pointless. Codebase URLs need to refer to locations that are accessible by the client. You can use shared file systems but you must provide a URL that is usable by the client. The server doesn't use its own codebase URL at all.
I tried the same and I found that Java simply ignored the policy file, no matter where I put it or what I put into it or which option I used to make the VM pick it up.
In the end, I create my own SecurityManager in the code and did everything manually.