Cannot import javax.ejb.* packages

Sebi picture Sebi · Dec 31, 2013 · Viewed 52.3k times · Source

I am having trouble in building an EJB session bean.

The following packages cannot be found:

import javax.ejb.LocalBean;
import javax.ejb.Stateful;
import javax.ejb.TransactionManagement; 
import javax.ejb.TransactionManagementType;

Some solutions implied adding the libraries j2ee.jar and javaee.jar to the java build path.

I am using jdk-7u75-windows-x64 and java_ee_sdk-7-windows-ml and cannot find any of these libraries at the given location($JAVA_HOME\lib). I am using eclipse(kepler) on a Windows 7 x64 machine

Answer

Sebi picture Sebi · Dec 31, 2013

javaee.jar ships with neither eclipse nor java(jdk). The file must be manually downloaded and added to the project build path. The java ee 7 api can be found here. Alternatively, a maven dependency can be used:

<dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-api</artifactId>
    <version>7.0</version>
</dependency>