views:

692

answers:

1

Hello again :)

I am facing another problem in my little test-webapp. I have an EJB module (created via maven-pom) that basically wraps the data-access, so all it does is some DAOs implemented as Stateless-SessionBeans. My domain-model (simple POJOs with JPA2 annotations) is located in another, simple java, project that will be packaged as jar-file.

When I create the enterprise-archive, maven only puts the webapp and the ejb-module into the application.xml and even when I change this manually the ejb-module cannot find the classes from the domain-module at deployment time.

I read something about that an ejb has to have all its dependent jars within its own archive but I cant believe that since this domain-module is used by other projects as well.

How would I package this (or set it up in maven) so my ejb can load classes from an external jar?

thanks

+1  A: 

If I remember well, simply generate a manifest with a Class-Path entry in your EJB-JAR:

<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-ejb-plugin</artifactId>
    <configuration>
      <ejbVersion>3.0</ejbVersion>
      <archive>
        <manifest>
          <addClasspath>true</addClasspath>
        </manifest>
      </archive>
    </configuration>
  </plugin>
  ...
</plugins>

And add your external jars to the EAR. To do so, declare them as jarModule in the Maven EAR plugin configuration. See modules configuration.

Pascal Thivent
Thanks, but now I am getting the next error that is related to this (the ClassNotFoundException is gone): Unable to load EJB module. DeploymentContext does not contain any EJB Check archive to ensure correct packaging.
lostiniceland
Could it be the same problem as here: https://glassfish.dev.java.net/issues/show_bug.cgi?id=10592? Does your `web.xml` reference 2.5 schema?
Pascal Thivent
Yes, that was it. Getting another error now, because my web-xml seems not valid any more but I got passed the described point. Thanks a lot.
lostiniceland