0
我有一個JavaEE6應用具有以下結構:注入豆成過濾器進行包裝共享庫
app.ear
META-INF
application.xml
lib
commmon-server-lib.jar
webapp1.war
webapp2.war
services-ejb.jar
雙方的webapps在其MANIFEST.MF中的Class-Path條目的通用服務器,lib.jar (骨感的戰爭)。
的application.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
有一個網絡過濾器,應該有一些EJB和其他CDI管理注入豆。這個過濾器在兩個webapps的web.xml
中定義。
common-server-lib.jar
和戰爭的beans.xml
在適當的地方。
現在的問題是,當我嘗試部署此應用程序到GlassFish,我得到象這樣的錯誤:
Class [ Lcom/acme/UserService; ] not found. Error while loading
[ class com.acme.filter.MyFilter ]
UserService
服務位於服務-ejb.jar
所以我的問題是: 我究竟做錯了什麼...?在共享庫中定義Web組件(針對它的依賴關係使用注入)有什麼問題嗎?
編輯:
在JSR-315(Servlet的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.
我搬到共服務器庫。 jar到兩個webapps的WEB-INF/lib目錄,但我仍然有同樣的問題;/...