3

My context :

  • BND (bndtools with Eclipse IDE) ;

  • OSGI (-runfw: org.eclipse.osgi;version='[3.16.100.v20201030-1916,3.16.200.v20210226-1447]') ;

  • runee: JavaSE-1.8

  • in bnd.launch file :

-runbundles: \
  org.apache.felix.gogo.command;version='[1.1.2,1.1.3)',\
  org.apache.felix.gogo.runtime;version='[1.1.4,1.1.5)',\
  org.apache.felix.gogo.shell;version='[1.1.4,1.1.5)',\
  org.apache.commons.commons-fileupload;version='[1.4.0,1.4.1)',\
  org.apache.commons.commons-io;version='[2.8.0,2.8.1)',\
  org.apache.felix.webconsole;version='[4.6.0,4.6.1)',\
  org.apache.felix.http.jetty;version='[4.1.6,4.1.7)',\
  org.apache.felix.http.servlet-api;version='[1.1.2,1.1.3)',\
  org.apache.felix.scr;version='[2.1.24,2.1.25)',\
  org.eclipse.equinox.cm;version='[1.5.0,1.5.1)',\
  org.eclipse.equinox.console;version='[1.4.300,1.4.301)',\
  org.eclipse.equinox.device;version='[1.1.100,1.1.101)',\
  org.eclipse.osgi.services;version='[3.10.0,3.10.1)',\
  org.eclipse.osgi.util;version='[3.6.0,3.6.1)',\
  ch.qos.logback.classic;version='[1.2.3,1.2.4)',\
  ch.qos.logback.core;version='[1.2.3,1.2.4)',\
  org.apache.felix.logback;version='[1.0.2,1.0.3)',\
  slf4j.api;version='[1.7.30,1.7.31)',\
  com.sun.activation.jakarta.activation;version='[2.0.1,2.0.2)',\
  jakarta.xml.bind-api;version='[3.0.1,3.0.2)',\
  com.sun.xml.bind.jaxb-osgi;version='[3.0.1,3.0.2)'
  • No use of any POM.xml file at all

When I launch the application, I get a

jakarta.xml.bind.JAXBException: Implementation of Jakarta XML Binding-API has not been found on module path or classpath.
 - with linked exception:
[java.lang.ClassNotFoundException: org.glassfish.jaxb.runtime.v2.ContextFactory]
  at jakarta.xml.bind.ContextFinder.newInstance(ContextFinder.java:255)
  at jakarta.xml.bind.ContextFinder.newInstance(ContextFinder.java:243)
  at jakarta.xml.bind.ContextFinder.find(ContextFinder.java:407)
  at jakarta.xml.bind.JAXBContext.newInstance(JAXBContext.java:691)
  at jakarta.xml.bind.JAXBContext.newInstance(JAXBContext.java:632)

If I add org.glassfish.jaxb.runtime;version='[3.0.1,3.0.2)' to the runbundles list, it doesn't change anything (same exception). Then if I add -runpath: org.glassfish.jaxb.runtime;version='[3.0.1,3.0.2)' to the bnd.launch file : it doesn't change anything either (same exception).

What did I did wrong ?? Thanks

Lbro
  • 309
  • 2
  • 16
  • I should have read more carefully jaxb site. I run java 8 so jaxb is in rt.jar ; I just have to import javax.xml.xxxx (no jakarta.xml.xxx) in my code and withdraw all reference to any jakarta.xml.xxx in my bnd.launch :( And it works. Sorry for the noise. – Lbro May 05 '21 at 07:41

1 Answers1

0

Are you running on Java 1.9 or later? (The error message talks about module path.) The problem might be that JAXB is no longer exported from the JVM in later versions. This will the class loading of glassfish to fail without telling the underlying reason sometimes.

You can add -runvm -v:class to get more information about the class loading.

Peter Kriens
  • 15,196
  • 1
  • 37
  • 55
  • Thanks for the advice :) I should have read more carefully jaxb site. I run java 8 so jaxb is in rt.jar ; I just have to import javax.xml.xxxx (no jakarta.xml.xxx) in my code and withdraw all reference to any jakarta.xml.xxx in my bnd.launch :( And it works. Sorry for the noise. – Lbro May 05 '21 at 07:35
  • BTW I have a `Unrecognized option: -v:class Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit. ` – Lbro May 05 '21 at 07:43
  • Its -verbose:class – Peter Kriens May 11 '21 at 06:34