Cro*_*zin 3 java spring glassfish dependency-management aopalliance
我正在使用Spring MVC和Hibernate开发一个简单的培训应用程序.我正在使用Maven作为构建工具.所有依赖项(spring,hibernate,aopalliance,junit等)都使用Maven的pom.xml文件解析.
$ mvn war:war glassfish:deploy
作品absolutley罚款,项目正在部署到GlassFish服务器 - 所有*.jar
文件都被复制(包括com.springsource.org.aopalliance-1.0.0.jar
).
我已经制作了一个简单的servlet来测试类路径中是否存在aopalliance:
protected void doGet(...) throws ... {
response.getWriter().println(org.aopalliance.intercept.MethodInterceptor.class.getCanonicalName());
}
Run Code Online (Sandbox Code Playgroud)
它存在.上面的代码org.aopalliance.intercept.MethodInterceptor
按预期显示.
但是,如果我将servlet更改为类似的东西:
protected void doGet(...) throws ... {
response.getWriter().println(org.springframework.transaction.interceptor.TransactionInterceptor.class.getCanonicalName());
}
Run Code Online (Sandbox Code Playgroud)
它引发了一个异常:
java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor
Run Code Online (Sandbox Code Playgroud)
TransactionInterceptor
使用aopalliance接口,但我不明白为什么它找不到它们,而我的servlet可以.我相信它可能与类加载器有某种关系,但我很害怕我不知道如何修复它.
一些细节:
pom.xml
档案:http://pastebin.com/430iPgRsHelloServlet
课程:http://pastebin.com/YVfzz4i8我还spring.osgi.core/io
根据@Ravi的建议添加了依赖项:
<dependency>
<groupId>org.springframework.osgi</groupId>
<artifactId>org.springframework.osgi.core</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>org.springframework.osgi</groupId>
<artifactId>org.springframework.osgi.io</artifactId>
<version>1.2.1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
但它没有解决问题.
但是,我尝试在VMware vFabric tc Server上运行相同的应用程序,该服务器随SpringSource Tool Suite一起提供,一切正常.这似乎是特定于GlassFish的问题.
我正在使用GlassFish Server Open Source Edition 3.1.1.
另一个奇怪的事情是:如果我重新部署应用程序(在Eclipse中使用"Publish"),servlet将抛出:
java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor
Run Code Online (Sandbox Code Playgroud)
但刷新后(在浏览器中)我得到:
java.lang.NoClassDefFoundError: org/springframework/transaction/interceptor/TransactionInterceptor
Run Code Online (Sandbox Code Playgroud)
进一步刷新不会改变任何东西.
归档时间: |
|
查看次数: |
14304 次 |
最近记录: |