Link to home
Start Free TrialLog in
Avatar of TimmyGT
TimmyGTFlag for United States of America

asked on

EJB project error

Windows 2000XP pro
NetBeans 5.5 beta 2
Sun Application Server

CLASSPATH value: C:\Sun\AppServer\lib;.

I created an Enterprise Application with EJB. I built it and deployed it to my local Sun App Server. I verified the deployment on the Admin page. This beans accepts a string and returns "Hello " + the string.

I created a new "Enterprise Application Client" with a "Main" class. I used the "enterprise resources" -> "Call Enterprise Bean" to reference my EJB. The IDE referenced the bean and I was able to call my one method in the EJB.

All of the above comiled without error.
When I run the Main class I get the errors:


C:\Java\JavaProjects\Client8241\src\java\client8241\Main.java:12: package javax.ejb does not exist
import javax.ejb.EJB;

C:\Java\JavaProjects\Client8241\src\java\client8241\Main.java:21: cannot find symbol
symbol  : class EJB
location: class client8241.Main
    @EJB

Thanks for your help!
Avatar of shinobun
shinobun

When you run your Main class, you need to specify the jar containing the EJB interfaces in your classpath.  Probably something like "j2ee.jar".
Avatar of TimmyGT

ASKER

I'm running this from the NetBeans 5.5 IDE with the following imports:

import javax.ejb.EJB;
import mbeans.NSBEA5Remote;
Avatar of TimmyGT

ASKER

When I run Verify Project I get:

Verifier output unparsable
C:\Java\JavaProjects\eA5\eA5-ejb\dist\eA5-ejb.jar.xml (The system cannot find the file specified)


Looking in the path above I find: eA5-ejb.jar     but not eA5-ejb.jar.xml
Actually, looking back at your post, the error message looks like compile error messages.  How are you running your Main class?  Do you configure a command line or something?

I've never used NetBeans, but somebody else might know if it is too IDE specific.
Avatar of TimmyGT

ASKER

package ac5;

import javax.ejb.EJB;
import mbeans.NSBEA5Remote;

/**
 *
 * @author bob.beasley
 */
public class Main {

    @EJB
    private static NSBEA5Remote nSBEA5Bean;
   
    public void getit(){
        String answer = "mary";
        answer = nSBEA5Bean.sayHello("Fred");
        System.out.println(answer);
       
    }
    /** Creates a new instance of Main */
    public Main() {
    }
   
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Main m = new Main();
        m.getit();
        // TODO code application logic here
    }
   
}
OK, so that's your Main class.  You might get a NullPointerException when you run it, but first thing's first.

I missed the CLASSPATH entry in your initial post (oops!).  This is what we need to fix.

CLASSPATH value: C:\Sun\AppServer\lib;.

Let's add your eA5-ejb.jar and the jars in C:\Sun\AppServer\lib here.  For jar files, you need to specify each jar directly, because setting a folder will not make java load the jars contained in them.

So, if there were a j2ee.jar and a mail.jar, you would set your CLASSPATH like this:
C:\Sun\AppServer\lib\j2ee.jar;C:\Sun\AppServer\lib\mail.jar;C:\path\to\ejb\eA5-ejb.jar;.
Avatar of TimmyGT

ASKER

Okay, I made the changes and my CLASSPATH is:
C:\Sun\AppServer\lib\j2ee.jar;C:\Sun\AppServer\lib\mail.jar;C:\Java\JavaProjects\EAFri1\EAFri1-ejb\dist\EAFri1-ejb.jar;.
The file name changed on the EJB to: EAFri1-ejb

I still get the error and when debugging get :

C:\Java\JavaProjects\ApplicationClient10\src\java\applicationclient10\Main.java:12: package javax.ejb does not exist
import javax.ejb.EJB;
C:\Java\JavaProjects\ApplicationClient10\src\java\applicationclient10\Main.java:21: cannot find symbol
symbol  : class EJB
location: class applicationclient10.Main
    @EJB

Thanks for your continued help!
Avatar of TimmyGT

ASKER

Append previous post

CLASSPATH is:
C:\Sun\AppServer\lib\j2ee.jar;C:\Sun\AppServer\lib\mail.jar;C:\Java\JavaProjects\EAFri1\dist\EAFri1-ejb.jar;C:\Sun\AppServer\lib\javaee.jar.
ASKER CERTIFIED SOLUTION
Avatar of shinobun
shinobun

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial