I have developed a java se client that calls some session beans on a glassfish server v3. I connect to the bean remote i开发者_运维百科nterface like this.
context = new InitialContext();
em = (ICrudService) context.lookup("java:global/BackITServer/CrudServiceImpl");
This works fine from inside eclipse (gf-client on build path). When I export my project as a runnable jar and call it on the console with
java -jar BackItClient.jar
I get a NoInitialContextException.
javax.naming.NoInitialContextException: Need to specify class name
in enviroment or system property, or as an applet parameter, or in an application resource file
MMMM. I would very much appreciate some help.
Thank You
Greetings Marcel
PS: Do I really have to pack all the jars which gf-client is referencing into my jar?
OK
It works when I do the following in the modules directory of glassfish:
java -cp gf-client.jar;c:/users/marcel/desktop/backITClient.jar gui.MainController
BUT
If I move up one directory and do the following:
java -cp /modules/gf-client.jar;c:/users/marcel/desktop/backITClient.jar gui.MainController
I get the NoInitialContextException again
Moreover all the relative paths in the client don't work anymore (i18n xml files/ pictures) since it looks it up in the modules directory. ???
I know one should "do learn the trade first, then download an IDE", nevertheless I hope someone could give me a hint.
Thanks
Marcel
OK I solved It. I had to reinstall glassfish. It was in the program files directory, a folder java doesn't like.
java -cp c:/glassfishv3/glassfish/modules/gf-client.jar;backITClient.jar gui.MainController
Greetings
Marcel
精彩评论