NoClassDefFoundError:与Glassfish的文件打包有关?

时间:2012-05-23 19:02:52

标签: java java-ee glassfish ejb

我有这个网络服务:


    /**
     * Web service operation
     */
    @WebMethod(operationName = "executeCleanAndValidateExtractedDate")
    public boolean executeCleanAndValidateExtractedDate()
    {
        try
        {
            CleanAndValidateExtractedData cav = new CleanAndValidateExtractedData();
            Transformation transformation = new DefaultTransformation();
            Step s1 = transformation.addStep(cav);          
            return transformation.execute();
        }
        catch (RuntimeException ex)
        {
            Logger.getLogger(ExecuteKeymark.class.getName()).log(Level.SEVERE, null, ex);
            return false;
        }
        catch(Exception ex)
        {
            Logger.getLogger(ExecuteKeymark.class.getName()).log(Level.SEVERE, null, ex);
            return false;
        }
    }

当我尝试执行它时,我得到一个例外:

javax.ejb.EJBException
    at com.sun.ejb.containers.BaseContainer.processSystemException(BaseContainer.java:5193)
    at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:5091)
    at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4879)
...
Caused by: java.lang.NoClassDefFoundError: com/medallion/etl/impl/AbstractStepSupport

我很困惑为什么它能找到那个班级。它在运行时可用,但不再可用。我需要做一些特殊的事情来部署它,以便它可以访问Glassfish中的类吗?

编辑:附加的POM文件

<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>com.dv</groupId>
<artifactId>WS_3</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>ejb</packaging>

<name>WS_3</name>

<properties>
    <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
    <dependency>
        <groupId>com.medallion</groupId>
        <artifactId>keymark.filemonitorEJB</artifactId>
        <version>1.0-ALPHA</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>com.medallion</groupId>
        <artifactId>etl</artifactId>
        <version>1.0-ALPHA</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>6.0</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
                <compilerArguments>
                    <endorseddirs>${endorsed.dir}</endorseddirs>
                </compilerArguments>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-ejb-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <ejbVersion>3.1</ejbVersion>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.1</version>
            <executions>
                <execution>
                    <phase>validate</phase>
                    <goals>
                        <goal>copy</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${endorsed.dir}</outputDirectory>
                        <silent>true</silent>
                        <artifactItems>
                            <artifactItem>
                                <groupId>javax</groupId>
                                <artifactId>javaee-endorsed-api</artifactId>
                                <version>6.0</version>
                                <type>jar</type>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
</project>

1 个答案:

答案 0 :(得分:0)

确保将所需的jar文件捆绑在war / ear文件中,以便它们在运行时可用,而不仅仅是在编译时。