0

netbeans と maven を使用して小さな Web アプリケーションを開発しています。

プロジェクトは 3 つのモジュールで構成されています。

prychadmin (これはメインモジュールです)

トラベル

インターフェイス

後者の 2 つのモジュールは別の場所でも使用されるため、このように分割する必要があります。すべてを war ファイル (WEB-INF/lib に含まれるモジュール travel とインターフェイス) にパックし、glassfish にデプロイしようとします (netbeans を介して手動でデプロイしようとしました)、travel モジュールに含まれるクラスの 1 つで NoClassDefFoundError を取得します。

RuntimeException
java.lang.NoClassDefFoundError: chore/gry/prych/map/LocationImpl

解決策を数日間探していたところ、あるソースから MANIFEST.MF を変更するように言われたので、現在は次のようになっています。

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: user
Build-Jdk: 1.6.0_26
Class-Path: travel-1.0-SNAPSHOT.jar log4j-1.2.16.jar interfaces-1.0-SN
 APSHOT.jar

しかし、それは役に立ちませんでした。

Tomcat にもデプロイしようとしましたが、うまくいかなかったので、war ファイルの愚かな間違いに違いありません。

誰にもアイデアはありますか?

ここに私の prychadimn プロジェクト pom.xml があります

<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
    <artifactId>prych</artifactId>
    <groupId>chore.gry</groupId>
    <version>1.0-SNAPSHOT</version>
</parent>
<groupId>chore.gry.prych</groupId>
<artifactId>prychadmin</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>prychadmin Java EE 6 Webapp</name>
<url>http://maven.apache.org</url>
<repositories>
    <repository>
        <id>java.net2</id>
        <name>Repository hosting the jee6 artifacts</name>
        <url>http://download.java.net/maven/2</url>
    </repository>
    <repository>
        <id>apache</id>
        <name>Apache</name>
        <url>http://ftp.cica.es/mirrors/maven2/</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>chore.gry.prych</groupId>
        <artifactId>travel</artifactId>
        <version>1.0-SNAPSHOT</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-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.0.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.1-alpha-2</version>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
                <execution>
                    <phase>compile</phase>
                    <configuration>
                        <tasks>

                            <copy todir="src\main\webapp\chore\gry\prych\prychadmin\mapa">
                                <fileset dir="target\classes\chore\gry\prych\prychadmin\mapa"/>
                            </copy>


                        </tasks>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
    <finalName>prychadmin</finalName>
</build>
<profiles>
    <profile>
        <id>endorsed</id>
        <activation>
            <property>
                <name>sun.boot.class.path</name>
            </property>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.0.2</version>
                    <configuration>
                        <!-- javaee6 contains upgrades of APIs contained within the JDK itself.
                        As such these need to be placed on the bootclasspath, rather than classpath of the
                        compiler.
                        If you don't make use of these new updated API, you can delete the profile.
                        On non-SUN jdk, you will need to create a similar profile for your jdk, with the similar property as sun.boot.class.path in Sun's JDK.-->
                        <compilerArguments>
                            <bootclasspath>${settings.localRepository}/javax/javaee-endorsed-api/6.0/javaee-endorsed-api-6.0.jar${path.separator}${sun.boot.class.path}</bootclasspath>
                        </compilerArguments>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>javax</groupId>
                            <artifactId>javaee-endorsed-api</artifactId>
                            <version>6.0</version>
                        </dependency>
                    </dependencies>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>
</project>

私の環境:

ウィンドウズ7

グラスフィッシュ 3.1.2.2

ネットビーンズ 7.2

JDK1.6.0_26

Maven 3.0.3

EDIT1 ここに私のパッケージツリーがあります:

-   index.jsp
-
+---chore
-   L---gry
-       L---prych
-           L---prychadmin
-               L---mapa
-                       DBConnector.class
-                       Location.class
-                       ....
-                       PathsEditorPanel.class
-
+---css
-       prych.css
-
+---lib
-       travel-1.0-SNAPSHOT.jar
-
+---META-INF
-   -   context.xml
-   -   MANIFEST.MF
-   -
-   +---maven
-   -   L---chore.gry.prych
-   -       L---prychadmin
-   -               pom.properties
-   -               pom.xml
-   -
-   L---services
-           java.sql.Driver
-
+---org
-   L---postgresql
-       -   Driver$1.class
-       -   Driver$ConnectThread.class
-       -   ...
-               RecoveredXid.class
-
L---WEB-INF
    +---classes
    -   L---chore
    -       L---gry
    -           L---prych
    -               L---prychadmin
    -                   -   Starter.class
    -                   -
    -                   L---mapa
    -                           DBConnector.class
    -                           LocationAdmin.class
    -                           ...
    -                           PathsEditorPanel.class
    -
    L---lib
        interfaces-1.0-SNAPSHOT.jar
        log4j-1.2.16.jar
        travel-1.0-SNAPSHOT.jar    <-- this is the one that has LocationImpl.class

また、私が気付いた奇妙な点が 1 つあります。主な方向のフォルダー雑用には、メイン モジュールのクラスだけでなく、2 つのライブラリのうちの 2 つ目のクラス (実際にはインターフェイス) もあります。

4

2 に答える 2

0

マニフェスト ファイルを変更する必要はありません。エラー メッセージから、欠落しているクラスはメイン モジュールのクラスのようです。クラスが WEB-INF/classes に存在することを確認できますか?

于 2012-10-25T10:53:06.083 に答える
0

アプリケーションに依存する jar ファイルを 2 つのドメイン ext (domain1/lib/ext) ディレクトリに追加してみてください。

于 2012-10-25T10:46:03.227 に答える