简体   繁体   English

如何将战争文件(其中包含persistance.xml和entity.java类封装)隐藏到耳朵文件中?

[英]How to covert a war file (having persistance.xml and entity.java class packaged within it) into an ear file?

I am trying to package a war file to a ear file as i have to deploy my project on webLogic. 我试图将war文件打包到ear文件,因为我必须在webLogic上部署我的项目。 I have created a dynamic web project which has 1 entity (java class)class and 1 persistance.xml (and lot of other lib files, jsp files,java classes). 我创建了一个动态Web项目,该项目具有1个实体(java类)类和1persistance.xml(以及许多其他lib文件,jsp文件和java类)。 I have extracted this project as a war file. 我已将该项目提取为战争文件。 Now to deploy it on weblogic I need to have a ear file. 现在要将其部署在weblogic上,我需要准备一个文件。 I dont know how to do it...when i simply added my war file as a web module in ear I got a null pointer exception. 我不知道该怎么做...当我只是将war文件作为Web模块添加到耳朵中时,出现了空指针异常。 I believe I need to do something with persistance.xml and entity files. 我相信我需要对persistance.xml和实体文件做一些事情。 Please help. 请帮忙。

When I was running dynamic web project on my local tomcat it was running fine and persistance.xml was placed in src/metainf folder and looks like this: 当我在本地tomcat上运行动态Web项目时,它运行良好,persistance.xml位于src / metainf文件夹中,如下所示:

 persistence-unit name="MyWar"

 class PackageName.MyEntity class

properties
  property name="eclipselink.jdbc.driver" value="oracle.jdbc.driver.OracleDriver"/>
 property name="eclipselink.jdbc.url" value="jdbc:oracle:thin:XYZ"/>
 property name="eclipselink.jdbc.user" value="USERNAME"/>
 property name="eclipselink.jdbc.password" value="PASSWORD"/>
  property name="eclipselink.logging.level" value="SEVERE"/>
 property name="eclipselink.ddl-generation" value="create-tables"/>
 properties

 persistence-unit

 persistence    `

For placing project on web logic I am using JTA.My persistance.xml is in src/metaInf and looks like this. 为了将项目放置在Web逻辑上,我使用的是JTA.mysistenceance.xml位于src / metaInf中,看起来像这样。

  persistence-unit name="MyWar" transaction-type="JTA"

    jta-data-source XYZ.datasource /jta-data-source

     class packageName.MyEntity class

   <exclude-unlisted-classes>false exclude-unlisted-classes> 

    persistence-unit

  persistence

I extracted dynamic web project as a WAR and added it in EA project 我将动态Web项目提取为WAR,并将其添加到EA项目中

My application.xml (in EA project) is placed in EARContent/MetaInf/application.xml and looks like this: 我的application.xml(在EA项目中)放置在EARContent / MetaInf / application.xml中,如下所示:

        display-name EARName display-name

       module

        web 

          web-uri MyWar.war  web-uri

           context-root MyWar context-root 

       web

       module

    application

Extracted a EAR and placed in webLogic server. 提取EAR并将其放置在webLogic服务器中。 Error: 错误:

Nov 24, 2014 12:04:19 PM GMT Error HTTP BEA-101371 There was a failure when processing annotations for application /opt/dap/domains/PORTALINSTANCE/int/domain/servers/MS1/tmp/_WL_user/MYWARNAME/48n279/MYWARNAME.war. 2014年11月24日12:04:19 PM GMT错误HTTP BEA-101371处理应用程序/ opt / dap / domains / PORTALINSTANCE / int / domain / servers / MS1 / tmp / _WL_user / MYWARNAME / 48n279 /的注释时失败MYWARNAME.war。 Ensure that the annotations are valid. 确保注释有效。 The error is null. 错误为空。

I am first time writting my question , please excuse my way of writting code. 我是第一次写我的问题,请原谅我写代码的方式。

you can deploy a .war file into an EE container. 您可以将.war文件部署到EE容器中。 the only advantage of repackaging as an .ear file is that you get to bundle multiple .war files as well as service endpoint ejb-jar files (remote ejbs). 重新打包为.ear文件的唯一优点是,您可以捆绑多个.war文件以及服务端点ejb-jar文件(远程ejbs)。

persistence.xml would reside where your ORM/DAO layer resides (in the META-INF dir of your war file or in the ejb jar file if you split out the ejb layer from the war file [assuming you go .ear]) the entities would either be in the WEB-INF/classes dir if you go with war packaging or in your ejb jar file if you split it out and deploy as an .ear file. persistence.xml将驻留在您的ORM / DAO层所在的位置(如果您从war文件中拆分ejb层,则假设在war文件的META-INF目录中,或者在ejb jar文件中,假设您是.ear)。如果使用war包装,则将位于WEB-INF / classes目录中;如果将其拆分并作为.ear文件进行部署,则将在ejb jar文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM