GeeCON Prague 2014*
The moose likes EJB and other Java EE Technologies and the fly likes EJB classpath issues Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB classpath issues " Watch "EJB classpath issues " New topic
Author

EJB classpath issues

Duran Harris
Ranch Hand

Joined: Nov 09, 2008
Posts: 598

Hi all,

I was trying to compile some EJBs but it tells me :

UserBean.java
HelloUserBean.java:2: package javax.ejb does not exist
import javax.ejb.Stateless;
^
HelloUserBean.java:4: cannot find symbol
symbol: class HelloUser
public class HelloUserBean implements HelloUser {
^
HelloUserBean.java:3: cannot find symbol
symbol: class Stateless
@Stateless
^
3 errors


I have both JAVA_HOME ,J2EE_HOME and ANT_HOME set.
The following are residing in my path env variable:
{j2ee.home}\bin
{j2ee.home}\lib\ant\bin

The following are in my classpath:
{j2ee.home}\lib
{j2ee.home}\lib\ant\lib

I am using glassfish and have set the admin password for the password file correctly.I can login to the admin console,ue ant to deploy applications and can use asadmin from the command prompt.I only run into problems trying to compile the classes.....
Please advise!


===>SCJP 1.5(72%)<===
==>SCWCD1.5(76%)<===
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

I believe the javaee.jar isn't in your classpath.

Can you paste your ant script?


SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
Duran Harris
Ranch Hand

Joined: Nov 09, 2008
Posts: 598

Hi Freddy,

I have tried adding j2ee.jar AND/OR javaee.jar to the classpath..This didnt help.
I am not sure whether ant build scripts are necessary...I thought that the DDs and build scripts were optional ie.
I thought could just have a bunch of POJOs/POJIs with annotations,compile them,jar them and deploy/run the jar.....

If this is not the case does that mean I will need to learn how to use ant build scripts before I can compile/run my own ejbs???
I am now downloading Netbeans/glassfish/JEE bundle,hopefully this will help.
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

How did you compile your EJB? Using javac, ant, or maven? If you compile them using javac, can you please paste the command? If you use ant, please provide the ant script so that we can help?

From the compilation error, "package javax.ejb does not exist", it shows that the javax.ejb classes, which are in the javaee.jar isn't present in the classpath.
Duran Harris
Ranch Hand

Joined: Nov 09, 2008
Posts: 598

EDIT:Removed double post
Duran Harris
Ranch Hand

Joined: Nov 09, 2008
Posts: 598

javac -cp \Sun\SDK\lib\j2ee.jar CountBean.java
OR
javac -cp \Sun\SDK\lib\javaee.jar CountBean.java
OR
javac -cp \Sun\SDK\lib\j2ee.jar *.java(Thought maybe it would help compiling it all one shot )

And I have confirmed that j2ee.jar exists.Have downloaded the glassfish+javaEE bundle from Sun instead of the javaEE+glassfish+appServer bundle.Maybe this will help.Have given up on Netbeans though,I don't like the idea of it generating build scripts for everything considering that I can't write a build script myself.
Duran Harris
Ranch Hand

Joined: Nov 09, 2008
Posts: 598

Okay so now I've managed to get this stuff to compile..The next step is to stick the package structure in a jar isn't it?I created the jar but when I try to execute it,I get the error:

Failed to load Main-Class manifest attribute from mine.jar

Should my bean classes and interfaces go into a jar and then I run the client from the cmd with this jar on the classpath?Or should the client be included in the jar??
 
jQuery in Action, 2nd edition
 
subject: EJB classpath issues