users@glassfish.java.net

Re: XPathFactory error with Glassfish

From: Sahoo <sanjeeb.sahoo_at_oracle.com>
Date: Sat, 18 Feb 2012 06:57:36 +0530

Set a system property called jaxp.debug to something so that jaxp will
print debug information which will help finding out what's going on.
But, I am pretty sure it is one of those ServiceLocator issues [1]. JAXB
has adopted our solution, but JAXP has not. So, what you may like to do is:

Thread.currentThread().setContextClassLoader(XPathFactory.class.getClassLoader());
try {
     XPathFactory.newInstance();
} finally{
  Thread.currentThread().setContextClassLoader(oldValue);
}

Let me know if this works.

Sahoo

[1] https://wikis.oracle.com/display/GlassFish/JdkSpiOsgi


On Saturday 18 February 2012 02:16 AM, forums_at_java.net wrote:
> I'm unable to use XPathFactory/classes with Glassfish. I get the
> following
> error:
>
> java.lang.RuntimeException: XPathFactory#newInstance() failed to
> create an
> XPathFactory for the default object model:
> http://java.sun.com/jaxp/xpath/dom
> with the XPathFactoryConfigurationException:
> javax.xml.xpath.XPathFactoryConfigurationException: No XPathFactory
> implementation found for the object model:
> http://java.sun.com/jaxp/xpath/dom
> at javax.xml.xpath.XPathFactory.newInstance(XPathFactory.java:101)
>
> This is in a fresh install of Glassfish 3.1.1 (Build 12). From what
> I've read
> around this is a class conflict somewhere, but I have no idea where to
> start
> looking.
>
> I'm testing with a very simple bundle that just has this activator:
>
> package com.spectron.xpath.test_xpath;
> import javax.xml.xpath.XPath;
> import javax.xml.xpath.XPathFactory;
> import org.osgi.framework.BundleActivator;
> import org.osgi.framework.BundleContext;
> public class Activator implements BundleActivator {
> public void start(BundleContext context) throws Exception {
> XPath p=XPathFactory.newInstance().newXPath();
> }
> public void stop(BundleContext context) throws Exception {
> }
> }
>
>
>
>
> --
>
> [Message sent by forum member 'fawzib']
>
> View Post: http://forums.java.net/node/883618
>
>