JBOSS 不占用我自己的库

JBOSS doesn't take my own libs

查看我的答案解决方案

我正在 Jboss 服务器中部署 WAR,但我不明白 Jboss 使用我自己的库,它使用自己的库(我认为那是我的问题)。

Structure of my project:
- projectName
--- src
----- main
-------webapp
---------WEB-INF
-----------jboss-classloading.xml
-----------jboss-deployment-structure.xml
-----------jboss-web.xml

---target
-----wars
-------myWar.war

起初我只有 jboss-web.xml 和 jboss-deployment-structure 但我读到 jboss-classloading 对于这个问题是必要的。

jboss-web.xml
<?xml version="1.0" encoding="UTF-8"?>  
<jboss-web>
<context-root>/myProject</context-root>
<class-loading java2ClassLoadingCompliance="false">
    <loader-repository>projectName/src/target/wars:loader=myWar.war
        <loader-repository-config>java2ParentDelegation=false</loader-repository-config>
    </loader-repository>
</class-loading>

jboss-classloading.xml
<?xml version="1.0" encoding="UTF-8"?>
<classloading xmlns="urn:jboss:classloading:1.0"
parent-first="false"
domain="myWar.war"
top-level-classloader="true"
export-all="NON_EMPTY"
import-all="false">
</classloading>

它显示了 2 个错误:

30/07/2015 07:30:03,795 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC000001: Failed to start service jboss.deployment.unit."myWar.war".FIRST_MODULE_USE: org.jboss.msc.service.StartException in service jboss.deployment.unit."myWar.war".FIRST_MODULE_USE: JBAS018733: Error al procesar la fase FIRST_MODULE_USE de deployment "myWar.war"
        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:166) [jboss-as-server-7.5.0.Final-redhat-21.jar:7.5.0.Final-redhat-21]
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1980) [jboss-msc-1.1.5.Final-redhat-1.jar:1.1.5.Final-redhat-1]
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1913) [jboss-msc-1.1.5.Final-redhat-1.jar:1.1.5.Final-redhat-1]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_40]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_40]
        at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_40]
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011426: No se pudo implementar el proveedor de persistencia empacado de la aplicación 'org.hibernate.ejb.HibernatePersistence'
        at org.jboss.as.jpa.processor.PersistenceProviderHandler.deploy(PersistenceProviderHandler.java:79)
        at org.jboss.as.jpa.processor.PersistenceBeginInstallProcessor.deploy(PersistenceBeginInstallProcessor.java:45)
        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:159) [jboss-as-server-7.5.0.Final-redhat-21.jar:7.5.0.Final-redhat-21]
        ... 5 more
Caused by: java.lang.ClassCastException: class org.hibernate.ejb.HibernatePersistence
        at java.lang.Class.asSubclass(Class.java:3404) [rt.jar:1.8.0_40]
        at org.jboss.as.jpa.processor.PersistenceProviderHandler.deploy(PersistenceProviderHandler.java:73)
        ... 7 more


30/07/2015 11:47:03,930 ERROR [org.jboss.msc.service.fail] (MSC service     thread 1-1) MSC000001: Failed to start service jboss.deployment.unit."myWar.war".PARSE: org.jboss.msc.service.StartException in service jboss.deployment.unit."myWar.war".PARSE: JBAS018733: Error al procesar la fase PARSE de deployment "myWar.war"
at   org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:166) [jboss-as-server-7.5.0.Final-redhat-21.jar:7.5.0.Final-redhat-21]
at  org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1980) [jboss-msc-1.1.5.Final-redhat-1.jar:1.1.5.Final-redhat-1]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1913) [jboss-msc-1.1.5.Final-redhat-1.jar:1.1.5.Final-redhat-1]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_40]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_40]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_40]
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS018014: No se logró analizar sintácticamente el descriptor "/content/myWar.war/WEB-INF/jboss-web.xml" en [4,5]
at org.jboss.as.web.deployment.JBossWebParsingDeploymentProcessor.deploy(JBossWebParsingDeploymentProcessor.java:79)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:159) [jboss-as-server-7.5.0.Final-redhat-21.jar:7.5.0.Final-redhat-21]
... 5 more
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[4,5]
Message: Unexpected element 'class-loading' encountered
at org.jboss.metadata.parser.util.MetaDataElementParser.unexpectedElement(MetaDataElementParser.java:109)
at org.jboss.metadata.parser.jbossweb.JBossWebMetaDataParser.parse(JBossWebMetaDataParser.java:210)
at org.jboss.as.web.deployment.JBossWebParsingDeploymentProcessor.deploy(JBossWebParsingDeploymentProcessor.java:71)
... 6 more


如果您需要更多信息,请告诉我。

提前致谢。

编辑有新错误

31/07/2015 12:29:52,896 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/ksjm_ksjm_01]] (ServerService Thread Pool -- 53) JBWEB000287: Exception sending context initialized event to listener instance of class com.grupobbva.sl.soa.gui.catalogos.ApplicationContextListener: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grupoDaoImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.grupobbva.sl.soa.configuracion.dao.impl.AbstractDao.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [spring/dao-configuracion-applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to get the default Bean Validation factory
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:288) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1116) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]


dao-配置-applicationContext.xml

<bean id="dataSource"
    class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="${configuracion.servicio.driverClassName}" />
    <property name="url" value="${configuracion.servicio.url}" />
    <property name="username" value="${usuario}" />
    <property name="password" value="${password}" />
</bean>

<bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.hbm2ddl.auto">${configuracion.servicio.hbm2ddl}</prop>
            <prop key="hibernate.dialect">${configuracion.servicio.dialect}</prop>
            <prop key="javax.persistence.jdbc.driver">${configuracion.servicio.driverClassName}</prop>
            <prop key="hibernate.default_schema">${configuracion.servicio.default-schema}</prop>
        </props>
    </property>
    <property name="packagesToScan"
        value="com.grupobbva.sl.soa.core.domain, com.grupobbva.sl.soa.core.domain.config" />
</bean>

我在其他 post 中读到,如果我将我的 sessionFactory bean 升级到休眠 4,它会起作用....但它对我不起作用 =(

我终于解决了这个问题。我删除了 jboss-classloading.xml 和 jboss-deployment-structure.xml 并且成功了!!这样库之间就没有了"conflicts" :)

希望对大家有用。