Java RMI cannot bind server - java

I'm working on Java RMI application, and having problem binding a server to the registry. I'm working on eclipse using rmi plugin, and everything worked fine before I had to format my pc. Also, I'm sure the code is ok since it's the one given to me as a solution, so there must be something wrong with my configuration.
Here's the code:
public static void main (String[] args){
try{
RMIChatServer myObject = new RMIChatServerImpl();
System.setSecurityManager(new RMISecurityManager());
Naming.rebind("Hello", myObject);
System.out.println("Remote object bound to registry");
}
catch( Exception e){
System.out.println("Failed to register object " + e);
e.printStackTrace();
System.exit(1);
}
}
Exceptions it gives:
Failed to register object java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: access to class loader denied
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: access to class loader denied
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:419)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:267)
at sun.rmi.transport.Transport$1.run(Transport.java:177)
at sun.rmi.transport.Transport$1.run(Transport.java:174)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:553)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:808)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:667)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:273)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:251)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:377)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Naming.java:177)
at RMIChatServerImpl.main(RMIChatServerImpl.java:175)
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: access to class loader denied
at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:409)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:267)
at sun.rmi.transport.Transport$1.run(Transport.java:177)
at sun.rmi.transport.Transport$1.run(Transport.java:174)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:553)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:808)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:667)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.ClassNotFoundException: access to class loader denied
at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:447)
at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:184)
at java.rmi.server.RMIClassLoader$2.loadClass(RMIClassLoader.java:637)
at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:264)
at sun.rmi.server.MarshalInputStream.resolveClass(MarshalInputStream.java:216)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1593)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1514)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1750)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
... 13 more
Caused by: java.security.AccessControlException: access denied ("java.io.FilePermission" "\D:\uni\YEAR 3\Enterprise Programming\java\czat solution 2\bin\-" "read")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:366)
at java.security.AccessController.checkPermission(AccessController.java:555)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at sun.rmi.server.LoaderHandler$Loader.checkPermissions(LoaderHandler.java:1176)
at sun.rmi.server.LoaderHandler$Loader.access$000(LoaderHandler.java:1130)
at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:411)
... 22 more
I researched the problem and most say that it's because of codebase settings (I also use security policy), I have tried different settings, and currently using 'compute from classpath' option provided by rmi plugin, which worked before, but fails now :( Please advice!

FWIW
I upgraded from JDK1.6.0_33 to 1.7.0_21 and had the same problem. I found this document and resolved the problem by starting rmiregistry with:
rmiregistry -J-Djava.rmi.server.useCodebaseOnly=false

So, quick summary of the problem and the solution:
If you're running on JDK 7.1/ 6.29 (possible some other version) RMI server will not bind if you set its codebase to the file or directory on your hard disk. The same code works just fine under older version of JDK (tested on 6.24).
Thanks for your help!

The underlying problem here is that the RMI Registry is running under a SecurityManager and its .policy file doesn't grant java.io.FilePermission" "\D:\uni\YEAR 3\Enterprise Programming\java\czat solution 2\bin\-" "read".
The clue to that is that this is a ServerException, i.e. thrown at the target of the call, and that the call itself is rebind().
See this post for an explanation.

Yes this problem occurs in Java 1.7 and above. So always go through the enhancements document if you upgrade your Java version. It is a fairly simple solution. You just need to start the rmiregistry in a different way.
Go through this document- http://docs.oracle.com/javase/7/docs/technotes/guides/rmi/enhancements-7.html

Have you tried to explicitly give access to the file using the *.policy file?
as described on
http://docs.oracle.com/javase/7/docs/technotes/guides/security/permissions.html
grant codebase "file:/path/to/code" {
permission java.io.FilePermission "\D:\uni\YEAR 3\Enterprise Programming\java\czat solution 2\bin\-", "read";
}
I have the same issue with openjdk... probably caused by this commit:
http://hg.openjdk.java.net/jdk7u/jdk7u-gate/jdk/rev/7ed2fd310470

Related

Caused by: java.lang.ExceptionInInitializerError at com.businessobjects.bcm.BCM.<clinit>(BCM.java:1144)

