Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-22-2009, 08:17 AM
Member
 
Join Date: Nov 2009
Location: Antarctica
Posts: 2
Rep Power: 0
mirik is on a distinguished road
Question 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?
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 11-23-2009, 07:05 PM
Senior Member
 
Join Date: Aug 2009
Posts: 1,759
Rep Power: 2
r035198x is on a distinguished road
Default
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.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 11-24-2009, 05:04 PM
Member
 
Join Date: Nov 2009
Location: Antarctica
Posts: 2
Rep Power: 0
mirik is on a distinguished road
Default 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(); }
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
get client ip Ozmosis Networking 4 11-07-2009 05:12 PM
how to send a file from server to client and client saves the file? KoolCancer New To Java 3 07-29-2009 05:52 AM
client app santhu538 New To Java 1 02-28-2009 07:54 AM
Datagram Client and Server, client timer question saru88 Networking 1 10-05-2008 04:12 PM
Identify Client in Socket Client Server Application masadjie Networking 1 12-20-2007 10:18 AM


All times are GMT +2. The time now is 12:58 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org