1

我需要创建查询构建器。我想在 ejb 网站上创建它。为此,我需要使用 org.primefaces.model.SortOrder。我在 ejb POM 中添加了对 primefaces 的依赖。之后我得到了 “java.lang.NoClassDefFoundError:org/primefaces/model/SortOrder”。这种依赖在战争中运行良好。有任何想法吗?

Pom WAR 构建部分

<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>
        </configuration>
    </plugin>

</plugins>
<finalName>JSF</finalName> 
</build>



EJB 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>test.com</groupId>
    <artifactId>EJB</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>ejb</packaging>

    <name>EJB</name>

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

    <dependencies>
My dependencies with primefaces
</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>

    <archive>
        <manifestEntries>
            <Dependencies>org.slf4j</Dependencies>
        </manifestEntries>
    </archive>

</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>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings 
    only. It has no influence on the Maven build itself. -->
<plugin>
    <groupId>org.eclipse.m2e</groupId>
    <artifactId>lifecycle-mapping</artifactId>
    <version>1.0.0</version>
    <configuration>
        <lifecycleMappingMetadata>
            <pluginExecutions>
                <pluginExecution>
                    <pluginExecutionFilter>
                        <groupId>
                            org.apache.maven.plugins
                        </groupId>
                        <artifactId>
                            maven-dependency-plugin
                        </artifactId>
                        <versionRange>
                            [2.1,)
                        </versionRange>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                    </pluginExecutionFilter>
                    <action>
                        <ignore></ignore>
                    </action>
                </pluginExecution>
            </pluginExecutions>
        </lifecycleMappingMetadata>
    </configuration>
</plugin>
</plugins>
</pluginManagement>
</build>

</project>


EAR is not a maven projekt


  <display-name>EAR</display-name>
  <module>
    <web>
      <web-uri>JSF.war</web-uri>
      <context-root>JSF</context-root>
    </web>
  </module>
  <module>
    <ejb>EJB.jar</ejb>
  </module>
</application>
4

1 回答 1

2

如果您需要同时使用 ejb 和 war 的应用程序,那么您必须创建一个包含您的库的 ear 包。如果您不想创建第三个 pom(从您的两个孩子创建 ear),那么您可以将此库移动到服务器。

于 2013-04-04T13:36:48.397 回答