I am trying to deploy a war file which creates IEnterpriseSession. I am able to successfully run on tomcat, but when I run it on JBoss i get the below error at this step sessionMgr.logon(trustedPrincipal);
Caused by: java.lang.ExceptionInInitializerError
at com.businessobjects.bcm.BCM.<clinit>(BCM.java:1144)
at com.crystaldecisions.sdk.framework.internal.TrustedPrincipal.getRandomString(TrustedPrincipal.java:252)
at com.crystaldecisions.sdk.framework.internal.TrustedPrincipal.getPassword(TrustedPrincipal.java:195)
at com.crystaldecisions.sdk.framework.internal.SessionMgr.logon_aroundBody22(SessionMgr.java:850)
at com.crystaldecisions.sdk.framework.internal.SessionMgr.logon(SessionMgr.java:1)
at com.crystaldecisions.sdk.framework.internal.SessionMgr.logon_aroundBody20(SessionMgr.java:818)
at com.crystaldecisions.sdk.framework.internal.SessionMgr.logon_aroundBody21$advice(SessionMgr.java:512)
at com.crystaldecisions.sdk.framework.internal.SessionMgr.logon(SessionMgr.java:1)
I tried with the solution mentioned in the ExceptionInInitializerError - JBoss 7.0.2, but I still couldn't get through.
I was digging more into the error and this is where I am stuck
Caused by: java.lang.SecurityException: An internal FIPS 140 self-verification test has failed. Algorithm HMAC has been disabled
at com.rsa.cryptoj.f.ug.d(Unknown Source)
at com.rsa.cryptoj.f.ug.b(Unknown Source)
at com.rsa.cryptoj.f.nd.b(Unknown Source)
at com.rsa.cryptoj.f.nd.c(Unknown Source)
at com.rsa.jsafe.CryptoJ.isFIPS140Compliant(Unknown Source)
at com.businessobjects.bcm.internal.BcmRsaLib.initialize(BcmRsaLib.java:214)
at com.businessobjects.bcm.internal.BcmRsaLib.<clinit>(BcmRsaLib.java:289)
Can someone help me to get it working on JBoss?

ClassNotFoundException in RMI + servlet [duplicate]

