0

I've just developed a sample Java EE 7 application. The code is as follows:

@Stateless
@LocalBean
public class Foo {

    @Inject
    private Boo boo;  // Internal resource

    @Asynchronous
    public void doFoo(Collection<Object> c) {
        boo.doSomething(c);
    }

}

With the aim to deploy the project as jar file, I'm using the following Maven configuration:

<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>sample</groupId>
    <artifactId>ejb-foo</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <dependencies>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>7.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <build>
        <finalName>ejb-foo</finalName>
    </build>
    <properties>
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>
    </properties>
</project>

Unfortunately, Maven returns me this warning:

Classpath entry org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER will not be exported or published. Runtime ClassNotFoundExceptions may result.   ejb-foo     P/ejb-foo   Classpath Dependency Validator Message

How can I fix this error?


Note:

The idea is to import that jar into another Java project and then to instance the Foo class as EJB:

import myjavaeeproject.Foo;

public OtherClass {

   @EJB
   private Foo foo;

   public void doMagic(List<String> list) {
        foo.doFoo(list);
   }

}

Update:

I've fixed the error as shown here.

When I deploy (as war) the target project (that implements OtherClass, annotated as WebServlet) on JBoss, I've an error:

POST_MODULE: JBAS018733: Failed to process phase POST_MODULE of deployment

It depends on the EJB injection.

What am I doing wrong?

Community
  • 1
  • 1
vdenotaris
  • 13,297
  • 26
  • 81
  • 132
  • Did you try [this](http://stackoverflow.com/questions/11577380/how-to-set-eclipse-to-ignore-the-classpath-dependency-validator-message-warnin) or [this?](http://ssv0811.blogspot.com/2013/01/eclipse-helios-classpath-dependency.html) – Maleen Abewardana May 26 '14 at 08:55
  • Ok, this fixs the warning. But is the code correct? Why returns it that warn? – vdenotaris May 26 '14 at 09:10

2 Answers2

0

As per my examples in comment, it is because eclise think "the library exists at the server and it is not right to export this with your projects"

I don't have much idea about your code, but seems to be ok.

Maleen Abewardana
  • 13,600
  • 4
  • 36
  • 39
0

If this is a J2EE application, I would expect the target to be a war or ear. I don't think that a J2EE container will understand a jar deployment.

kiwiron
  • 1,677
  • 11
  • 17