wildfly did not find jar inside war - deployment

After changing ear to war, wildfly 10 cant find the jar file from jboss-deployment-structure.xml from sub-deployment section. There is no gui.ejb.jar in war after project buildin and I copy it to war manually. I try to root folder and to WEB-INF lib. Help please how to fix it.
Caused by:
org.jboss.as.server.deployment.DeploymentUnitProcessingException:
WFLYSRV0166: Sub deployment gui.ejb.jar in
jboss-deployment-structure.xml was not found. Available sub
deployments: at
org.jboss.as.server.deployment.module.descriptor.DeploymentStructureDescriptorParser.subDeploymentNotFound(DeploymentStructureDescriptorParser.java:288)
at
org.jboss.as.server.deployment.module.descriptor.DeploymentStructureDescriptorParser.deploy(DeploymentStructureDescriptorParser.java:190)
at
org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:147)
... 5 more
<jboss-deployment-structure>
<deployment>
<exclude-subsystems>
<subsystem name="webservices"/>
<subsystem name="jaxrs"/>
</exclude-subsystems>
<exclusions>
<module name="org.apache.commons.logging"/>
<module name="org.apache.log4j"/>
<module name="org.jboss.logging"/>
<module name="org.jboss.logging.jul-to-slf4j-stub"/>
<module name="org.jboss.logmanager"/>
<module name="org.jboss.logmanager.log4j"/>
<module name="org.slf4j"/>
<module name="org.slf4j.impl"/>
<module name="org.apache.cxf.impl"/>
<module name="org.apache.cxf"/>
<module name="org.apache.cxf.services-sts"/>
<module name="org.apache.cxf.ws-security"/>
<module name="org.apache.cxf.ws-policy"/>
<module name="org.apache.xerces"/>
<module name="org.apache.xalan"/>
</exclusions>
<dependencies>
<module name="com.sun.xml.bind" export="true"services="export"/>
<module name="javax.xml.ws.api" export="true"/>
<module name="javax.jws.api" export="true"/>
<module name="org.slf4j" export="true"/>
</dependencies>
</deployment>
<sub-deployment name="gui.ejb.jar">
<exclusions>
<module name="org.apache.xerces"/>
<module name="org.apache.xalan"/>
<module name="org.slf4j"/>
<module name="org.slf4j.impl"/>
</exclusions>
<dependencies>
<module name="com.sun.xml.bind" export="true"services="export"/>
<module name="javax.xml.ws.api" export="true" />
<module name="javax.jws.api" export="true" />
<module name="org.slf4j" export="true"/>
</dependencies>
</sub-deployment>
</jboss-deployment-structure>

A WAR deployment does not have a sub-deployment. You can remove the <sub-deployment/> element and it will be inherited from the main deployment element.
As a side note it looks a bit weird to both include and exclude the org.slf4j module. If you're attempting to use you're own slf4j binding you'd need to keep it excluded and include an slf4j-api and binding library.

Related

How to excude exports in deployment module (Wildfly)?

