TimmyGT
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\Clien t8241\src\ java\clien t8241\Main .java:12: package javax.ejb does not exist
import javax.ejb.EJB;
C:\Java\JavaProjects\Clien t8241\src\ java\clien t8241\Main .java:21: cannot find symbol
symbol : class EJB
location: class client8241.Main
@EJB
Thanks for your help!
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\Clien
import javax.ejb.EJB;
C:\Java\JavaProjects\Clien
symbol : class EJB
location: class client8241.Main
@EJB
Thanks for your help!
When you run your Main class, you need to specify the jar containing the EJB interfaces in your classpath. Probably something like "j2ee.jar".
ASKER
I'm running this from the NetBeans 5.5 IDE with the following imports:
import javax.ejb.EJB;
import mbeans.NSBEA5Remote;
import javax.ejb.EJB;
import mbeans.NSBEA5Remote;
ASKER
When I run Verify Project I get:
Verifier output unparsable
C:\Java\JavaProjects\eA5\e A5-ejb\dis t\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
Verifier output unparsable
C:\Java\JavaProjects\eA5\e
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.
I've never used NetBeans, but somebody else might know if it is too IDE specific.
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
}
}
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:\pat h\to\ejb\e A5-ejb.jar ;.
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.
ASKER
Okay, I made the changes and my CLASSPATH is:
C:\Sun\AppServer\lib\j2ee. jar;C:\Sun \AppServer \lib\mail. jar;C:\Jav a\JavaProj ects\EAFri 1\EAFri1-e jb\dist\EA Fri1-ejb.j ar;.
The file name changed on the EJB to: EAFri1-ejb
I still get the error and when debugging get :
C:\Java\JavaProjects\Appli cationClie nt10\src\j ava\applic ationclien t10\Main.j ava:12: package javax.ejb does not exist
import javax.ejb.EJB;
C:\Java\JavaProjects\Appli cationClie nt10\src\j ava\applic ationclien t10\Main.j ava:21: cannot find symbol
symbol : class EJB
location: class applicationclient10.Main
@EJB
Thanks for your continued help!
C:\Sun\AppServer\lib\j2ee.
The file name changed on the EJB to: EAFri1-ejb
I still get the error and when debugging get :
C:\Java\JavaProjects\Appli
import javax.ejb.EJB;
C:\Java\JavaProjects\Appli
symbol : class EJB
location: class applicationclient10.Main
@EJB
Thanks for your continued help!
ASKER
Append previous post
CLASSPATH is:
C:\Sun\AppServer\lib\j2ee. jar;C:\Sun \AppServer \lib\mail. jar;C:\Jav a\JavaProj ects\EAFri 1\dist\EAF ri1-ejb.ja r;C:\Sun\A ppServer\l ib\javaee. jar.
CLASSPATH is:
C:\Sun\AppServer\lib\j2ee.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.