【发布时间】:2013-03-12 07:30:13
【问题描述】:
我有一个具有以下结构的 JavaEE6 应用程序:
app.ear
META-INF
application.xml
lib
commmon-server-lib.jar
webapp1.war
webapp2.war
services-ejb.jar
两个 webapp 在其 MANIFEST.MF(瘦战)的 Class-Path 条目中都有 common-server-lib.jar。
应用程序.xml:
<application>
<module>
<ejb>services-ejb.jar</ejb>
</module>
<module>
<web>
<web-uri>webapp1.war</web-uri>
<context-root>/webapp1</context-root>
</web>
</module>
<module>
<web>
<web-uri>webapp2.war</web-uri>
<context-root>/webapp2</context-root>
</web>
</module>
<library-directory>lib</library-directory>
</application>
在common-server-lib.jar 中有一个Web 过滤器,应该注入很少的EJB 和其他CDI 托管bean。此过滤器在两个 web 应用的 web.xml 中定义。
common-server-lib.jar 和战争的 beans.xml 在适当的位置。
现在的问题是,当我尝试将此应用程序部署到 Glassfish 时,我收到如下错误:
Class [ Lcom/acme/UserService; ] not found. Error while loading
[ class com.acme.filter.MyFilter ]
UserService服务位于services-ejb.jar
所以我的问题是:我做错了什么......?在共享库中定义 Web 组件(对其依赖项使用注入)有什么问题吗?
编辑:
在 JSR-315(Servlets 3.0 最终规范)的第 15.5 节中可以找到:
In a web application, classes using resource injection will have their annotations processed only if they are located in the WEB-INF/classes directory, or if they are packaged in a jar file located in WEB-INF/lib.
我已将 common-server-lib.jar 移至两个 webapps 的 WEB-INF/lib 目录,但我仍然遇到同样的问题;/...
【问题讨论】:
标签: java-ee-6 cdi servlet-filters ejb-3.1