在一个EAR中部署多个依赖的CDI罐 [英] Deployment of multiple, depended CDI jars in one EAR

查看:115
本文介绍了在一个EAR中部署多个依赖的CDI罐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,关于如何部署多个jar包含CDi实现与webapp。



这是我的Jar结构

  -------- ---------- ------------ 
| WAR | < - | API Jar | < - | Data Jar |
-------- ---------- ------------
^
|
--------------
|普通罐|还有更多的实现
--------------

WAR本身是使用在API Jar中定义的类的webapp。 API jar只包含接口,注释,非逻辑类,限定符等...



API的实现存储在不同的JAR中,按主题分割。所以所有数据访问/操作数据,安全性,日志记录,常见等方面的实现。此实现具有对API Jar和可能的库的依赖。所有包都通过事件沟通。



我们在每个实现和webapp中使用CDI。完整的配置仅在WAR中。



我想在一个EAR中部署所有内容。所以这是我使用的文件结构:

  EAR 
- META-INF / application.xml
- api.jar
- api类,没有beans.xml这里
- common.jar
- 普通项目类的api实现
- META-INF / beans.xml
- data.jar
- 数据类的api实现
- META-INF / beans.xml
- logging.jar
- 记录类的api实现
- META-INF / beans.xml
- webapp.war
- classes
- (使用api的项目类)
- META-INF
- 服务
- persistence.xml
- WEB-INF / beans.xml
- beans.xml
- web.xml

我的application.xml看起来像这样:

 <应用程序xmlns =http://java.sun.com/xml/ns/javaeexmlns:xsi =http://www.w3.org/2001/XMLSchema-instancexsi:schemaLocation =http:// java .sun.com / xml / ns / javaee http://java.sun.com/xm l / ns / javaee / application_6.xsdversion =6> 
< display-name> test-ear< / display-name>
< module>
< java> api-1.0.0.jar< / java>
< / module>
< module>
< java> common-package-1.0.0.jar< / java>
< / module>
< module>
< java> data-package-1.0.0.jar< / java>
< / module>
< module>
< java> logging-package-1.0.0.jar< / java>
< / module>
< module>
< web>
< web-uri> test-war-1.0.0.war< / web-uri>
< context-root> / war< / context-root>
< / web>
< / module>
< / application>

我的问题是现在,这根本不工作。 CDI容器抱怨丢失一些bean。我搜索了google,并发现包含一个beans.xml mus的jar被部署为ejbModule,但在这里我需要为所有内容创建一个ejb.jar。另一个结果说,我只需要在WEB-INF / lib中的WAR文件中添加所有依赖关系。同样的抱怨在这里



我不能得到这个运行,并尝试在这里请求帮助。



作为服务器我想使用websphere也许是tomee)。



编辑:Maven用于将所有文件合并在一起。



非常感谢,如果有人可以帮助我:)

解决方案

你尝试在战争清单中引用你的罐子吗?



类似于类路径:api.jar data.jar logging.jar common.jar


i have a question about how to deploy multiple jars which contains CDi implementations together with a webapp.

This is my Jar Structure

--------     ----------      ------------
| WAR  | <-- | API Jar | <-- | Data Jar |
--------     ----------      ------------ 
                  ^
                  |
           --------------  
           | Common Jar |    And many more implementations
           --------------                  

The WAR itself is the webapp which uses classes which are defines in the API Jar. The API jar only contains Interfaces, Annotations, non-logic classes, Qualifiers etc...

The implementation for the API is stored in different JARs, split by thematic. So all Data accessing/manipulating implementations in Data, security, logging, common and so on. This Implementations have the dependency to the API Jar and maybe Libraries. All packages communicates trough events.

We use CDI in every implementation and in the webapp. The complete configuration is only in the WAR.

I want to deploy everything in one EAR. So this is the file structure i use:

EAR
  - META-INF/application.xml
  - api.jar
    - api classes, no beans.xml here
  - common.jar
    - api implementation for common project classes
    - META-INF/beans.xml
  - data.jar
    - api implementation for data classes
    - META-INF/beans.xml
  - logging.jar
    - api implementation for logging classes
    - META-INF/beans.xml
  - webapp.war
    - classes 
      - ( project classes which uses the api)
      - META-INF
        - services
        - persistence.xml
    - WEB-INF/beans.xml
      - beans.xml
      - web.xml

My application.xml looks something like this:

<application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd" version="6">
  <display-name>test-ear</display-name>
  <module>
    <java>api-1.0.0.jar</java>
  </module>
  <module>
    <java>common-package-1.0.0.jar</java>
  </module>
  <module>
    <java>data-package-1.0.0.jar</java>
  </module>
  <module>
    <java>logging-package-1.0.0.jar</java>
  </module>
  <module>
    <web>
      <web-uri>test-war-1.0.0.war</web-uri>
      <context-root>/war</context-root>
    </web>
  </module>
</application>

My problem is now, that this is not working at all. The CDI Container is complaining about missing some beans. I searched google about that, and found that the jars which contains a beans.xml mus be deployed as ejbModule, but here i need to create an ejb.jar for everything. An other result said i just need to add all dependencies to the WAR file in WEB-INF/lib. Same complaints here.

I cant get this running and try to request help here.

As server i want to use websphere (and maybe tomee).

Edit: Maven is uses to assemble all files together.

Thanks a lot, if anyone can help me out :)

解决方案

Did you try to reference your jars in the war manifest ?

Something like Class-Path: api.jar data.jar logging.jar common.jar

这篇关于在一个EAR中部署多个依赖的CDI罐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