florin flo florin flo - 7 months ago 34
Java Question

Maven compiling javax.ejb does not exists

I created a maven project in eclipse and when I try to run in the project directory mvn clean install it gives this errors:

[INFO] Compiling 3 source files to C:\Users\Florin\Documents\Facultate\Master\TM
IS\Anul1\Sem2\ORM\Teme\Lab1_5\shop-interfaces\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/Florin/Documents/Facultate/Master/TMIS/Anul1/Sem2/ORM/Teme/Lab
1_5/shop-interfaces/src/main/java/ro/unitbv/IShoppingCart.java:[5,17] package ja
vax.ejb does not exist
[ERROR] /C:/Users/Florin/Documents/Facultate/Master/TMIS/Anul1/Sem2/ORM/Teme/Lab
1_5/shop-interfaces/src/main/java/ro/unitbv/IShoppingCart.java:[7,2] cannot find
symbol
symbol: class Remote
[ERROR] /C:/Users/Florin/Documents/Facultate/Master/TMIS/Anul1/Sem2/ORM/Teme/Lab
1_5/shop-interfaces/src/main/java/ro/unitbv/ProductDao.java:[6,17] package javax
.ejb does not exist

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.
1:compile (default-compile) on project shop-interfaces: Compilation failure: Com
pilation failure:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.
1:compile (default-compile) on project shop-interfaces: Compilation failure: Com
pilation failure:
[ERROR] /C:/Users/Florin/Documents/Facultate/Master/TMIS/Anul1/Sem2/ORM/Teme/Lab
1_5/shop-interfaces/src/main/java/ro/unitbv/IShoppingCart.java:[5,17] package ja
vax.ejb does not exist
...


I checked if the package javax.ejb is downloaded, and it exists in the .m2 folder.

Edit:
My pom file is:

<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ro.unitbv</groupId>
<artifactId>shop-interfaces</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>shop-interfaces</name>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>povided</scope>
</dependency>
</dependencies>
</project>

Answer

Depending on what you really need you have to define the dependency for javax.ejb which is not defined in javaee-api.

You have to give for example:

<dependency>
    <groupId>javax.ejb</groupId>
    <artifactId>javax.ejb-api</artifactId>
    <version>3.2</version>
    <scope>provided</scope>
</dependency>