This question already has answers here:
java.rmi.ServerException: RemoteException occurred in server thread (ClassNotFoundException)
(5 answers)
Closed 6 years ago.
Hi I'm trying to run a java application that binds a class to the naming server, but i constantly get a ClassNotFoundException
First I start the registry:
rmiregistry
then from eclipse I try to execute the server but get this error
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: progInternet2008.commons.NominabileFactory
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:396)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:250)
at sun.rmi.transport.Transport$1.run(Transport.java:159)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:255)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:233)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:359)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at progInternet2008.Pozzobon.tesi.Slave.main(Slave.java:54)
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: progInternet2008.commons.NominabileFactory
at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:386)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:250)
at sun.rmi.transport.Transport$1.run(Transport.java:159)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException: progInternet2008.commons.NominabileFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at sun.rmi.server.LoaderHandler.loadProxyInterfaces(LoaderHandler.java:711)
at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:655)
at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:592)
at java.rmi.server.RMIClassLoader$2.loadProxyClass(RMIClassLoader.java:628)
at java.rmi.server.RMIClassLoader.loadProxyClass(RMIClassLoader.java:294)
at sun.rmi.server.MarshalInputStream.resolveProxyClass(MarshalInputStream.java:238)
at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1531)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1493)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
... 12 more
I've read the RMI Java tutorial but still could not get it working...
As VM Arguments I've set this:
-Djava.rmi.server.codebase=file:${workspace_loc}/progInternet2008
please help me
(I'm using Java 6)
Run the rmiregisrty command from your /bin, /build, or /build/classes folder, whichever folder is the root of your built files.
I spent half a day trying to solve that same thing.
The exception is occurring because the rmiregistry application doesn't know where to load classes from. When you attempt to bind an object in the RMI registry, the registry downloads the class definition for that object. Some of the other answers are telling you to get around this by setting the classpath for the rmiregistry app so that it has the class definitions when it is started and doesn't need to download anything, but Sun's Java RMI tutorial explicitly says not to do this. I suspect this has the potential to cause conflicts between the version of the class in the registry and the class on the server.
The correct way to handle the problem is to set the java.rmi.server.codebase property as you were trying to do. The property requires that a directory path be terminated with a forward slash, like so:
-Djava.rmi.server.codebase=file:${workspace_loc}/progInternet2008/
You may also be having trouble if the ${workspace_loc} variable is a relative path and the rmiregistry application was not started in the same directory so the relative path is not correct for it. If you either make the path absolute, or start the rmiregistry in the appropriate directory, the ClassNotFoundException should go away. See the tutorial on the java.rmi.server.codebase property for a little more detailed information.
Okay I just overcame this problem. Make sure when you run rmiregistry that your CLASSPATH environment variable is set.
For example, you might have a script:
set CLASSPATH=[path to jdbc driver].jar
rmiregistry.exe
This was all I needed to get my lost classpath working. I'm not sure how to send -cp commandline to rmiregistry.exe. Its documentation is quite lacking.
I'm fairly certain that you'll have to start your RMI server using the same classpath as your application. I believe it takes the same parameters as java, i.e. -cp [your class path].
Close the cmd window where the rmiregistry was initially started.In a fresh cmd go to the location where your project classfiles are located(uptill bin) and start the registry using the below command:
rmiregistry -J-Djava.rmi.server.useCodebaseOnly=false
If you are using Eclipse ,Run the ServerSideProject and your ImplementationClass Instance gets bound to the URL specified.
Just print a line below the the binding method and see to it whether it is gets printed. If it gets printed successfully it means your server is working fine.
try to add /bin at the end of your VM Arg:
-Djava.rmi.server.codebase=file:${workspace_loc}/progInternet2008/bin
The file you will run are in this directory, so you need to include it in the path.
I upgraded from JDK1.6.0_33 to 1.7.0_45 and had the same problem. I found this document and resolved the problem by starting rmiregistry with:
rmiregistry -Djava.rmi.server.useCodebaseOnly=false
Refer below
http://docs.oracle.com/javase/7/docs/technotes/guides/rmi/enhancements-7.html
I had the same problem, to fix this ensure that your CLASSPATH is set to the path containing the server classes when running rmiregistry.
On a linux machine run the following commands.
export CLASSPATH="<server_class_path>"
Ensure the CLASSPATH has been set:
echo $CLASSPATH
Once the class path has been set, run rmiregistry
rmiregistry &
I spent a whole day uninstalling and reinstalling my JDK and changing the classpaths's and environment variables. But the culprit was that the command start rmigregistry didnt' start rmiregistry in a proper way. So, thanks for the comments on this page the solution was to unset the CLASSPATH temporarily. And that is done through the command set CLASSPATH=

rmi eclipse UnmarshalException ClassNotFoundException [duplicate]

This question already has answers here:
java.rmi.ServerException: RemoteException occurred in server thread (ClassNotFoundException)
(5 answers)
Closed 6 years ago.
Hi I'm trying to run a java application that binds a class to the naming server, but i constantly get a ClassNotFoundException
First I start the registry:
rmiregistry
then from eclipse I try to execute the server but get this error
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: progInternet2008.commons.NominabileFactory
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:396)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:250)
at sun.rmi.transport.Transport$1.run(Transport.java:159)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:255)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:233)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:359)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at progInternet2008.Pozzobon.tesi.Slave.main(Slave.java:54)
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: progInternet2008.commons.NominabileFactory
at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:386)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:250)
at sun.rmi.transport.Transport$1.run(Transport.java:159)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException: progInternet2008.commons.NominabileFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at sun.rmi.server.LoaderHandler.loadProxyInterfaces(LoaderHandler.java:711)
at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:655)
at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:592)
at java.rmi.server.RMIClassLoader$2.loadProxyClass(RMIClassLoader.java:628)
at java.rmi.server.RMIClassLoader.loadProxyClass(RMIClassLoader.java:294)
at sun.rmi.server.MarshalInputStream.resolveProxyClass(MarshalInputStream.java:238)
at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1531)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1493)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
... 12 more
I've read the RMI Java tutorial but still could not get it working...
As VM Arguments I've set this:
-Djava.rmi.server.codebase=file:${workspace_loc}/progInternet2008
please help me
(I'm using Java 6)
Run the rmiregisrty command from your /bin, /build, or /build/classes folder, whichever folder is the root of your built files.
I spent half a day trying to solve that same thing.
The exception is occurring because the rmiregistry application doesn't know where to load classes from. When you attempt to bind an object in the RMI registry, the registry downloads the class definition for that object. Some of the other answers are telling you to get around this by setting the classpath for the rmiregistry app so that it has the class definitions when it is started and doesn't need to download anything, but Sun's Java RMI tutorial explicitly says not to do this. I suspect this has the potential to cause conflicts between the version of the class in the registry and the class on the server.
The correct way to handle the problem is to set the java.rmi.server.codebase property as you were trying to do. The property requires that a directory path be terminated with a forward slash, like so:
-Djava.rmi.server.codebase=file:${workspace_loc}/progInternet2008/
You may also be having trouble if the ${workspace_loc} variable is a relative path and the rmiregistry application was not started in the same directory so the relative path is not correct for it. If you either make the path absolute, or start the rmiregistry in the appropriate directory, the ClassNotFoundException should go away. See the tutorial on the java.rmi.server.codebase property for a little more detailed information.
Okay I just overcame this problem. Make sure when you run rmiregistry that your CLASSPATH environment variable is set.
For example, you might have a script:
set CLASSPATH=[path to jdbc driver].jar
rmiregistry.exe
This was all I needed to get my lost classpath working. I'm not sure how to send -cp commandline to rmiregistry.exe. Its documentation is quite lacking.
I'm fairly certain that you'll have to start your RMI server using the same classpath as your application. I believe it takes the same parameters as java, i.e. -cp [your class path].
Close the cmd window where the rmiregistry was initially started.In a fresh cmd go to the location where your project classfiles are located(uptill bin) and start the registry using the below command:
rmiregistry -J-Djava.rmi.server.useCodebaseOnly=false
If you are using Eclipse ,Run the ServerSideProject and your ImplementationClass Instance gets bound to the URL specified.
Just print a line below the the binding method and see to it whether it is gets printed. If it gets printed successfully it means your server is working fine.
try to add /bin at the end of your VM Arg:
-Djava.rmi.server.codebase=file:${workspace_loc}/progInternet2008/bin
The file you will run are in this directory, so you need to include it in the path.
I upgraded from JDK1.6.0_33 to 1.7.0_45 and had the same problem. I found this document and resolved the problem by starting rmiregistry with:
rmiregistry -Djava.rmi.server.useCodebaseOnly=false
Refer below
http://docs.oracle.com/javase/7/docs/technotes/guides/rmi/enhancements-7.html
I had the same problem, to fix this ensure that your CLASSPATH is set to the path containing the server classes when running rmiregistry.
On a linux machine run the following commands.
export CLASSPATH="<server_class_path>"
Ensure the CLASSPATH has been set:
echo $CLASSPATH
Once the class path has been set, run rmiregistry
rmiregistry &
I spent a whole day uninstalling and reinstalling my JDK and changing the classpaths's and environment variables. But the culprit was that the command start rmigregistry didnt' start rmiregistry in a proper way. So, thanks for the comments on this page the solution was to unset the CLASSPATH temporarily. And that is done through the command set CLASSPATH=

How to deploy a report to Jasper Server

I tried to deploy a report to my jasper server. I followed this tutorial: http://randomallsorts.blogspot.de/2009/12/jasper-reports-how-to-deploy-report-to.html. But in the end of the day, when I tried to have a look at my report in the admin interface I just received a pretty long error which I don't understand.
The server has encountered an error. Please excuse the inconvenience.
Error Message
com.mysql.jdbc.Driver Error Trace
com.jaspersoft.jasperserver.api.JSExceptionWrapper:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1516)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361)
at java.lang.Class.forName0(Native Method) at
java.lang.Class.forName(Class.java:247) at
com.jaspersoft.jasperserver.api.common.service.impl.JdbcDriverServiceImpl.loadDriverFromExistingClassLoaders(JdbcDriverServiceImpl.java:535)
at
com.jaspersoft.jasperserver.api.common.service.impl.JdbcDriverServiceImpl.register(JdbcDriverServiceImpl.java:130)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597) at
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:196)
at $Proxy35.register(Unknown Source) at
com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.DbcpDataSourceFactory.registerDriver(DbcpDataSourceFactory.java:58)
at
com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.DbcpDataSourceFactory.createPooledDataSource(DbcpDataSourceFactory.java:50)
at
com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.JdbcReportDataSourceServiceFactory.getPoolDataSource(JdbcReportDataSourceServiceFactory.java:145)
at
com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.JdbcReportDataSourceServiceFactory.createService(JdbcReportDataSourceServiceFactory.java:128)
at
com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl.createDataSourceService(EngineServiceImpl.java:1763)
at
com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl.fillReport(EngineServiceImpl.java:1651)
at
com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl$ReportFill.runReport(EngineServiceImpl.java:1022)
at
com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl$ReportRunnable.run(EngineServiceImpl.java:897)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619) Error Message
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver Error Trace
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1516)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361)
at java.lang.Class.forName0(Native Method) at
java.lang.Class.forName(Class.java:247) at
com.jaspersoft.jasperserver.api.common.service.impl.JdbcDriverServiceImpl.loadDriverFromExistingClassLoaders(JdbcDriverServiceImpl.java:535)
at
com.jaspersoft.jasperserver.api.common.service.impl.JdbcDriverServiceImpl.register(JdbcDriverServiceImpl.java:130)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597) at
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:196)
at $Proxy35.register(Unknown Source) at
com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.DbcpDataSourceFactory.registerDriver(DbcpDataSourceFactory.java:58)
at
com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.DbcpDataSourceFactory.createPooledDataSource(DbcpDataSourceFactory.java:50)
at
com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.JdbcReportDataSourceServiceFactory.getPoolDataSource(JdbcReportDataSourceServiceFactory.java:145)
at
com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.JdbcReportDataSourceServiceFactory.createService(JdbcReportDataSourceServiceFactory.java:128)
at
com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl.createDataSourceService(EngineServiceImpl.java:1763)
at
com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl.fillReport(EngineServiceImpl.java:1651)
at
com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl$ReportFill.runReport(EngineServiceImpl.java:1022)
at
com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl$ReportRunnable.run(EngineServiceImpl.java:897)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Does anybody have a clue what could be wrong there ? I am sorry but I am really a ireport amateur.
First you should install the driver on your Jasper Server.
Go to the web interface with a user in the role ROLE_ADMINISTRATOR
On the tree view, you can create a folder to hold your datasource
In that folder, right click and add a data source
Give it a meaningful name for you and upload the com.mysql.jdbc.Driver (if not already present).
Note: if you did a manual WAR installation, you probably installed the driver already.
Download the driver here http://dev.mysql.com/downloads/connector/j/
Check the jdbc url. Should be something like jdbc:mysql://your_host/your_database
Small hack is to check your max allow packet setting in your MYSQL server and set it accordingly in your jdbc url. On MYSQL driver, check it using this command:
SHOW VARIABLES LIKE 'max_allowed_packet';
Then set the url to: jdbc:mysql://your_host/your_database?maxAllowedPacket=WHATEVER_SIZE_YOU_GOT
Check the username, password and timezone and test the connection.
Edit the report on the web interface and set the datasource as being this one.
When you upload a new report, either via web interface or iReport Designer, assign this data source.
Good luck, hope it solves your problem :)
try using this guide..
Seems like it cannot find the mysql driver to connect.
http://jasperserver.sourceforge.net/docs/3-5-0/JasperServer-User-Guide.pdf

