1
votes

I'm trying to deploy an EAR file to an application server. The project builds using Maven 3 in NetBeans 7.

When I try to deploy Glassfish and Websphere CE tell me certain classes cannot be found even though they are packaged in the EAR file. The app servers can see the other classes in the package just not all of them.

What could the problem be? I've been trying to solve this all day. I looked at the Maven POM files and I've been reading about deployment descriptors but I don't seem to be making in progress.

The error I get is SEVERE: Class [className] not found. Error while loading [className]

Here is the main pom file for the project:

<modelVersion>4.0.0</modelVersion>
<parent>
    <artifactId>SeaMarNetting</artifactId>
    <groupId>com.manageinc.seamar</groupId>
    <version>1.0RC1</version>
</parent>
<groupId>${project.parent.groupId}</groupId>
<artifactId>SeaMarNetting-ear</artifactId>
<packaging>ear</packaging>
<version>${project.parent.version}</version>
<name>SeaMarNetting-ear JEE5 Assembly</name>
<url>http://maven.apache.org</url>
<dependencies>
    <dependency>
        <groupId>${project.parent.groupId}</groupId>
        <artifactId>SeaMarNetting-project-deps</artifactId>
        <version>${project.parent.version}</version>
        <type>pom</type>
    </dependency>
    <dependency>
        <groupId>${project.parent.groupId}</groupId>
        <artifactId>SeaMarNetting-ejb</artifactId>
        <version>${project.parent.version}</version>
        <type>ejb</type>
    </dependency>
    <dependency>
        <groupId>${project.parent.groupId}</groupId>
        <artifactId>SeaMarNetting-jpa</artifactId>
        <version>${project.parent.version}</version>            
    </dependency>
    <dependency>
        <groupId>${project.parent.groupId}</groupId>
        <artifactId>SeaMarNetting-web</artifactId>
        <version>${project.parent.version}</version>
        <type>war</type>
    </dependency>
    <dependency>
        <groupId>com.manageinc.seamar</groupId>
        <artifactId>SeaMarNetting-web</artifactId>
        <version>1.0RC1</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.0.2</version>
            <configuration>
                <source>${source.version}</source>
                <target>${compile.version}</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-ear-plugin</artifactId>
            <version>2.4.2</version>
            <configuration>
                <version>5</version>
                <displayName>SeaMarNetting</displayName>
                <modules>                        
                    <jarModule>
                        <groupId>${project.parent.groupId}</groupId>
                        <artifactId>SeaMarNetting-jpa</artifactId>
                    </jarModule>
                    <ejbModule>
                        <groupId>${project.parent.groupId}</groupId>
                        <artifactId>SeaMarNetting-ejb</artifactId>
                    </ejbModule>
                    <webModule>
                        <groupId>${project.parent.groupId}</groupId>
                        <artifactId>SeaMarNetting-web</artifactId>
                        <contextRoot>/nets</contextRoot>
                    </webModule>
                </modules>
            </configuration>
        </plugin>
    </plugins>
</build>

I tried changing the scope as recommended but I get the same error messages. I just started using Maven and I'm sure it's something simple I'm unaware of.

Thanks.

1

1 Answers

0
votes

Without being able to look at your POM file, my best guess is that you're not defining your dependencies correctly. Apache's POM reference at: http://maven.apache.org/pom.html#The_Basics shows:

<dependencies>
<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>4.0</version>
  <type>jar</type>
  <scope>test</scope>
  <optional>true</optional>
</dependency>
...

I think you need to focus on the 'scope' attribute, where you can list it as either 'provided' or 'system'. That way maven won't look for your jars in its repository. Here are the possibilities w/ descriptions:

scope: This element refers to the classpath of the task at hand (compiling and runtime, testing, >etc.) as well as how to limit the transitivity of a dependency. There are five scopes >available: compile, provided, runtime, test, system.

compile - this is the default scope, used if none is specified. Compile dependencies are >available in all classpaths. Furthermore, those dependencies are propagated to dependent >projects.

provided - this is much like compile, but indicates you expect the JDK or a container to >provide it at runtime. It is only available on the compilation and test classpath, and is >not transitive.

runtime - this scope indicates that the dependency is not required for compilation, but is >for execution. It is in the runtime and test classpaths, but not the compile classpath.

test - this scope indicates that the dependency is not required for normal use of the >application, and is only available for the test compilation and execution phases.

system - this scope is similar to provided except that you have to provide the JAR which >contains it explicitly. The artifact is always available and is not looked up in a >repository.

It's also important to remember to include a groupId for each dependency that corresponds with the groupId of a repository. I've found that even if my files are saved locally, they still need a groupId - even if the scope is 'provided.'