2

I have problems with a webservice/OSGi application that is bundled as WAR under JBoss 7.

My questions are:

  1. What modules are available to the application by default? I know how to add a dependeny and how to exclude one. But how do I know the defaults? I think they are called "global modules".
  2. Which packages of the JDK are provided to the application by default? All? Some? How do I investigate this?
  3. By concrete error is the following. Some bootstrapping code calls javax.xml.parsers.DocumentBuilderFactory.newInstance(). Which results in the exception javax.xml.parsers.FactoryConfigurationError: Provider __redirected.__DocumentBuilderFactory not found. It seems as in JBoss the system property javax.xml.parsers.DocumentBuilderFactory points to the above strange implementation __redirected.__DocumentBuilderFactory.

Thanks for your help!

3 Answers3

1

Answering my own question:

  1. Modules added implicitly are described in detail in the JBoss documentation found here: https://docs.jboss.org/author/display/AS7/Implicit+module+dependencies+for+deployments. As the other answer already states, dependencies can be suppressed by declaring excludes in the jboss-deployment-structure.xml.

  2. See answer above

  3. The application deployed to JBoss is a WAR file that itself bootstraps an OSGi container. Inside the container Gemini Blueprint is used to manage OSGi service dependencies. Gemini Blueprint searches for Spring Application Context files and starts a Spring context for the bundle if found. Parsing the XML file failed with the exception stated above. The reason was that the package __redirected was not avaiable to the bundle. I managed this via boot delegation.

    # In JBoss some JDK classes like "javax.xml.parsers.DocumentBuilderFactory" are redirected to a JBoss package "__redirected" via a system property
    # The corresponding implementation "__redirected/__DocumentBuilderFactory" is made accessible from all bundles via "boot delegation" 
    org.osgi.framework.bootdelegation = __redirected
    # Sets the parent classloader to the one that loads the framework. It must have access to the bootdelegation pakages, e. g. "__redirected"
    org.osgi.framework.bundle.parent = framework
    
  • how do you know gemini blueprint is being used? I don't see anything about that in OP – eis Jan 13 '14 at 17:30
0
  1. You can check the admin console / OSGi tab to see what are available for you on runtime. "By default" depends on your startup configuration, there are 4 alternative startup profiles that you can use IIRC.

  2. Check $JBOSS/modules/sun/jdk/main/module.xml to see which packages are imported and which not. Only some of them are. Others you need to add manually by using jboss-deployment-structure or modifying sun.jdk module.xml file if you need them. There are other automatic dependencies in addition to JDK, which are listed on this page.

  3. You'll need to provide more details to answer this, including your dependencies. Xerces parser is a big headache for a modular classloader.

eis
  • 51,991
  • 13
  • 150
  • 199
0

The problem is the using of the method setContextClassLoader. This override the classloder which can load the DocumentBuilderFactory. A workaround is to use OrderClassLoaders.

Thread currentThread = Thread.currentThread();
ClassLoader originalCl = currentThread.getContextClassLoader();
currentThread.setContextClassLoader( new OrderClassLoaders( myCl, originalCl ) );
Horcrux7
  • 23,758
  • 21
  • 98
  • 156