amorfis
amorfis

Reputation: 15770

Server can not find class in .ear

I have some problems with my .ear file. The structure of the file is:

app.ear
|-xxx.jar
 -yyy.jar
 -zzz.jar
 -ektorp.jar
 -app-ejb.jar
 -app-web.war
  |-WEB-INF
    |-lib
      |-xxx.jar
      |-yyy.jar
      |-zzz.jar
      |-ektorp.jar

When I try to deploy my application, I get ClassNotFoundException, with class wihch is in ektorp.jar. This file is used by ejb module.

I also don't know why these jars are doubled? In ear and in war module are the same .jar files.

Ear is built by maven2.

Upvotes: 2

Views: 2755

Answers (1)

Pascal Thivent
Pascal Thivent

Reputation: 570545

When I try to deploy my application, I get ClassNotFoundException, with class which is in ektorp.jar. This file is used by ejb module.

Does the EJB-JAR reference ektorp.jar in the Class-Path: entry in the manifest (see Packaging EJB 3 Applications for more background on this)? The FAQ explains how you can configure the plugin to generate a Class-Path: entry in the manifest:

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-ejb-plugin</artifactId>
        <version>2.2.1</version>
        ...
        <configuration>
          <archive>
            <manifest>
              <addClasspath>true</addClasspath>
           </manifest>
         </archive>
       </configuration>
        ...
     </plugin>
   </plugins>
 </build>
  ...
</project>

Just in case, do you know that you can package EJBs in a .war with Java EE 6 (the difference is that all classes are loaded with the same classloader when using the .war packaging)? If you don't have strong modularization requirements, the .war packaging is simpler.

Upvotes: 2

Related Questions