How is possible to exclude all automatic dependencies from being added in JBoss 7? - jboss7.x

I want to exclude all automatic dependencies in JBoss 7.
Was not able to find the answer here:
https://docs.jboss.org/author/display/AS7/Class+Loading+in+AS7
Added
Automatic (implicit) dependencies are described here:
https://docs.jboss.org/author/display/AS7/Implicit+module+dependencies+for+deployments
Now I need to do it explicitly. See below.
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="org.jboss.as.jmx"/>
</dependencies>
<exclusions>
<module name="javaee.api" />
<module name="javax.xml.bind.api" />
<module name="javax.persistence.api" />
...
</exclusions>
</deployment>
</jboss-deployment-structure>
Question if I can do it using simple configuration like:
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="org.jboss.as.jmx"/>
</dependencies>
<exclusions>
<subsystem name="implicit" />
</exclusions>
</deployment>
</jboss-deployment-structure>

I don't think you can. However, it wouldn't make sense anyway, as for example JDK is part of those implicit dependencies - you really don't want to deploy the entire JDK with your application, now, do you?
Create a set of implicit dependencies that you don't want and put them into jboss-deployment-structure like you have done.

Related

Can't register AWS-SDK on Jboss modules correctly

I found the dependency aws-java-sdk was being compiled on a legacy code, having as result a very heavy EAR.
I declared this dependency as provided and wanted to put it as part of the Jboss modules, but no matter where I put it, I'm still having the ClassNotFound issue.
Here is my module.xml:
<module xmlns="urn:jboss:module:1.1" name="com.amazonaws">
<properties>
<property name="jboss.api" value="private"/>
</properties>
<resources>
<resource-root path="aws-java-sdk-1.11.584.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.xml.stream.api"/>
<module name="javax.xml.bind.api"/>
<module name="com.fasterxml.jackson"/>
<module name="org.joda.time"/>
</dependencies>
</module>
And the error:
Caused by: java.lang.NoClassDefFoundError: com/amazonaws/auth/AWSCredentials
The problem was on the JAR file, needed sdk-core. Check your JARs always.

Can keycloak JavaScript based policy calls remote REST API?

Can I call remote REST API from keycloak's JavaScript based policy? I need this because the current version of keycloak does not support custom attributes for resources according to this answer. Thus I created a special server that contains all required metadata for making decisions about granting access to resources.
1.You can make jar and copy it into modules dir. Make it like other modules, create module.xml
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.5" name="io.geewit.keycloak.provider">
<resources>
<resource-root path="keycloak-mock-module-1.0.0.jar"/>
</resources>
<dependencies>
<module name="sun.jdk"/>
<module name="sun.scripting"/>
<module name="org.keycloak.keycloak-core"/>
<module name="org.keycloak.keycloak-server-spi"/>
<module name="org.keycloak.keycloak-server-spi-private"/>
</dependencies>
</module>
2.You edit the "keycloak-services" module.xml
<dependencies>
<module name="sun.scripting"/>
<module name="io.geewit.keycloak.provider"/>
</dependencies>

Axis1 on Wildlfy

Trying to deploy a war on Wildfly 10.0.0. Final standalone got the following error :
java.lang.LinkageError: loader constraint violation: when resolving method "org.apache.axis.description.TypeDesc.setXmlType(Ljavax/xml/namespace/QName;)V"
the class loader (instance of org/jboss/modules/ModuleClassLoader) of the current class, mypackage/MyClass,
and the class loader (instance of org/jboss/modules/ModuleClassLoader) for the method's defining class, org/apache/axis/description/TypeDesc,
have different Class objects for the type javax/xml/namespace/QName used in the signature
wildfly-10.0.0.Final\modules\org\apache\axis\jaxrpc\main\axis-jaxrpc-1.4.jar\javax\xml\namespace\QName.class major version: 47jdk1.8.0_60\jre\lib\rt.jar\javax\xml\namespace\QName.class major version: 52
I have read the Class Loading in WildFly but have no idea what the proper "specific order" is:
A common source of errors in Java applications is including API
classes in a deployment that are also provided by the container. This
can result in multiple versions of the class being created and the
deployment failing to deploy properly. To prevent this in WildFly,
module dependencies are added in a specific order that should prevent
this situation from occurring.
jboss-deployment-structure.xml contains:
<module name="org.apache.axis.axis" />
pom.xml contains:
<dependency>
<groupId>axis</groupId>
<artifactId>axis</artifactId>
<version>1.4</version>
<scope>provided</scope>
</dependency>
wildfly-10.0.0.Final\modules\org\apache\axis\axis\main\module.xml:
<module xmlns="urn:jboss:module:1.1" name="org.apache.axis.axis">
<resources>
<resource-root path="axis-1.4.jar"/>
</resources>
<dependencies>
<module name="org.apache.axis.jaxrpc"/>
<module name="org.apache.axis.saaj"/>
<module name="org.apache.axis.wsdl4j"/>
<module name="org.apache.commons.discovery"/>
<module name="org.apache.commons.logging"/>
<module name="javax.activation.api"/>
<module name="javax.api"/>
<module name="javax.mail.api"/>
<module name="javax.servlet.api"/>
</dependencies>
</module>
wildfly-10.0.0.Final\modules\org\apache\axis\jaxrpc\main\module.xml:
<module xmlns="urn:jboss:module:1.1" name="org.apache.axis.jaxrpc">
<resources>
<resource-root path="axis-jaxrpc-1.4.jar"/>
</resources>
</module>
Using Local Resource instead of User Dependencies solved the problem.
From jboss-deployment-structure.xml removed:
<module name="org.apache.axis.axis" />
pom.xml (no provided scope anymore):
<dependency>
<groupId>org.apache.axis</groupId>
<artifactId>axis-jaxrpc</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.axis</groupId>
<artifactId>axis-saaj</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>axis</groupId>
<artifactId>axis-wsdl4j</artifactId>
<version>1.5.1</version>
</dependency>
<dependency>
<groupId>axis</groupId>
<artifactId>axis</artifactId>
<version>1.4</version>
</dependency>