rmi class can not found exception

I wrote an simple project using java rmi and exported to an executable jar file. When I tries to run it, sometimes i got exceptions and sometimes it works. When I specify -Djava.rmi.server.codebase=file:serverClasses/, it seems it didn't create the jar file correctly.
Here is the stacktrace:
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: com.ServerBootstrap.IServer
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:413)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:267)
at sun.rmi.transport.Transport$1.run(Transport.java:177)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:553)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:808)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:667)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:636)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:273)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:251)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:377)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Naming.java:177)
at com.v3q6.eece411.A2.ServerBootstrap.ChatRoomServer.main(ChatRoomServer.java:37)
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: com.ServerBootstrap.IServer
at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:403)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:267)
at sun.rmi.transport.Transport$1.run(Transport.java:177)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:553)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:808)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:667)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:636)
Caused by: java.lang.ClassNotFoundException: com.ServerBootstrap.IServer
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:336)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at sun.rmi.server.LoaderHandler.loadProxyInterfaces(LoaderHandler.java:728)
at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:672)
at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:609)
at java.rmi.server.RMIClassLoader$2.loadProxyClass(RMIClassLoader.java:646)
at java.rmi.server.RMIClassLoader.loadProxyClass(RMIClassLoader.java:311)
at sun.rmi.server.MarshalInputStream.resolveProxyClass(MarshalInputStream.java:255)
at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1548)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1510)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1749)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1346)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:368)
... 12 more
It seems the program doesn't recognize the codebase. In my case, all the files are local. Does anyone know what is the problem? thanks
Try explicitly specifying the name of the JAR file containing the com.ServerBootstrap.IServer class in your codebase, e.g.
-Djava.rmi.server.codebase=file:serverClasses/myjarfile.jar
The "Dynamic code downloading using JavaTM RMI (Using the java.rmi.server.codebase Property)" doc provides more information on the use of codebase and the options for its specification.
With a relative path specified for java.rmi.server.codebase, make sure that you are in the correct directory (the parent directory of "serverClasses") when starting the client. If that's hard to ensure, an absolute path for the codebase might be more reliable.
Also, remember that when running with the -jar option, the -classpath option is completely ignored. I don't think that's a problem here; the RMIClassLoader should still be able to work using the server's codebase setting. But if you are relying on the client having access to additional classes specified on the classpath, that won't work. You'll need to use the Class-path attribute in the main JAR file's manifest.
That's not a complete stacktrace, and I think you may have left out the part that shows the root cause of your problem.
If I recall correctly, ClassNotFoundException can sometimes be due to an exception thrown during static initialization of the class that is being loaded, or some class that it depends on. If this occurs, it will show up as a nested exception in the first stacktrace for the problem, at the next level of nesting. I recall (maybe incorrectly) that if your application repeats the attempted class load, the initialization exception is not in the resulting stacktrace.
EDIT: The complete stacktrace says that my theory is not correct.

Categories

Resources