Drools compatibility with Java 11 - wildfly

When deploying an ear application containing a drools kie engine 7.20.0.Final on Wildfly 16.0.0.Final, I get a deployment failure exception that sun.reflect.ReflectionFactory class cannot be loaded. The application deploys fine with Java 8.
I understand that Java 11 has removed support for sun.reflect.Reflection. Does drools rely on it? The drools documentation only says the Java requirement is for Java 1.5 and nothing more.
Is drools compatible with Java 11?
Solved. Turns out the removal of sun.reflect from Java 11 was a red herring. the actual problem was with Wildfly 16 which didn't make the module available. Solution was to create a jboss-deployment-structure.xml as follows:
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">
<deployment>
<dependencies>
<system export="true">
<paths>
<path name="sun/reflect"/>
</paths>
</system>
</dependencies>
</deployment>
</jboss-deployment-structure>
See this post: Mockito, Java 9 and java.lang.ClassNotFoundException: sun.reflect.ReflectionFactory

Related

Possibility to access wildfly / app server libraries via jboss-deployment-structure.xml?

I have a web application running on a wildfly app server (22.X). It contains a war file which has the ability (besides the actual functionality) to query the wildfly itself for its active running sessions via JMX and display that number on an simple html page.
Originally the following dependency was added (via maven) to make this work:
<dependency>
<groupId>org.jboss.remotingjmx</groupId>
<artifactId>remoting-jmx</artifactId>
<version>3.0.4.Final</version>
However this dependency brings lots of other transitive dependencies along like jboss-marshalling, xnio, jboss-threads, wildfly-*, (...) - all packages which does exist within the wildfly app server anyway. So I was wondering whether it is possible to use those app server packages instead of bundling it as part of the war. I tried to add the following to the jboss-deployment-structure.xml to the EAR:
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.3">
<deployment>
<dependencies>
<system export="true">
<paths>
<path name="sun/reflect"/>
</paths>
</system>
</dependencies>
</deployment>
<sub-deployment name="service.war">
<dependencies>
<module name="org.jboss.remoting3.remoting-jmx" services="import"/>
</dependencies>
</sub-deployment>
However it didn't work - as soon as the dependencies were removed from the war file it stopped working. My question:
Is it possible to specify/configure the deployment structure file to allow access to the necessary packages from the application server? (I know that this is a wildfly specific solution but this is intended)
It looks like this module has moved to org.jboss.remoting-jmx. The org.jboss.remoting3.remoting-jmx does export the org.jboss.remoting-jmx module in WildFly 22, however the services are not exported which could be the issue.
Either way, it's best to use the org.jboss.remoting-jmx.

I don't want to refer server side jars for my project, My primefaces+spring project has to use the jars that i added to lib folder

I'm working on Primefaces + Spring project.Recently we migrated the project from JSF 1.2 to 2.2 Version.Previously our project was using jsf Implementation and API jars from Project's lib folder but now it's using the jars located in,
**\wildfly-10.0.0.Final\modules\system\layers\base\com\sun\jsf-impl\main**
**\wildfly-10.0.0.Final\modules\system\layers\base\javax\faces\api\main**
and it is throwing Services which failed to start error while deploying on wildfly 10.x,
JBAS014777: Services which failed to start: service jboss.deployment.unit."abc.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."abc.war".POST_MODULE: Failed to process phase POST_MODULE of deployment "abc.war"
How can configure my project to use lib jars.Which will helps in deployment.
Some dependencies are added implicitly by Wildfly 10. You can find a list of them here.
For the web subsystem these are:
javaee.api
com.sun.jsf-impl
org.hibernate.validator
org.jboss.as.web
org.jboss.logging
If you don't want one of them, like in your case com.sun.jsf-impl, you can exclude them using a jboss-deployment-structure.xml file as explained here.
In your case it might look like this:
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="com.sun.jsf-impl" />
</exclusions>
</deployment>
</jboss-deployment-structure>
Probably you may need more exclusions, but the principle should be clear.

jboss eap 6.4 oracle.sql.ARRAY cannot be cast to oracle.sql.ARRAY