I have two war-files: core.war and service.war
Archive core.war includes jboss-deployment-structure.xml:
<?xml version='1.0' encoding='UTF-8'?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<ear-subdeployments-isolated>false</ear-subdeployments-isolated>
<deployment>
<exclude-subsystems>
<subsystem name="logging"/>
<subsystem name="pojo"/>
</exclude-subsystems>
<exclusions>
<module name="org.slf4j"/>
<module name="org.slf4j.impl"/>
<module name="org.slf4j.ext"/>
<module name="org.slf4j.jcl-over-slf4j"/>
<module name="org.apache.log4j"/>
<module name="org.apache.commons.logging"/>
<module name="org.jboss.logging"/>
<module name="org.jboss.logging.jul-to-slf4j-stub"/>
<module name="org.jboss.logmanager"/>
<module name="org.jboss.log4j.logmanager"/>
<module name="org.jboss.as.logging"/>
<!-- exclude wildfly logging modules, use slf4j + logback -->
<module name="org.jboss.logmanager.log4j"/>
</exclusions>
<dependencies>
<module name="deployment.some-dep-1.ear" meta-inf="import"/>
<module name="deployment.some-dep-2.ear" meta-inf="import" services="import" optional="true"/>
<module name="deployment.some-dep-3.ear" meta-inf="import"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
service.war includes jboss-deployment-structure.xml:
<?xml version='1.0' encoding='UTF-8'?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<ear-subdeployments-isolated>false</ear-subdeployments-isolated>
<deployment>
<exclude-subsystems>
<subsystem name="logging"/>
<subsystem name="pojo"/>
</exclude-subsystems>
<exclusions>
<module name="org.slf4j"/>
<module name="org.slf4j.impl"/>
<module name="org.slf4j.ext"/>
<module name="org.slf4j.jcl-over-slf4j"/>
<module name="org.apache.log4j"/>
<module name="org.apache.commons.logging"/>
<module name="org.jboss.logging"/>
<module name="org.jboss.logging.jul-to-slf4j-stub"/>
<module name="org.jboss.logmanager"/>
<module name="org.jboss.log4j.logmanager"/>
<module name="org.jboss.as.logging"/>
<!-- exclude wildfly logging modules, use slf4j + logback -->
<module name="org.jboss.logmanager.log4j"/>
</exclusions>
<dependencies>
<module name="deployment.core.war" services="import" meta-inf="import"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
and I have overlays:
standalone.xml:
...
<deployment-overlays>
<deployment-overlay name="dep-lib">
<!-- ... -->
<content path="/WEB-INF/lib/org-springframework-spring-aop-3.2.10.RELEASE.jar" content="77d0b86238df32cb15e469eaa2f7f32c4893dc54"/>
<content path="/WEB-INF/lib/org-springframework-spring-aspects-3.2.10.RELEASE.jar" content="d5327b3d4a74f224d32c338e83789ae877feb790"/>
<!-- ... -->
<deployment name="core.war"/>
</deployment-overlay>
</deployment-overlays>
...
In this case classLoader in service.war module could not load classes declared in some-dep-1.ear/some-dep-2.ear/some-dep-3.ear becouse
attribute export="false" by default in the tag <module/>
Now I want to exclude some overlay dependensies for service.war.
I try to use tage <export/> something like this:
<?xml version='1.0' encoding='UTF-8'?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<ear-subdeployments-isolated>false</ear-subdeployments-isolated>
<deployment>
<exclude-subsystems>
<subsystem name="logging"/>
<subsystem name="pojo"/>
</exclude-subsystems>
<exclusions>
<module name="org.slf4j"/>
<module name="org.slf4j.impl"/>
<module name="org.slf4j.ext"/>
<module name="org.slf4j.jcl-over-slf4j"/>
<module name="org.apache.log4j"/>
<module name="org.apache.commons.logging"/>
<module name="org.jboss.logging"/>
<module name="org.jboss.logging.jul-to-slf4j-stub"/>
<module name="org.jboss.logmanager"/>
<module name="org.jboss.log4j.logmanager"/>
<module name="org.jboss.as.logging"/>
<!-- exclude wildfly logging modules, use slf4j + logback -->
<module name="org.jboss.logmanager.log4j"/>
</exclusions>
<exports>
<exclude-set>
<path name="**"/>
</exclude-set>
<include-set>
<path name="org/slf4j"/>
</include-set>
</exports>
<dependencies>
<module name="deployment.some-dep-1.ear" meta-inf="import"/>
<module name="deployment.some-dep-2.ear" meta-inf="import" services="import" optional="true"/>
<module name="deployment.some-dep-1.ear" meta-inf="import"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
but this not works.
How can I exclude overlay dependences for export?
If you are using master-slave configuration and your slave configuration is EAP 6.3. or older than it is not possible, you need to downgrade your configuration.
[https://issues.jboss.org/browse/WFCORE-2899?_sscc=t][1]

log4j2 2.10.0 will not deploy on jboss EAP 7

Needed to update our log4j2 from 2.7 to 2.10.0 to get JMS retries working.
When I try to deploy the ear with the 2.10.0 files, jboss is complaining with the following error:
Caused by: java.util.ServiceConfigurationError:
org.apache.logging.log4j.util.PropertySource: Provider
org.apache.logging.log4j.util.EnvironmentPropertySource not a subtype"},
We are also excluding the default jboss logger from our app
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<exclusions>
<module name="org.apache.log4j" />
<module name="org.apache.commons.logging"/>
<module name="org.apache.commons.logging" />
<module name="org.jboss.logging" />
<module name="org.jboss.logging.jul-to-slf4j-stub" />
<module name="org.jboss.logmanager" />
<module name="org.jboss.logmanager.log4j" />
<module name="org.slf4j" />
<module name="org.slf4j.impl" />
</exclusions>
</deployment>
These are the jars in my ear's lib folder for logging:
lib/log4j-api.jar
lib/log4j-core.jar
lib/log4j-slf4j-impl.jar
lib/log4j-web.jar
lib/slf4j-api.jar
lib/slf4j-ext.jar
Any suggestions? Maybe there is another new file I have to exclude?

How to configure a new module in JBoss AS 7.1.3?

This question is a spinoff of this one!
I now can configure my project to use a different version of Hibernate and my JBoss installation has a second slot named "5.1.1.Final" (located at ...\jboss-as-7.1.3.Final\modules\org\hibernate\5.1.10.Final) that has the following module.xml file:
<module xmlns="urn:jboss:module:1.1" name="org.hibernate:5.1.10.Final">
<resources>
<resource-root path="hibernate-core-5.1.10.Final.jar"/>
<resource-root path="hibernate-entitymanager-5.1.10.Final.jar"/>
<resource-root path="hibernate-infinispan-5.1.10.Final.jar"/>
<!-- Insert resources here -->
</resources>
<dependencies>
<module name="asm.asm"/>
<module name="javax.api"/>
<module name="javax.persistence.api"/>
<module name="javax.transaction.api"/>
<module name="javax.validation.api"/>
<module name="org.antlr"/>
<module name="org.apache.commons.collections"/>
<module name="org.dom4j"/>
<module name="org.infinispan" optional="true"/>
<module name="org.javassist"/>
<module name="org.jboss.as.jpa.hibernate" slot="4" optional="true"/>
<module name="org.jboss.logging"/>
<module name="org.hibernate.envers" services="import" optional="true"/>
<module name="org.hibernate.commons-annotations"/>
</dependencies>
</module>
However, when JBoss starts I receive the following error message: ParseError at [row,col]:[26,72] Message: Invalid/mismatched module name (expected org.hibernate:5.1.10.Final).
I can't understand why this message, since the required module name (org.hibernate:5.1.10.Final) is the exact name I specified at the file (name="org.hibernate:5.1.10.Final");
What am i missing?
The slot is a separate attribute. It should look like the following.
<module xmlns="urn:jboss:module:1.1" name="org.hibernate" slot="5.1.10.Final">
On a side note you may want to consider trying to upgrade to WildFly 11, current release is WildFly 11.0.0.Beta1. I'm not sure if Hibernate 5.1.x will work with JBoss AS 7.x. WildFly 10.1.0.Final uses Hibernate 5.0.10.Final.

Cannot access Seam Components within JAR from WAR in [JBOSS 7.1.1.FINAL and SEAM 2.2.1.CR2]

Problem: I have an ejb-jar-1.jar which defines EJBs and Entities. The project structure is listed below. During deployment all EJBs are successfully bootstraped > started and their JNDI locations are printed in a log file. There's a class in my WAR file which needs to access a NAMED QUERY defined on an Entity which resides inside ejb-jar-1.jar. When this piece of code is run it throws an illegalArgumentException saying NAMED QUERY cannot be found. On a different note I also cannot get reference to SEAM components that were started when ejb-jar1.jar was deployed. I printed the JNDI tree from app-war.war file and it does not have any JNDI resources from ejb-jar-1.jar. So, I believe this is a context issue where JNDI resources available in ejb-jar-1.jar cannot be seen from app-war.war.
Any suggestions on how to access JNDI resources available in ejb-jar-1.jar from app-war.war?
Deployement Info
* JBOSS 7.1.1.FINAL
* Uses seam framework: jboss-seam-2.2.1.CR2.jar
* Uses Hibernate 3.4.0.GA
main-ear.ear
|__META-INF
| |____jboss-deployment-structure.xml
| |____application.xml
| |____jboss-app.xml
| |____MANIFEST.MF
|__lib
| |____somejar.jar
| |____somejar.jar
|__ejb-jar-1.jar
|__ejb-jar-2.jar
|__jboss-seam-2.2.1.CR2.jar
|__commons-lang-2.4.jar
|__commons-codec-1.1.jar
|__jasypt-1.6.jar
|__app-war.war
jboss-deployment-structure.xml
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
<ear-subdeployments-isolated>false</ear-subdeployments-isolated>
<deployment>
<exclusions>
<module name="javax.faces.api" slot="1.2"/>
<module name="com.sun.jsf-impl" slot="1.2"/>
<module name="org.hibernate" slot="main"/>
<module name="org.hibernate.validator" slot="main"/>
<module name="org.apache.commons.lang"/>
<module name="org.apache.commons.collections"/>
<module name="org.apache.commons.codec"/>
<module name="org.picketlink" slot="main"/>
<module name="org.picketbox" slot="main"/>
<module name="org.javassist" slot="main"/>
<module name="org.dom4j" slot="main"/>
</exclusions>
<dependencies>
<module name="javax.faces.api" slot="1.2" export="true"/>
<module name="com.sun.jsf-impl" slot="1.2" export="true"/>
<module name="org.javassist" slot="1" export="true"/>
<module name="org.apache.commons.logging" export="true"/>
</dependencies>
</deployment>
<sub-deployment name="app-war.war">
<exclusions>
<module name="javax.faces.api" slot="main"/>
<module name="com.sun.jsf-impl" slot="main"/>
</exclusions>
<dependencies>
<module name="javax.faces.api" slot="1.2"/>
<module name="com.sun.jsf-impl" slot="1.2"/>
<module name="deployment.main-ear.ear.ejb-jar-1.jar" />
<module name="deployment.main-ear.ear.ejb-jar-2.jar" />
<module name="deployment.main-ear.ear.jboss-seam-2.2.1.CR2.jar"/>
</dependencies>
</sub-deployment>
<module name="deployment.main-ear.ear.jasypt-1.6.jar" />
<module name="deployment.main-ear.ear.commons-codec-1.1.jar" />
<module name="deployment.main-ear.ear.commons-lang-2.4.jar" />
</jboss-deployment-structure>
application.xml
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/javaee/application_6.xsd"
version="6">
<description>myapp</description>
<display-name>myapp</display-name>
<initialize-in-order>true</initialize-in-order>
<library-directory>lib</library-directory>
<module>
<ejb>ejb-jar-1.jar</ejb>
</module>
<module>
<ejb>ejb-jar-2.jar</ejb>
</module>
<module>
<ejb>jboss-seam-2.2.1.CR2.jar</ejb>
</module>
<module>
<web>
<web-uri>app-war.war</web-uri>
<context-root>/app</context-root>
</web>
</module>
</application>
Bit late but oh well...for EE6 you need to use JNDI portable syntax, eg. add following annotations to all beans in the secondary module
#JndiName("java:app/NameOfModule/NameOfBean")
Think you need seam.properties in your jar in META-INF

Has anyone run AspectJ with JBoss AS 7.1.1 final?

I configured everything like they say here.
And it still won't run. It just gives me an LogManager exception.
Does anyone successfully run AspectJ there?
Here is a possible workaround/solution (from http://wiki.eclipse.org/LTWJboss7):
The IllegalStateException is thrown by jBoss7 because there is a bug
that limits access to java.util.logging:
https://issues.jboss.org/browse/AS7-1 - There a partial solution to
avoid this problem is suggested, regarding changing the way the
loadmanager is loaded, pushing it to the BootClasspath and adding
several configuration options. However we suggest deactivating the
AspectJ tracing facilities. You can achieve this by adding the next
options:
-Dorg.aspectj.tracing.enabled=false -Dorg.aspectj.tracing.factory=default
Due to new JBoss classloader and modularization architecture, classes
stored in your javaagent are not visible to the remaining modules, so
your aspects will not be found and you will get different types of
errors. To let your aspects been found by all your code you have to
add the aspectjweaver, and aspects.jar files to the bootclasspath and
add the next option to JBoss startup:
-Djboss.modules.system.pkgs=org.aspectj,com.yourcompany.aspects.package
that makes every class under those packages shared across all the
modules in the JBoss system.
This worked excellently for me ;).
I have configured three modules ec.com.acme, org.springframework, org.aspectj.
The key is to add the ironjacamar module as dependency of org.aspectj module and export them to be visible to all modules that depend on org.aspectj module, for example org.springframework module, as well:
org.aspectj Module Configuration:
<module xmlns="urn:jboss:module:1.1" name="org.aspectj">
<resources>
<resource-root path="aspectjweaver-1.7.2.jar"/>
</resources>
<dependencies>
<!--Add and export it to work-->
<module name="org.jboss.ironjacamar.jdbcadapters" export="true"/>
</dependencies>
</module>
Module Configuration org.springframework:
<module xmlns="urn:jboss:module:1.1" name="org.springframework">
<resources>
<resource-root path="com.springsource.org.aopalliance-1.0.0.jar"/>
<resource-root path="org.springframework.aop-3.1.0.RELEASE.jar"/>
<resource-root path="org.springframework.asm-3.1.0.RELEASE.jar"/>
<resource-root path="org.springframework.aspects-3.1.0.RELEASE.jar"/>
<resource-root path="org.springframework.beans-3.1.0.RELEASE.jar"/>
<resource-root path="org.springframework.context-3.1.0.RELEASE.jar"/>
<resource-root path="org.springframework.context.support-3.1.0.RELEASE.jar"/>
<resource-root path="org.springframework.core-3.1.0.RELEASE.jar"/>
<resource-root path="org.springframework.expression-3.1.0.RELEASE.jar"/>
<resource-root path="org.springframework.jdbc-3.1.0.RELEASE.jar"/>
<resource-root path="org.springframework.orm-3.1.0.RELEASE.jar"/>
<resource-root path="org.springframework.oxm-3.1.0.RELEASE.jar"/>
<resource-root path="org.springframework.transaction-3.1.0.RELEASE.jar"/>
<resource-root path="org.springframework.web-3.1.0.RELEASE.jar"/>
<resource-root path="org.springframework.web.servlet-3.1.0.RELEASE.jar"/>
<resource-root path="spring-batch-core-2.1.9.RELEASE.jar"/>
<resource-root path="spring-batch-infrastructure-2.1.9.RELEASE.jar"/>
</resources>
<dependencies>
<module name="org.apache.commons.logging" export="true"/>
<module name="org.hibernate" slot="3" export="true"/>
<module name="javax.api"/>
<module name="javax.annotation.api"/>
<module name="javax.el.api"/>
<module name="javax.enterprise.api"/>
<module name="javax.ejb.api"/>
<module name="javax.faces.api"/>
<module name="javax.interceptor.api"/>
<module name="javax.servlet.api"/>
<module name="javax.servlet.jsp.api"/>
<module name="javax.transaction.api"/>
<module name="javax.xml.bind.api"/>
<!--Add and export it to work-->
<module name="org.aspectj" export="true"/>
<module name="com.ibm.as400" slot="main" export="true"/>
</dependencies>
</module>
ec.com.acme Module Configuration:
<module xmlns="urn:jboss:module:1.1" name="ec.com.acme">
<resources>
<resource-root path="prjAcme.jar"/>
</resources>
<dependencies>
<module name="org.apache.commons.lang" slot="main" export="true"/>
<module name="org.apache.commons.beanutils" slot="main" export="true"/>
<module name="org.apache.commons.collections" slot="main" export="true"/>
<module name="org.apache.commons.io" slot="main" export="true"/>
<module name="org.apache.commons.lang3" slot="main" export="true"/>
<!--Add and export it to work-->
<module name="org.springframework" slot="main" export="true"/>
</dependencies>
</module>