我的Java應用程序需要org.objectweb.asm庫。我在pom中指定了'asm'依賴項。將圖書館與應用程序一起部署。應用程序仍會拋出異常NoClassDefFoundError:org/objectweb/asm/ClassVisitor。NoClassDefFoundError。如何設置依賴關係並部署一個Java應用程序?
java.lang.NoClassDefFoundError: org/objectweb/asm/ClassVisitor
at com.sun.jersey.api.core.PackagesResourceConfig.init(PackagesResourceConfig.java:112)
at com.sun.jersey.api.core.PackagesResourceConfig.<init>(PackagesResourceConfig.java:78)
... many more
我該如何解決這個問題?
詳情: 我正在使用Glassfish 2.1.1。該應用需要運動衫1.1.4,運動衫需要運動員3.1。我認爲1.1.4版本是2.1.1的GlassFish
要求如果我運行的Glassfish updatetool並在服務器上安裝澤西然後我的應用程序加載並沒有問題運行。我的客戶沒有在他們的服務器上安裝Jersey,他們不能使用updatetool。
Glassfish的2.1.1 updatetool安裝球衣1.1.4和ASM-3.1.jar在GlassFish中/ lib目錄下。 卸載運動衫時,updatetool也會刪除asm。
如果我包括球衣和ASM的依賴和部署我的war文件然後球衣和ASM罐子進入本地位置,例如的glassfish /域/域1 /應用/ J2EE模塊/ MYAPPNAME/WEB-INF/LIB/ASM-3.1.jar。
Glassfish的updatetool把ASM到lib文件夾:GlassFish的/ lib目錄下的應用程序啓動部署和正常工作。
這裏是我的Maven POM文件的依賴部分:
<dependencies>
<dependency>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-bundle</artifactId>
<version>1.1.4</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.jersey-test-framework</groupId>
<artifactId>jersey-test-framework-grizzly2</artifactId>
<version>1.17.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<version>1.0.0.Final</version>
<scope>provided</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
</dependencies>
由於某些原因POM文件的部分內容從最初的文章中丟失。這包括'asm'依賴。我再次將POM標記爲代碼並重新保存該帖子。 – dmitri