RMI Server Codebase Permission Denied
I'm having a problem trying to get my application running in a test environment. I currently have this same application up and running in an almost identical location without any issues, and I'm at a loss to understand what the problem is.
My application is an RMI server-client setup. At the moment, I'm having trouble with solely the server portion, as I'm unable to get it to access the codebase. I start the application with the following runServer.sh file (located in /usr/local/app/app, so the $ROOT_DIR=pwd is correct):
Line: -----
#!/bin/bash
ROOT_DIR=`pwd`
JAVA_HOME=/usr/java/latest
CLASSPATH=''
#:: Please edit the environmental variables below so that it refers
#:: to the location where you have distribution URL.
DISTRIBUTION_URL=file://$ROOT_DIR
find /usr/local/app/app/server -name '*.jar' -type f -print | while read FILE
do
if [ $CLASSPATH ]
then
CLASSPATH=$CLASSPATH:$FILE
else
CLASSPATH=$FILE
fi
echo $CLASSPATH > classpath.env
done
read CLASSPATH < classpath.env
find /usr/local/app/app/import -name '*.jar' -type f -print | while read FILE
do
if [ $CLASSPATH ]
then
CLASSPATH=$CLASSPATH:$FILE
else
CLASSPATH=$FILE
fi
echo $CLASSPATH > classpath.env
done
read CLASSPATH < classpath.env
find /usr/local/app/app/common -name '*.jar' -type f -print | while read FILE
do
if [ $CLASSPATH ]
then
CLASSPATH=$CLASSPATH:$FILE
else
CLASSPATH=$FILE
fi
echo $CLASSPATH > classpath.env
done
read CLASSPATH < classpath.env
echo ${CLASSPATH}
cd server
# start /min "RMI Registry"
$JAVA_HOME/bin/rmiregistry &
JAVA_SECURITY="-Djava.security.policy==config/admin.policy -Djava.security.auth.login.config==config/app_jaas.config"
IMPORT_PROPERTIES="-Dapp.import.properties=file://$ROOT_DIR/import/config/import.properties -Dapp.import.logging.properties=file://$ROOT_DIR/import/config/importlog.properties -Dapp.client.properties=file://$ROOT_DIR/client/config/client.properties"
app_PROPERTIES="-Dapp.root=$ROOT_DIR -Dconnection.pool.properties=file://$ROOT_DIR/server/config/database.properties -Dapp.common.properties=$DISTRIBUTION_URL/common/config/common.properties -Dapp.server.properties=file://$ROOT_DIR/server/config/server.properties -Dapp.server.logging.properties=file://$ROOT_DIR/server/config/log.properties"
echo
echo "-------------- app Server -------------------"
echo
$JAVA_HOME/bin/java -ms96m -mx256m -classpath $CLASSPATH -Djava.rmi.server.codebase=file:///usr/local/app/app/common/lib/common.jar $IMPORT_PROPERTIES $JAVA_SECURITY $app_PROPERTIES -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=n app.serverimpl.ServerStarter
cd $ROOT_DIR
Line: -----
After running this, it fails at that last line, $JAVA_HOME/bin/java etc. Near as I can see from the error is that it cannot access the -Djava.rmi.server.codebase.
Line: -----
app.serverimpl.service.ServiceException: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 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.bind(Unknown Source)
at app.serverimpl.service.LoginManagerServiceImpl.start(LoginManagerServiceImpl.java:52)
at app.serverimpl.service.ServiceAdapter.start(ServiceAdapter.java:96)
at app.serverimpl.service.ServiceManager.startup(ServiceManager.java:78)
at app.serverimpl.ServerStarter.main(ServerStarter.java:62)
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 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: access to class loader denied
at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:445)
at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:182)
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:214)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1592)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1513)
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
Caused by: java.security.AccessControlException: access denied (java.io.FilePermission /usr/local/app/app/common/lib/- read)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:393)
at java.security.AccessController.checkPermission(AccessController.java:553)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at sun.rmi.server.LoaderHandler$Loader.checkPermissions(LoaderHandler.java:1173)
at sun.rmi.server.LoaderHandler$Loader.access$000(LoaderHandler.java:1127)
at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:409)
... 21 more
Line: -----
Out of growing desperation (and since it's a test VM in virtual box so I'm not really protecting anything) I've already granted full permissions to everyone for these these files in the filesystem itself - chmod -R 775 - and I've made sure that common.jar is accessible. I also double-checked the Security Policy, Djava.security.policy, and that's just a straight all permission to everything (again, I'm not protecting anything on this test).
Line: -----
grant {
permission java.security.AllPermission;
Line: -----
What's really driving me nuts is that this exact same code is already running and working on another machine. There are no environment variables that I'm missing, and I don't see how those would relate to this problem even if I did. The directories are identical, and I've verified the location that's listed as the cause (/usr/local/app/app/common/lib/) exists and is accessible. I keep coming back to the file permissions and the security policy and I'm sure I could be missing something obvious, but I am not seeing it at all. Can anyone give me some advice on this?
I'm running a VM in VirtualBox 4.1.4, running CentOS 5.7 32-bit. Java is JDK 1.6.0, just the basic yum install package.
This is a .policy file problem, not a filesystem permissions problem. Run it with -Djava.security.debug=access,failure to see exactly what is going on. Basically your .policy file either doesn't grant the required FilePermission or isn't being loaded.
NB a codebase of a local JAR file isn't going to work unless all the clients are in the same host.
Similar Messages
-
I'm trying to run an RMI application (under Windows XP, one machine for client and server) like this:
at server side:
java -Djava.rmi.server.codebase=file://\..\..\..\j\ -Djava.security.policy=file:.\polityka.txt sss
- and it works fine, but at client side:
java -Djava.security.policy=file:.\polityka.txt -Djava.rmi.server.codebase=file://\..\..\..\j\ kkk
results in:
Exception in thread "main" java.lang.NoClassDefFoundError: PrzykladowaKlasa
at kkk.main(kkk.java:31)
when I'm listing directory (at client side) got with System.getProperty("java.rmi.server.codebase") i get this
file://\..\..\..\j\
OdleglaKlasa_Stub.class
PrzykladowaKlasa.class
Folder Structure is:
|------j\
| |------(*_Stub.class, and ClassNeededByClient.class)
|------2\
| |------Server\
| | |------(serwer files)
| |------Klient\
| | |------(klient files)
I'm fresh in RMI and Codebase poperty, but with some exp with Java...
(policy files are allright - grant {permission java.security.AllPermission;};)
Any help will be appreciated.I've come back to this issue again (since I am moving code around to different systems again). Using linux I can use -Djava.rmi.server.codebase=file://$PWD/build/
Presumably there is a similar command in WIndows. -
Java.rmi.server.codebase in JSP
Hi,
i have a system made from an RMI client and an RMI server. The users access the system through a JSP page, which creates an instance of the RMI client. In order for the system to work, i need to specify the java.rmi.server.codebase property.
For testing purposes the client has a main(..) method. If i run just the client the server and specify java.rmi.server.codebase, everything works.
If i don't specify it i get a java.rmi.UnmarshalException, with the nested exception of ClassNotFound. The same exception i get trying to access the jsp page. So, i guess, it's due to the lack of the property.
I tried setting the property in the jsp page, but it doesn't work.
Thank you.
P.S. : maybe this is relevant: my jsp server is tomcat 6.0.it refers to where are your stubs and skeletons
you can set it to point to the jar files or to the directory that contains them
hope htis helps
regards
marco -
Rmiregistry �J-Djava.rmi.server.codebase=URL
Hi all,
When starting the rmiregistry, I do the following:
rmiregistry �J-Djava.rmi.server.codebase=URL
Eager to understand what is going on, I read that this means the following:
RMIClassLoader:
For stubs and skeletons of remote objects created in the local virtual machine, the URL specified by the local java.rmi.server.codebase property is used.
I thought "hey why not do the same for the server" and tried:
java -Djava.rmi.server.codebase=URL Server
getting me a StubNotFoundException. Can anybody tell me what I am doing wrong? The Server works when the Stub is in the local classpath but refuses to load it via the http Server. Am I at least theoretically right or is there a fundamental misconception in what I am trying?
Thanks,
RalfRMI uses annotations to record codebase information. In addition to recording the class despriptions also records info about the location from which it loaded the classes bytecode. If you are trying to specify the codebase on the server and removing the stubs from the servers classpath the bytecode will never actually get loaded.
-
Cross posted in the hope that someone using it knows how....
I am using the following command:
java -Djava.rmi.server.codebase=file:///home/ben/fyp/build/ -Djava.security.policy=security.policy -cp ./lib/bcprov-jdk15-130.jar:./props:./build com.bensmyth.fyp.example.IssuerServer
Can I specify -Djava.rmi.server.codebase=file:///home/ben/fyp/build/ without giving the whole path? Can I say ./build?I've come back to this issue again (since I am moving code around to different systems again). Using linux I can use -Djava.rmi.server.codebase=file://$PWD/build/
Presumably there is a similar command in WIndows. -
-Djava.rmi.server.codebase Question.
When I study the meaning of codebase in
http://java.sun.com/j2se/1.3/docs/guide/rmi/codebase.html
, I am still confuse what is different between codebase
settings in Remote Object side and RMI Client side.
The command options -Djava.rmi.server.codebase=
http://myHost/myDir and -Djava.rmi.server.codebase=
http://wwwserver/mydirectory ( in Figure3 and Figure4 of
http://java.sun.com/j2se/1.3/docs/guide/rmi/codebase.html
) are set in which side ??
The option in Remote Object side seems no any work.
Who can explain its meaning ??
Thank you in advance... Alan.Hi,
For the dynamic class loading to work, you should give
-Djava.rmi.server.codebase=http://some-server/
you can see that it supports http protocol.. So there should be one web server running on the server side so that client can call it by name or by IP address.. Then try running the program again. now it will work..
actually you should give this option on client side as it is the client who needs this property.. so in order to download classes the server machine should be addresable to the client in any method. if it is a LAN, try giving '\\computer-name' in the value of the property.. I haven't tried this, but I think you dont need a http server this time.. I am not sure abt this,,. check it out..
- Bibin. -
Spaces in -Djava.rmi.server.codebase path
hello,
how must i format the string containing the codebase for a rmi server if the path to the codebase contains spaces?
-Djava.rmi.server.codebase=file:c:/path/ and -Djava.rmi.server.codebase=file:/path/ works, but
-Djava.rmi.server.codebase=file:c:/path with spaces/ doesnt work
i have tried to put the string in quotes and to replace the spaces with %20 (url encoded)
but nothing does work.
how must i format the string?
cu,
elmarI guess you are using a batch file to start your RMI application.
Spaces in URLs must be encoded with %20, that is correct.
The problem is: the command line interpreter on Windows interprets % as a special character and will replace it.
What worked for me (Windows Vista):
java -Djava.rmi.server.codebase="file:/C:/Users/FirstName%%20LastName/RMI/" App
So encode each white space with %%20.
You can very easily check by inserting the following code at the start of your RMI application. These lets you see how the codebase is set.
System.out.println(" Codebase: " + System.getProperty("java.rmi.server.codebase")); -
Server Debug Permission denied
I upgraded to CF8 and now when using the "Server Debug"
feture in Dreamweaver 8 I get an error. I can skip the error and
everything seems ok. It is just such a pain to get the error
message each time I start a debug session.
The error is:
The following error has occured while connecting to the
ColdFusion Server:
Permission denied for the requested operation.
Each time I make the error occure an entry is placed in the
ColdFusion Runtime log:
user RDSServlet: Permission denied for the requested
operation
I am running on MS IIS on a windows XP proTry turning on logging.
I typically edit /etc/syslog.conf and add an entry
local7.info;local7.debug /var/log/sshd
ensuring the entries are tab delimited.
Then
touch /var/log/sshd
Edit /etc/ssh/sshd_config and change
SyslogFacility auth
LogLevel info
to
SyslogFacility LOCAL7
LogLevel debug
Restart everything:
svcadm restart system-log
svcadm restart ssh -
Rmi.server.codebase property
Hi i am new ,
I've writting a small RMI-application using Apache webserver lo load classes,that will be needed by client.
the question:I will instead of webserver(http or ftp) a file protocol and as codebase a networkdrive,that be of course from client accessible
what muss exactly written in the property?
thanks!file://myserver/mydirectory/myjarfile.jar. If there are any spaces they must be URL-encoded as %20. See java.net.URLEncoder.
-
Is it a must to set java.rmi.server.codebase property?
As to my understanding, only when JVM cannot find the necessary class from the local CLASSPATH will it tries to download the classes from the codebase right? so if the class exists in the local machine, actually it is unnecessary to set this property? Urgent, help!!!!!
Correct.
-
How to set the granted permission in RMI SERVER site
Hi everyone,
I have developin some simple RMi program but the error message is keep on prompting out and I cant really test out what is the result. I understand I got to GRANT the permission for the RMI but I I dun really know where should I start first. I know there are code that can be implement in the sErver site, just hope some one can guide me out.
Thank lot...
here is the code for server:
import java.rmi.*;
import java.rmi.server.UnicastRemoteObject;
public class myRMIServer
public static void main(String[] argv)
System.setSecurityManager(new RMISecurityManager());
try
myRMIImpl implementation = new myRMIImpl("myRMIImplInstance");
catch (Exception e)
System.out.println("Exception occurred: " + e);
Where should i code the getProperties and setProperties code...so, what u mean is the problem occur doesnt related to coding part ?? do you think it is because I did not start the rmiRegistry, but somehow when i started the rmiRegistry, the console window is blank an it is nothing in the window. pls pls help me to solve this problem... sound easy initially but end up it is not...
by the way, here is the code
Interface
public interface myRMIInterface extends java.rmi.Remote
public java.util.Date getDate() throws java.rmi.RemoteException;
Interface Implementation
import java.rmi.*;
import java.rmi.server.UnicastRemoteObject;
public class myRMIImpl extends UnicastRemoteObject implements myRMIInterface
public myRMIImpl(String name) throws RemoteException
super();
try
Naming.rebind(name, this);
catch(Exception e)
System.out.println("Exception occurred: " + e);
public java.util.Date getDate()
return new java.util.Date();
server
import java.rmi.*;
import java.rmi.Naming;
import java.rmi.RMISecurityManager;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.registry.LocateRegistry;
import java.util.Properties;
public class myRMIServer
public static void main(String[] argv)
//System.setProperty("java.security.policy","C:\\workspace\\MyRMI\\java.policy");
//System.getProperty("java.security.policy","C:\\workspace\\MyRMI\\java.policy");
//myRMIServer m = System.getProperties();
//m.setProperty("java.security.policy","C:\\workspace\\MyRMI\\java.policy");
//System.setSecurityManager(new RMISecurityManager());
//Properties p = System.getProperties();
//p.setProperty("java.security.policy","C:\\workspace\\MyRMI\\java.policy");
try
myRMIImpl implementation = new myRMIImpl("myRMIImplInstance");
Properties p = System.getProperties();
System.setProperty("java.security.policy","C:\\workspace\\MyRMI\\java.policy.txt");
System.setProperty("java.rmi.server.codebase","file:///P:\\Projects\\RMIServer\\bin");
if (System.getSecurityManager() == null) {
System.setSecurityManager(new RMISecurityManager());
System.out.println("Security manager registered");
//System.out.println("Service registered");
catch (Exception e)
System.out.println("Exception occurred: " + e);
here is the code, to run, I got a client one as well, but is just for displat purpose..
thank you, guys....really appreciate ur help -
PERMISSION DENIED IN FTP SERVER
Hi all,
i have XML to XML scenario. i have put xi_input.xml in my system and made delete mode in sender communication channel. but its not picking and deleting the data, its giving error in FTP serve as "permission denied" and in runtime work bench error is "Failed to delete file 'xi_input.txt' after processing. The FTP server returned the following error message: 'com.sap.aii.adapter.file.ftp.FTPEx: 550 Permission denied'. For details, contact your FTP server vendor.". please help me
thanks and regards>
pawan kumar wrote:
i m getting output XML file in my system.but i tried with directly one to one mapping in message mapping, now i did some modification in Message mapping like i concatenate name by X in message mapping and in description i passed ZSUBHODIP as constant then in output i am not getting concatenateed value and constant ZSUBHODIP in name and description.
Hi,
Did you activate the message mapping after modification ??
If yes, test the mapping in test tab and let us know the exact error.
Regards,
Chandra -
Codebase run RMI server .NoClassDefFoundError:
If I run the folllowing from the solaris command line
java -cp /junk/jdev+/jdev/src -Djava.rmi.server.logCalls=true -Djava.rmi.server.codebase=file:////junk/jdev+/jdev/src/ -Djava.security.policy=/junk/jdev+/jdev/src/jdev/server/policy jdev.server.RMIServerDBAdapter
my RMIServerDBAdapter binds regardless of my current working directory. In other words the RMI server
runs and binds as expected.
If I remove the classpath clause of the java command (-cp /junk/jdev+/jdev/src) then the RMI server
will only run and bind if my current working directory is the "root" of the package.
In this case if my current working directory is /junk/jdev+/jdev/src the RMI server will run and bind as
it should. If my current working directory is at the root of the solaris file system ( / ) I get the following error
Exception in thread "main" java.lang.NoClassDefFoundError: jdev/server/RMIServerDBAdapter
My question is why doesn't the code base clause of the java command point to the root
directory of the package /junk/jdev+/jdev/src. It seems to me that the codebase clause
would point to the root directory of the package allowing the RMI server to run and bind as expected
regardless of the current working directory.
I cannot get this to work. I have tried 0-4 slashes (file:/, - file:////) that did not seem to help.
The package statement in the java source files is
package jdev.server
Thank you in advance for your help.
Michael
[email protected]Hi Ciaccio,
Your question is doesn't clear enogh to me to answer it straight... But I'll try... :)
First you must not mix the reason and usage of the codebase and classpath. Classpath is locally parsed and used, codebase is remotely parsed and used (at the registry and at the client side).
Your server program cannot start if you don't tell to the system where to find the needed classes. That's why you have to specify the root path of the jdev.server.RMIServerDBAdapter in the CLASSPATH (from that point will search the java system the jdev dir, the server dir and the RMIServerDBAdapter object) .
If the Java system is unable to locate any of a needed class it throws a nice exception during the startup of the server program.
The codebase property is used by the client and the registry to locate the stub objects (and return types and parameter types) if those cannot be found on their local classpath. This path (or it would be more accurate to call what it is: URL) must be an absolute address (path, URI, etc), because the clients and the registry can be started anywhere. This way you also have to set RMISecurityManager and polici files also to your client because of dynamic class downloading...
Last thing:
Note the line above: ...if those cannot be found on their local classpath... If the stubs and the param/return types are present in the registry's and the clients local classpath then you don't have to specify codebase property at the server side because it is not parsed at all.
I hope I could help,
Sanyi -
Connecting to MYSQL from RMI Server results SQL Communication fail
Hi ,
I have an RMI Server which exports a remote method, which in-turn needs to access content
from the MYSQL Database.
PROBLEM: The code snip for RMI Server is given below. In this getChief() is the remote method called
by the RMI Client running on my same Windows XP machine (ie., localhost).
I get a slew of exceptions when the DriverManager.getConnection() API call occurs in getChief()
via the remote method call from the RMI Client. Two exceptions are the SQL Communications failure and Access Denied Socket Exceptions.
I checked my policy file is OK and MySQL Server is running and my username/password is right in code?
Can you please let me know what am I missing in the RMI Server code?
I also found my code works if the Database Connection API is used within main() rather than inside a Remote
Method...
The Source and Binary are available in my local Windows XP Machine
RMI Server: c:/workspace/DirectoryJava/src/server for and c:/workspace/DirectoryJava/bin/server
RMI Client: c:/workspace/DirectoryJava/src/client for and c:/workspace/DirectoryJava/bin/client
My security policy file is:
grant codeBase "file:/workspace/DirectoryJava/bin" {
permission java.security.AllPermission;
permission java.net.SocketPermission "*:1024-65535", "listen,connect,accept,resolve";
permission java.net.SocketPermission "*","listen,connect,accept,resolve";
grant codeBase "file:/workspace/DirectoryJava/bin/client" {
permission java.security.AllPermission;
permission java.net.SocketPermission "*:1024-65535", "listen,connect,accept,resolve";
permission java.net.SocketPermission "*","listen,connect,accept,resolve";
grant codeBase "file:/workspace/DirectoryJava/bin/server" {
permission java.security.AllPermission;
permission java.net.SocketPermission "*:1024-65535", "listen,connect,accept,resolve";
permission java.net.SocketPermission "*","listen,connect,accept,resolve";
grant codeBase "file:/workspace/DirectoryJava/bin/directory" {
permission java.security.AllPermission;
permission java.net.SocketPermission "*:1024-65535", "listen,connect,accept,resolve";
permission java.net.SocketPermission "*","listen,connect,accept,resolve";
grant codeBase "file:/workspace/DirectoryJava/src/client" {
permission java.security.AllPermission;
permission java.net.SocketPermission "*:1024-65535", "listen,connect,accept,resolve";
permission java.net.SocketPermission "*","listen,connect,accept,resolve";
grant codeBase "file:/workspace/DirectoryJava/src/server" {
permission java.security.AllPermission;
permission java.net.SocketPermission "*:1024-65535", "listen,connect,accept,resolve";
permission java.net.SocketPermission "*","listen,connect,accept,resolve";
grant codeBase "file:/workspace/DirectoryJava/src/directory" {
permission java.security.AllPermission;
permission java.net.SocketPermission "*:1024-65535", "listen,connect,accept,resolve";
permission java.net.SocketPermission "*","listen,connect,accept,resolve";
};I checked that mysqld.exe is running at port 3306 and am able to connect to and use it via
MySQL Command Client successfully.
Thanks in advance.
The Exception list is pasted below.
c:\workspace\DirectoryJava\bin>java -cp "c:/workspace/Directory
Java/bin/Directory.jar;c:/workspace/DirectoryJava/bin/server;c:/workspac
e/DirectoryJava/bin;C:/Program Files/MySQL/mysql-connector-java-5.1.6/my
sql-connector-java-5.1.6-bin.jar" -Djava.rmi.server.codebase=file:/c:/workspace/
DirectoryJava/bin/Directory.jar -Djava.security.policy=wideopen.policy
server.DirectoryEngine
DirectoryEngine bound
getChief() Called
SQLException: Communications link failure
Last packet sent to the server was 0 ms ago.
SQLState: 08S01
VendorError: 0
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link fai
lure
Last packet sent to the server was 0 ms ago.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Sou
rce)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1
074)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2103)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:718)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Sou
rce)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:302)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java
:282)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at server.DirectoryEngine.getChief(DirectoryEngine.java:91)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(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)
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)
Caused by: java.net.SocketException: java.security.AccessControlException: acces
s denied (java.net.SocketPermission 127.0.0.1:3306 connect,resolve)
at com.mysql.jdbc.StandardSocketFactory.unwrapExceptionToProperClassAndT
hrowIt(StandardSocketFactory.java:404)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.ja
va:265)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:280)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2026)
... 26 moreCODE SNIP:
=========
public class DirectoryEngine implements Directory {
public DirectoryEngine() {
super();
public Employee getChief() throws RemoteException {
Statement stmt = null;
ResultSet rs = null;
Employee emp = null;
// TODO Auto-generated method stub
try {
System.out.println("getChief() Called");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306",
"<username>","<password>");
// Username and Password were replaced with root username and password in my original code
System.out.println("getConnection() Called");
stmt = conn.createStatement( ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_READ_ONLY);
System.out.println("createStatement() Called");
rs = stmt.executeQuery("use mysql");
} catch (SQLException ex) {
// handle any errors
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
ex.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
// it is a good idea to release
// resources in a finally{} block
// in reverse-order of their creation
// if they are no-longer needed
if (rs != null) {
try {
rs.close();
} catch (SQLException sqlEx){
// ignore
rs = null;
if (stmt != null) {
try {
stmt.close();
} catch (SQLException sqlEx) {
// ignore
stmt = null;
return emp;
} /* getChief() ends */
public static void main(String[] args) {
if (System.getSecurityManager() == null) {
System.setSecurityManager(new SecurityManager());
try {
String name = "Directory";
Directory engine = new DirectoryEngine();
Directory stub =
(Directory) UnicastRemoteObject.exportObject(engine, 0);
Registry registry = LocateRegistry.getRegistry();
registry.rebind(name, stub);
Class.forName("com.mysql.jdbc.Driver").newInstance();
System.out.println("DirectoryEngine bound");
} catch (Exception e) {
System.err.println("DirectoryEngine exception:");
e.printStackTrace();
} /* end DirectoryEngine class */It looks there is some permission issue.
Can you please try once with below policy and let me know the result.
grant {
permission java.security.AllPermission;
}; -
Problem in starting RMI server, please help!
Hi , all:
I am learning RMI from SUN's tutorial. I set all of program packages as same as the tutorial, compiled all of programs . and built all of the jar files, the server classes and the client classes.When I run the server, ComputeEngine, it did not work ,and the following messages were showed at command lines:
C:\RMI\doc>java -Djava.rmi.server.codebase=file:/c:\rmi\ann\public_html\classes/
-Djava.rmi.server.hostname=localhost -Djava.security.policy=java.policy eng
ine.ComputeEngine
ComputeEngine exception: access denied (java.net.SocketPermission 127.0.0.1:1099
connect,resolve)
java.security.AccessControlException: access denied (java.net.SocketPermission 1
27.0.0.1:1099 connect,resolve)
at java.security.AccessControlContext.checkPermission(AccessControlConte
xt.java:272)
at java.security.AccessController.checkPermission(AccessController.java:
399)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:545)
at java.lang.SecurityManager.checkConnect(SecurityManager.java:1044)
at java.net.Socket.<init>(Socket.java:262)
at java.net.Socket.<init>(Socket.java:100)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirect
SocketFactory.java:25)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMaster
SocketFactory.java:120)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:499)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:190
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:174)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:318)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Naming.java:160)
at engine.ComputeEngine.main(ComputeEngine.java:25)
Please give helps .
Thanks!Thank.
Thank.
I have put them at the same directory, but is deos not work.
Something I am not sure.
On the SUN's tutorial , the follows is given:
Win32:
java -Djava.rmi.server.codebase=file:/c:\home\ann\public_html\classes/
-Djava.rmi.server.hostname=zaphod.east.sun.com
-Djava.security.policy=java.policy
engine.ComputeEngine
I changed hostname = localhost
I also changed the code of the server class given by tutorial :
String name = "//host/Compute" ;
to:
String name = "//localhost/Compute";
Should I make such changes?
Here is the server class given by the tutorial:
package engine;
import java.rmi.*;
import java.rmi.server.*;
import compute.*;
public class ComputeEngine extends UnicastRemoteObject
implements Compute
public ComputeEngine() throws RemoteException {
super();
public Object executeTask(Task t) {
return t.execute();
public static void main(String[] args) {
if (System.getSecurityManager() == null) {
System.setSecurityManager(new RMISecurityManager());
String name = "//host/Compute";
try {
Compute engine = new ComputeEngine();
Naming.rebind(name, engine);
System.out.println("ComputeEngine bound");
} catch (Exception e) {
System.err.println("ComputeEngine exception: " +
e.getMessage());
e.printStackTrace();
Maybe you are looking for
-
To import photos from my iPhone, I plug it into my MacBook Pro's iPhoto program. I am now also using iCloud photo sharing. When I import, my photos are DOUBLED. I'm sure I need to change my settings, but I'm not sure which ones to change. In my P
-
HI GUru's I have some problem to retrieve my spool id. After did my 'Submit' I pass my parameter and no spool id is generated. Does anybody could help me please? "Select the Cost Centers Responsible LOOP AT i_cntrllng_rsp INTO wa_cntrllng_rsp.
-
Packet filtering and traffic shaping during peak h...
I play the online game World of Tanks and an currently exteriancing severe lagg and disconnects, the problem does not appear to be with the game/service provider but with BT, i need to know does BT use "packet filtering" and "traffic shaping" during
-
Playing Songs One After the Other NOT WORKING
When I play a song on my iTunes, it finishes the song and then stops. I can't get iTunes to play the next song in the Library. I never had this problem until I put the new iTunes 7 on my machine. Thoughts?
-
How to download chart as an image ?
I am using the class CL_GUI_CHART_ENGINE to display a chart into a container on my screen. I wanted to know if it is possible to export the chart as an image (bmp / jpg). If yes, how ? Any help or guidance would be highly appreciated...