• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 972
  • Last Modified:

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

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
Sheldonh
Asked:
Sheldonh
  • 10
  • 6
  • 5
  • +2
1 Solution
 
girionisCommented:
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
 
SheldonhAuthor Commented:
Where can I get an older version of j2ee.jar ?
0
 
girionisCommented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
zzynxSoftware engineerCommented:
0
 
girionisCommented:
> I have jdk1.3.1_02
> J2EE 1.4 SDK

Try to download J2EE 1.3 SDK and try again.
0
 
armoghanCommented:
j2ee.jar may be corrupted..
Try reinstalling and running some sample project
0
 
girionisCommented:
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
 
zzynxSoftware engineerCommented:
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
 
girionisCommented:
> 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
 
girionisCommented:
CLASSPATH=.;c:\jdk1.3.1_02\lib;c:\Sun\AppServer\lib\j2ee.jar;C:\Sun\AppServer\domains\domain1\lib\class
0
 
SheldonhAuthor Commented:
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
 
girionisCommented:
Try J2EE 1.3 and let us know.
0
 
SheldonhAuthor Commented:
another 32 minutes for the download... (116MB)
0
 
zzynxSoftware engineerCommented:
:)
0
 
girionisCommented:
> another 32 minutes for the download... (116MB)

Are you also downloading the application server? You only need the j2ee classes.
0
 
girionisCommented:
>  You only need the j2ee classes.

At least to compile it. You will indeed need an application server to run it.
0
 
SheldonhAuthor Commented:
what is the link for the classes download...i saw it earlier but now I can't find it again
0
 
objectsCommented:
0
 
girionisCommented:
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
 
SheldonhAuthor Commented:
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
 
zzynxSoftware engineerCommented:
>>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
 
SheldonhAuthor Commented:
Yup, that did the trick.

Thanks zzynx!
0
 
zzynxSoftware engineerCommented:
You're welcome.
Thanks for accepting
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 10
  • 6
  • 5
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now