Solved

My JAVA says that "java.ejb" package does not exist!

Posted on 2004-09-23
23
960 Views
Last Modified: 2013-11-24
Hi

I am trying to code Enterprise Java Beans. I have my classes coded, but they won't compile.

Here is the Java file...

//CalculatorEJB.java
import java.rmi.RemoteException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;

public class CalculatorEJB implements SessionBean
{
   public double dollarToRs(double dollars)
   {
       return dollars * 47.20;
   }

   public CalculatorEJB() {}
   public void ejbCreate() {}
   public void ejbRemove() {}
   public void ejbActivate() {}
   public void ejbPassivate() {}
   public void setSessionContext(SessionContext sc) {}

} // CalculatorEJB

I get the following error when trying to compile in command prompt:


Calculator.java:3: cannot access javax.ejb.EJBObject
bad class file: c:\sun\appserver\lib\j2ee.jar(javax/ejb/EJBObject.class)
class file has wrong version 48.0, should be 47.0
Please remove or make sure it appears in the correct subdirectory of the classpath.
import javax.ejb.EJBObject;

I get an error that says the javax.ejb package does not exist when I compile using Netbeans IDE 3.6

I have jdk1.3.1_02
J2EE 1.4 SDK

Environment Variables:
JAVA_HOME=c:\jdk1.3.1_02
J2EE_HOME=c:\Sun\AppServer
PATH=C:\jdk1.3.1_02\bin;C:\Sun\AppServer\bin
CLASSPATH=.;c:\jdk1.3.1_02\lib;c:\sun\appserver\lib\j2ee.jar;C:\Sun\AppServer\domains\domain1\lib\classes

I need to know ASAP how to fix it!

Thanks in advance
0
Comment
Question by:Sheldonh
  • 10
  • 6
  • 5
  • +2
23 Comments
 
LVL 35

Expert Comment

by:girionis
ID: 12130826
It seems to me that you are using a newer version of the j2ee.jar file. Can you use an older one and try again? What application server are you using?
0
 
LVL 1

Author Comment

by:Sheldonh
ID: 12130833
Where can I get an older version of j2ee.jar ?
0
 
LVL 35

Expert Comment

by:girionis
ID: 12130846
Have you download the j2sdk? Have you installed an application server? You might have two j2ee.jar files in your system. Can you make a search?
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 37

Expert Comment

by:zzynx
ID: 12130847
0
 
LVL 35

Expert Comment

by:girionis
ID: 12130854
> I have jdk1.3.1_02
> J2EE 1.4 SDK

Try to download J2EE 1.3 SDK and try again.
0
 
LVL 18

Expert Comment

by:armoghan
ID: 12130861
j2ee.jar may be corrupted..
Try reinstalling and running some sample project
0
 
LVL 35

Expert Comment

by:girionis
ID: 12130868
The solution might simply be that you have a jar file in your classpath that you do not need. Can you tell us how many j2ee.jar files you have? If you have more than one then try to replace each other, if not try to download an older version.
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12130876
Here's someone with the same problem: http://forum.java.sun.com/thread.jsp?thread=487767&forum=13&message=2288940
Maybe the short answers help...
0
 
LVL 35

Expert Comment

by:girionis
ID: 12130882
> CLASSPATH=.;c:\jdk1.3.1_02\lib;c:\sun\appserver\lib\j2ee.jar;C:\Sun\AppServer\domains\domain1\lib\classes

I know it shouldn't matter on Windows but can you also make sure that the classpath is case sensitive:

CLASSPATH=.;c:\jdk1.3.1_02\lib;c:\sun\AppServer\lib\j2ee.jar;C:\Sun\AppServer\domains\domain1\lib\classes
0
 
LVL 35

Expert Comment

by:girionis
ID: 12130891
CLASSPATH=.;c:\jdk1.3.1_02\lib;c:\Sun\AppServer\lib\j2ee.jar;C:\Sun\AppServer\domains\domain1\lib\class
0
 
LVL 1

Author Comment

by:Sheldonh
ID: 12130969
I only have one j2ee.jar -> c:\Sun\AppServer\lib\j2ee.jar

I have checked for case sensitivity on the classpath and it doesn't work.

I have tried the link from zzynx and no solution.

I have J2EE installed on more than one computer and they all give the same error. (same paths too)

Busy downloading J2EE 1.3...
0
 
LVL 35

Expert Comment

by:girionis
ID: 12130990
Try J2EE 1.3 and let us know.
0
 
LVL 1

Author Comment

by:Sheldonh
ID: 12131007
another 32 minutes for the download... (116MB)
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12131025
:)
0
 
LVL 35

Expert Comment

by:girionis
ID: 12131036
> another 32 minutes for the download... (116MB)

Are you also downloading the application server? You only need the j2ee classes.
0
 
LVL 35

Expert Comment

by:girionis
ID: 12131047
>  You only need the j2ee classes.

At least to compile it. You will indeed need an application server to run it.
0
 
LVL 1

Author Comment

by:Sheldonh
ID: 12131080
what is the link for the classes download...i saw it earlier but now I can't find it again
0
 
LVL 92

Expert Comment

by:objects
ID: 12131084
0
 
LVL 35

Expert Comment

by:girionis
ID: 12131101
http://java.sun.com/j2ee/sdk_1.3/ and then go down where it says "Download the Software for the Java 2 SDK, Enterprise Edition 1.3.1:"
0
 
LVL 1

Author Comment

by:Sheldonh
ID: 12236886
Ok

I have tried everything you guys suggested. Still doesn't solve my problem though. Using netbeans, I have got the .java files to compile, but Netbeans still doesn't recognise the EJB packages. Without using Netbeans, I won't be able to compile at all.
0
 
LVL 37

Accepted Solution

by:
zzynx earned 500 total points
ID: 12239370
>>Netbeans still doesn't recognise the EJB packages
Common info:
For netBeans to recognise a package, the corresponding jar file(s) should have been mounted.
(Right-click File System > Mount > archive files)
0
 
LVL 1

Author Comment

by:Sheldonh
ID: 12250660
Yup, that did the trick.

Thanks zzynx!
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12251729
You're welcome.
Thanks for accepting
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
session migration servlets 2 36
oracle 11g 23 80
jdbc error in jsp application 20 45
Desingning Refactoring existing code 2 24
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question