Solved

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

Posted on 2004-09-23
23
952 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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to implement Singleton Design Pattern in Java.

708 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now