Exclude org.codehouse.jackson.* from my War on Wildfly 8.2.0 to use com.fasterxml.jackson.*

I try to use the com.fasterxml.jackson for my JSON Deserialization and Serialization. I put the dependencies for the com.fasterxml version in the pom.xml of my war-project and also added the org.jboss.resteasy.resteasy-jackson2-provider dependency there. However my WildFly throws the exception that it can not find the class org.codehouse.jackson.jaxrs.JacksonJsonProvider. I also tried excluding the resteasy-jackson-provider in my jboss-deployment-structure.xml and added the new resteasy-jackson2-provider as dependency with the service-attribute set to "import" as i found on some previous questions. None of this resolved my problem. The important files (hope i did not miss one):
Jboss-deployment-structure:
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.jboss.resteasy.resteasy-jackson-provider"/>
<module name="org.jboss.resteasy.resteasy-json-provider"/>
</exclusions>
<dependencies>
<module name="org.jboss.resteasy.resteasy-jackson2-provider" services="import"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
Dependencies from pom.xml:
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson2-provider</artifactId>
<version>3.0.10.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.4.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.4.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.4.1</version>
<scope>provided</scope>
</dependency>
EDIT: I noticed that there are several duplicate jars in my war (including the resteasy-jackson-provider). To fix this i tried to exclude as much general poms (for example wildfly-parent) from my poms as possible. I now have only the directly necessary dependencies in my poms and the issue still stands (multiple jars i did not include or include with the scope provided in my war). Does anybody have an idea why this might occure?
EDIT 2: Issue is fixed there was a problem with my maven script, which did not clean the war... stupid mistake by my part
I faced the same problem too
Im' not really sure about it but when i tryed i found out that Wildfly has packaged all his module under javaee.api so you couldn't exclude any module or have to exclude all. You have to upgrade your Wildfly version and upgrade package.
I can tell you at least than in the most recent version they use fasterxml. So if you don't need a specific version of fasterXML's jackson, just upgrade wildfly.
For anyone who arrives here I would like to comment that, for me, the key has been this exclusions, expecially important the second one:
<exclusions>
<module name="org.jboss.resteasy.resteasy-jackson-provider"/>
<module name="org.jboss.resteasy.resteasy-json-binding-provider"/>
</exclusions>
So, I hope this can be helpfull for somebody.

CDI 1.1 with JBoss

Is it possible to use CDI 1.1 with JBoss 7.1.1?
I have a single test war and would like to deploy this war together with weld 2.0.
I disabled the automatically loading of the weld module with the jboss-deployment-structure File:
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.jboss.weld.core" />
</exclusions>
</deployment>
</jboss-deployment-structure>
I also tried to add a extra slot in the jboss/module folder:
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.jboss.weld.core" />
<module name="org.jboss.weld.api" />
<module name="org.jboss.weld.spi" />
</exclusions>
<dependencies>
<module name="org.jboss.weld.core" slot="2.0" />
<module name="org.jboss.weld.api" slot="2.0" />
<module name="org.jboss.weld.spi" slot="2.0" />
</dependencies>
</deployment>
</jboss-deployment-structure>
The deployment failed in both cases because JBoss apparently needs weld for the deployment.
So is it possible to use CDI 1.1 with JBoss 7.1.1 and how?
No, it's not possible. You could try weld-servlet from 2.0 but it won't work with EJB and will get quite confused. The app server integration is different in weld 2.0, so it won't work with AS7.
JBoss Weld community has an installation script to update JBoss AS Weld Subsystem to Weld 2.0;
https://github.com/weld/as7-weld-subsystem . Wildfly is currently in Alpha4 so this may be a better option at this time.