Results 1 to 3 of 3
Thread: Cannot run EE client
- 11-22-2009, 07:17 AM #1
Member
- Join Date
- Nov 2009
- Location
- Antarctica
- Posts
- 2
- Rep Power
- 0
Cannot run EE client
Hi all.
I created a simple stateless EE EJB3 and its client.
I succeed the execute the client with appclient:
C:\j2ee-projects>appclient -client testclient.jar
But I have a problem when running it with jar name:
C:\j2ee-projects>java -jar testclient.jar
Exception in thread "main" java.lang.NullPointerException
at testclient.main(testclient.java:9)
And also when running it with class name:
C:\j2ee-projects>java -cp chapter1-ejb.jar;testbeans.jar testclient
Exception in thread "main" java.lang.NoClassDefFoundError: testclient
Caused by: java.lang.ClassNotFoundException: testclient
at java.net.URLClassLoader$1.run(URLClassLoader.java: 200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.j ava:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 07)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 52)
at java.lang.ClassLoader.loadClassInternal(ClassLoade r.java:320)
Could not find the main class: testclient. Program will exit.
This is the manifest file inside testclient.jar:
Manifest-Version: 1.0
Class-Path: chapter1-ejb.jar testbeans.jar
Main-Class: testclient
Could someone tell what is the problem there?
- 11-23-2009, 06:05 PM #2
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
When you run it as a jar file, there is something required at line 9 of testclient which you are not providing and causing the null pointer.
When you run it as a class, add the folder containing the testclient.class to the classpath as well. If it is the current directory then add dot, ie .
P.S Better put your classes in packages and name then according to Java naming conventions.
- 11-24-2009, 04:04 PM #3
Member
- Join Date
- Nov 2009
- Location
- Antarctica
- Posts
- 2
- Rep Power
- 0
Cannot run EE client
Thanks for response r035198x.
Here is the correct answer:
The @EJB annotation can be used only inside another EE container or by appclient.
In order to call it from POJO utility class you should write:
try{
Context ctx = new InitialContext();
testint cls = (testint)ctx.lookup("testint");
}catch(Exception ex) { ex.printStackTrace(); }
Similar Threads
-
get client ip
By Ozmosis in forum NetworkingReplies: 4Last Post: 11-07-2009, 04:12 PM -
how to send a file from server to client and client saves the file?
By KoolCancer in forum New To JavaReplies: 3Last Post: 07-29-2009, 04:52 AM -
client app
By santhu538 in forum New To JavaReplies: 1Last Post: 02-28-2009, 06:54 AM -
Datagram Client and Server, client timer question
By saru88 in forum NetworkingReplies: 1Last Post: 10-05-2008, 03:12 PM -
Identify Client in Socket Client Server Application
By masadjie in forum NetworkingReplies: 1Last Post: 12-20-2007, 09:18 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks