Results 1 to 3 of 3
  1. #1
    mirik is offline Member
    Join Date
    Nov 2009
    Location
    Antarctica
    Posts
    2
    Rep Power
    0

    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?

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    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.

  3. #3
    mirik is offline Member
    Join Date
    Nov 2009
    Location
    Antarctica
    Posts
    2
    Rep Power
    0

    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(); }

Similar Threads

  1. get client ip
    By Ozmosis in forum Networking
    Replies: 4
    Last Post: 11-07-2009, 04:12 PM
  2. Replies: 3
    Last Post: 07-29-2009, 04:52 AM
  3. client app
    By santhu538 in forum New To Java
    Replies: 1
    Last Post: 02-28-2009, 06:54 AM
  4. Replies: 1
    Last Post: 10-05-2008, 03:12 PM
  5. Identify Client in Socket Client Server Application
    By masadjie in forum Networking
    Replies: 1
    Last Post: 12-20-2007, 09:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •