JAXB ClassNotFoundException com.sun.xml.bind.v2.ContextFactory when hot-deploying camel routes - apache-camel

Yes I know, there are numerous questions and answers since JAXB was removed from JDK 11. But this one is specific.
I've a Wildfly Server (tested with 18.0.1 and 16.0.0) running with the wildfly-camel subsystem 11.0.1 patch applied. The patch installs Camel 2.25.0
Deploying and Hot-Deploying (while the server is up) Camel routes works fine!
Until I deploy Liferay on the same server :-(
Then the Hot-Deploy of a camel route gives me the annoying
[java.lang.ClassNotFoundException: com.sun.xml.bind.v2.ContextFactory from [Module "org.apache.camel.spring" version 2.25.0...
exeption.
No matter if I run the server on JDK 11 or JDK 8! Liferay 7.3.2 claims to be runnable on both JDK versions so I guess it has something to with the way Liferay was build.
Reading this article
http://www.descher.at/descher-vu/2019/01/java-11-jaxb-and-osgi/
that the JAXB topic is very complex and far from being resolved.
Question:
How can a deployed application destroy otherwise working classpath resolutions?
And more important:
How to fix it?
I tried removing the 2 jars in question jaxb-api.jar and jaxb-impl.jar from Liferay. But that didn't help.

Turns out that the root cause of the error is a missing dependency to com.sun.xml.bind in the org.apache.camel.spring module of the wildfly-camel patch.
I filed the issue in detail.
Looks like Liferay has nothing to do with it. Because in theory jboss-modules should separate the deployments.

Related

Wagtail version in admin interface does not update after upgrade

I recently incrementally upgraded my Wagtail installation from 2.15.2 to 2.16.2, but the Wagtail version in the admin interface is still stuck in the old version. What can I do to fix this?
As #LB Ben Jonston suggested, in the end the problem was even though the Docker image was built correctly, the image did not deploy correctly.
Since I'm not very familiar with Azure, I only checked that the pipeline ran correctly, image was built and pushed. But I missed checking that the actual CD task deployed the image successfully, which it didn't.

NoSuchMethodError for errorHandler when deploying into ServiceMix

I have a servicemix module, which is basicly a camel based route.
It works fine during development and also when deploying in older version of FUSE. However, when deploying in a later version of FUSE, I get
Caused by: java.lang.NoSuchMethodError:
com.company.integration.MyRouteBuilder.errorHandler(Lorg/apache/camel/builder/ErrorHandlerBuilder;)Lorg/apache/camel/builder/RouteBuilder;
I do not quite get why :-)
The old version used camel 2.6, the new uses Camel 2.9. Both have RouteBuilder.errorHandler as far as i can tell..
br
I wouldn't spend too much time trying to figure that out myself...I'd just start testing with the same version of Camel that I'm going to deploy it under...otherwise even if you get around this issue, others will likely pop up, etc.
If you do have a requirement to run multiple apps that depend on different versions of Camel, then OSGi supports this as long as install the necessary camel bundle versions and setup your applicaiton bundle manifests correctly, etc.
Reinstalling (or rather, recreating the instance) helped.

Datanucleus using wrong enhancer in Google App Engine 1.7

I'm having difficulty in getting Datanucleus 2 to work properly with enhancing classes on GAE 1.7.0 in Eclipse using the Datanucleus plugin. This worked fine in older versions of GAE when I'd follow the manual steps here:
http://www.datanucleus.org/products/accessplatform/guides/eclipse/index.html
But since upgrading, GAE now includes these libs (newer versions of them it looks like), and also GAE has a new "enhancer" flag you can set. I can't find anyway to set this flag in Eclipse though. It appears that GAE is still including the v1 libs when I want the V2 libs and Datanucleus is having conflicts according to this error:
Jul 1, 2012 5:59:55 PM org.datanucleus.enhancer.DataNucleusEnhancer <init>
INFO: DataNucleus Enhancer : Using ClassEnhancer "ASM" for API "JPA"
Exception in thread "main" java.lang.NoSuchFieldError: NUCLEUS_CONTEXT_LOADER
at org.datanucleus.NucleusContext.<clinit>(NucleusContext.java:73)
at org.datanucleus.enhancer.DataNucleusEnhancer.<init>(DataNucleusEnhancer.java:171)
at org.datanucleus.enhancer.DataNucleusEnhancer.main(DataNucleusEnhancer.java:1265)
I've tried many different things. I've tried using all the defaults. I've tried adding the v2 libs to the Datanucleus runtime Classpath Entries. I've tried deleting the v1 libs in the GAE 1.7.0 SDK in both the src and libs. But somehow GAE is still pulling over (or trying to pull over the V1 libs. I've even tried the older method of manually setting up the configuration as specified by the link above. It's a little frustrating as it seems like I'm now in a situation where I can't use these libs at all. At least with older versions of GAE I could manually set it up to work. Nothing seems to work now. Any suggestions?
I hit this same error and was able to resolve it in my project by:
Doing what DavidB suggested in the comments, without modifying the DataNucleus JPA settings in the preferences.
Deleting all of the "V1" jars from the war/WEB-INF/lib
To clarify DavidB's suggestion, open the directory that holds your project. There will be a folder named ".settings", open this and edit com.google.appengine.eclipse.core.prefs. Just change the third line from gaeDatanucleusVersion=v1 to gaeDatanucleusVersion=v2
Once you have done this, remove the following jars from you war/WEB-INF/lib directory:
datanucleus-appengine-1.0.10.final.jar
datanucleus-core-1.1.5.jar
datanucleus-jpa-1.1.5.jar
geronimo-jpa_3.0_spec-1.1.1.jar
geronimo-jta_1.1_spec-1.1.1.jar
jdo2-api-2.3-eb.jar
Restart eclipse and you should be good to go.

Google App Engine .jsp Problem

I just created a .jsp file in my google app engine project. How to resolve the below error.
Description Resource Path Location Type
Your project must be configured to use a JDK in order to use JSPs
proj1.jsp
/Proj1/war Unknown Google App Engine Problem
Kindly let me know.
it is the error. In order to compile jsp you need a jdk installed in your system. If you are running on a JRE you will get this error. Also make sure that your project has been configured with a jdk in it's path.
For sake of improving answers
stack over flow reference
.jsp file not working for Google App Engine guestbook tutorial
the accepted answer was a year ago
updated answer from reference
In the end I seem to have wasted my bounty as I found the solution (with a little help) myself.
The problem arose because I was unfamiliar with Eclipse. When I found the more verbose error message Your project must be configured to use a JDK in order to use JSPs guestbook.jsp.
It was located in a tab called 'Markers' in pane found at the bottom of the Eclipse window.
It seems that Eclipse wasn't aware that I had installed the JDK.
In Eclipse I went to menu Window->Preferences->Java->Installed JREs . Eclipse had only one entry there named jre6 I clicked the Add... button Chose Standard VM and browsed to the base directory of the jdk (in my case C:\Program Files\Java\jdk1.6.0_20)
I rebuilt my project but the same error was there. I had forgotten to check the box that tells Eclipse to use the jdk instead of the jre.
As soon as I did that Eclipse rebuilt my project and the error was gone.
To solve this problem, first please confirm that JDK is already install on your computer. If it not available, go to Oracle JDK hompage to download and install it.
Then follow some steps to config JDK.
When JDK is configured, return eclipse and build project if you still get current error, I decide you are using JRE instead JDK. Choose Prefrences - Java - Install JRE - Un-check JRE and check JDK
Rebuild project
Hope this help!
Set JDK as your Installed JREs in Eclipse.
In Eclipse Window->Preference->Java->Installed JREs
Click on Add Button | Select VM ->Add JRE
Select Folder of jdk as "JRE Home" Directory.
Click OK.
Build your GAE Project
JFTR:
For those who use Ubuntu and OpenJDK, and may come here looking for help on the same issue: EVEN when it is called Open*JDK* (i.e. java-6-openjdk) actually you may have installed only the JRE part since they are on different packages, so you need to install also the JDK. For version 6 this is done via:
$ sudo apt-get install openjdk-6-jdk
Note that you may have yet an openjdk-6-jre in your system.
If your problem persist, you must sure that in your project use JDK library. Go to your project->click right->Build Path->Configure Build Path->Add library->JRE System Library->Select "Workspace default JRE (jdk1...)"->Finish, and in "Order and Export" UP your JDK Library above JRE Library. When you save your proyect it´s ok.

Apache Camel route as a Windows Service

I have a Apache Camel route that is exported as a runnable jar file from eclipse. I use a simple bat file to run this route...
C:\PROGRA~1\Java\jre6\bin\java -jar C:\dev\_exports\mdt\cpnnectors_v1.jar
How can I run this as a window service instead with the output from the console to a log file?
I think there are some general windows tools you can use to turn Java apps into services. And I vaugely recall something added to the JDK6 or 7 to support that natively. Anyway try to google a bit.
Tanuki has been around for a long time and they offer such a tool
http://wrapper.tanukisoftware.com/doc/english/download.jsp
I know it is a bit of a late answer but I have managed to deploy my Camel Routes to Apache Karaf and Karaf comes with a service wrapper for both for windows and a deamon wrapper for linux. Basically I know have my Camel routes deployed to Karaf and it is running as a service on windows with really minor hassle.
Karaf is easy to install and the help file also show you how to install the wrapper.

Resources