JBoss EAP 6.4 standalone server
Application deployed as a war file throws a runtime exception
java.lang.ClassCastException: oracle.sql.ARRAY cannot be cast to oracle.sql.ARRAY
at line
ARRAY a = (ARRAY) cs.getArray(1);
JDBC libary included is ojdbc14.jar (WEB_INF/lib). All libraries are included in the war file and there are no "global" libaries setup on the server. I have verified no other jdbc libraries are included anywhere in the app.
In order to create a JDBC datasource, i created a deployment for ojdbc14.jar. This is the only possible source of conflict i can think of. When i remove the ojdbc14.jar from the war file, i get a ClassNotFound exception in place of the ClassCastException.
Every other part of the app works fine except this line. How do i debug this any further?
I have try something ,but not work:
(1)add a jboss-deployment-structure.xml into web-inf/.
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="com.oracle" slot="main"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
not work and the war dont write the log too.
This error occurs when you have two copies of the class packaged.
Based on your description, one copy is in the deployment for the Oracle driver. The second copy is in the application.
Remove it from application and instead of deploying oracle jar in deployment directory, create module of it.

JAX-RS support in JBoss (Apache CXF, JBoss Resteasy)

I'm working on a java RESTful client using Apache CXF's Proxy-based API, deploying to JBoss 5.1.
Here's my dependency in POM:
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-client</artifactId>
<version>3.0.1</version>
</dependency>
I've written a test and it works just fine, but it doesn't work in application after deployment to JBoss. It fails with NPE after application start because #SessionContext was not injected for some reason and is null.
I suppose that there are some conflicts between dependencies, because when I change above POM to:
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-client</artifactId>
<version>3.0.1</version>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
</exclusion>
</exclusions>
</dependency>
the application works fine (!) until it creates a proxy:
authenticationProxy = JAXRSClientFactory.create(
myServiceUrl,
IAuthenticationResource.class,
Collections.singletonList(jsonProvider));
At this point it hangs and fails by timeout.
I've tried to use Resteasy instead of CXF and had the same problem.
I've tried to detect conflicts in my POM using maven plugins, but it gave nothing.
I think that the problem is in JBoss. Does JBoss 5.1 support JAX-RS 2.0? Is there a default implementation of it within JBoss? Can I use Apache CXF 3.x.x in JBoss 5.1? Please advise
JAX-RS 2.0 is part of Java EE 7 Web Profile and JAX-RS 1.1 is part of Java EE 6 Web Profile.
JBoss AS 7.1 uses RESTEasy with JAX-RS 1.1, see JBoss AS 7.1 - JAX-RS Reference Guide.
JBoss AS 6 uses RESTEasy , see RESTEasy JAX-RS.
JBoss AS 5 has no implementation of JAX-RS, see RESTEasy JAX-RS, but some issues:
Resteasy has no special integration with JBoss Application Server so it must be configured and installed like any other container. There are some issues though. You must make sure that there is not a copy of servlet-api-xxx.jar in your WEB-INF/lib directory as this may cause problems. Also, if you are running with JDK 6, make sure to filter out the JAXB jars as they come with JDK 6.
If you use JBoss EAP 5.1 you find versions of JBoss AS, RESTEasy and Apache CXF at JBoss Enterprise Application Platform 5.

How to enable a custom log4j with Jboss AS 7.1

I tried several options. But anything didn't work for me.
Previously I used the same log4j.xml (simple common config) with Tomcat 6,7 and I could able to control the root logging and the application logging with updating the log4j.xml.
When I deploy the same project with JBoss AS 7.1, It only gives me INFO level logging and my log4j.xml doesn't work at all. Sometime this can be fixed by updating some configuration files inside the JBoss server, but I like to know if there a portable way to do it or something similar. If this is bug or something with JBoss AS 7.1 I like to know about a quick fix anyway.
I haven't worked with JBoss before.
Thanks!
I had this problem and solved it by following method:
use your own log4j jar instead of one that provided by jboss. Do it by excluding jboss org.apache.log4j jar module from your application (exclude it in jboss-deployment-structure.xml) and add your own log4j jar file in lib folder of the .ear package.
Now put log4j.xml in the root folder of your module.
By this method you have full control on log4j (like standalone applications).
let me know if you need more help.
Sample jboss-deployment-structure.xml for excluding log4j.jar:
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
<deployment>
<exclusions>
<module name="org.apache.log4j" slot="main"/>
</exclusions>
</deployment>
<sub-deployment name="MyEjb.jar">
<exclusions>
<module name="org.apache.log4j"/>
</exclusions>
</sub-deployment>