Announcement Announcement Module
Collapse
No announcement yet.
Problems accessing xml properties files via XmlBeanFactory Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problems accessing xml properties files via XmlBeanFactory

    Hi,

    I am having trouble accessing xml properties files via XmlBeanFactory. Here is the code snip it I am using:
    Code:
    FileSystemResource resource = new FileSystemResource("customer.xml");
    XmlBeanFactory factory = new XmlBeanFactory(resource);
    my customer.xml is located in my classes dir.

    I get the following error:

    Code:
    [java] javax.xml.parsers.FactoryConfigurationError: Provider com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl could not be instantiated: java.lang.NullPointerException
            [java] 	at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:172)
            [java] 	at org.apache.tools.ant.taskdefs.Java.run(Java.java:705)
            [java] 	at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:177)
            [java] 	at org.apache.tools.ant.taskdefs.Java.execute(Java.java:83)
            [java] 	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
            [java] 	at org.apache.tools.ant.Task.perform(Task.java:364)
            [java] 	at org.apache.tools.ant.Target.execute(Target.java:341)
            [java] 	at org.apache.tools.ant.Target.performTasks(Target.java:369)
            [java] 	at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
            [java] 	at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRunner.java:635)
            [java] 	at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRunner.java:412)
            [java] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            [java] 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
            [java] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            [java] 	at java.lang.reflect.Method.invoke(Unknown Source)
            [java] 	at org.eclipse.ant.core.AntRunner.run(AntRunner.java:350)
            [java] 	at org.eclipse.ant.internal.ui.launchConfigurations.AntLaunchDelegate$1.run(AntLaunchDelegate.java:182)
            [java] 	at java.lang.Thread.run(Unknown Source)
            [java] Caused by: javax.xml.parsers.FactoryConfigurationError: Provider com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl could not be instantiated: java.lang.NullPointerException
            [java] 	at javax.xml.parsers.DocumentBuilderFactory.newInstance(Unknown Source)
            [java] 	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:134)
            &#91;java&#93; 	at org.springframework.beans.factory.xml.XmlBeanFactory.<init>&#40;XmlBeanFactory.java&#58;68&#41;
            &#91;java&#93; 	at org.springframework.beans.factory.xml.XmlBeanFactory.<init>&#40;XmlBeanFactory.java&#58;56&#41;
            &#91;java&#93; 	at com.pouncilt.test.customer.CustomerApp.getBeanFactory&#40;Unknown Source&#41;
            &#91;java&#93; 	at com.pouncilt.test.customer.CustomerApp.main&#40;Unknown Source&#41;
            &#91;java&#93; 	at sun.reflect.NativeMethodAccessorImpl.invoke0&#40;Native Method&#41;
            &#91;java&#93; 	at sun.reflect.NativeMethodAccessorImpl.invoke&#40;Unknown Source&#41;
            &#91;java&#93; 	at sun.reflect.DelegatingMethodAccessorImpl.invoke&#40;Unknown Source&#41;
            &#91;java&#93; 	at java.lang.reflect.Method.invoke&#40;Unknown Source&#41;
            &#91;java&#93; 	at org.apache.tools.ant.taskdefs.ExecuteJava.run&#40;ExecuteJava.java&#58;193&#41;
            &#91;java&#93; 	at org.apache.tools.ant.taskdefs.ExecuteJava.execute&#40;ExecuteJava.java&#58;130&#41;
            &#91;java&#93; 	... 17 more
            &#91;java&#93; --- Nested Exception ---
            &#91;java&#93; javax.xml.parsers.FactoryConfigurationError&#58; Provider com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl could not be instantiated&#58; java.lang.NullPointerException
            &#91;java&#93; 	at javax.xml.parsers.DocumentBuilderFactory.newInstance&#40;Unknown Source&#41;
            &#91;java&#93; 	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions&#40;XmlBeanDefinitionReader.java&#58;134&#41;
            &#91;java&#93; 	at org.springframework.beans.factory.xml.XmlBeanFactory.<init>&#40;XmlBeanFactory.java&#58;68&#41;
            &#91;java&#93; 	at org.springframework.beans.factory.xml.XmlBeanFactory.<init>&#40;XmlBeanFactory.java&#58;56&#41;
            &#91;java&#93; 	at com.pouncilt.test.customer.CustomerApp.getBeanFactory&#40;Unknown Source&#41;
            &#91;java&#93; 	at com.pouncilt.test.customer.CustomerApp.main&#40;Unknown Source&#41;
            &#91;java&#93; 	at sun.reflect.NativeMethodAccessorImpl.invoke0&#40;Native Method&#41;
            &#91;java&#93; 	at sun.reflect.NativeMethodAccessorImpl.invoke&#40;Unknown Source&#41;
            &#91;java&#93; 	at sun.reflect.DelegatingMethodAccessorImpl.invoke&#40;Unknown Source&#41;
            &#91;java&#93; 	at java.lang.reflect.Method.invoke&#40;Unknown Source&#41;
            &#91;java&#93; 	at org.apache.tools.ant.taskdefs.ExecuteJava.run&#40;ExecuteJava.java&#58;193&#41;
            &#91;java&#93; 	at org.apache.tools.ant.taskdefs.ExecuteJava.execute&#40;ExecuteJava.java&#58;130&#41;
            &#91;java&#93; 	at org.apache.tools.ant.taskdefs.Java.run&#40;Java.java&#58;705&#41;
            &#91;java&#93; 	at org.apache.tools.ant.taskdefs.Java.executeJava&#40;Java.java&#58;177&#41;
            &#91;java&#93; 	at org.apache.tools.ant.taskdefs.Java.execute&#40;Java.java&#58;83&#41;
            &#91;java&#93; 	at org.apache.tools.ant.UnknownElement.execute&#40;UnknownElement.java&#58;275&#41;
            &#91;java&#93; 	at org.apache.tools.ant.Task.perform&#40;Task.java&#58;364&#41;
            &#91;java&#93; 	at org.apache.tools.ant.Target.execute&#40;Target.java&#58;341&#41;
            &#91;java&#93; 	at org.apache.tools.ant.Target.performTasks&#40;Target.java&#58;369&#41;
            &#91;java&#93; 	at org.apache.tools.ant.Project.executeTarget&#40;Project.java&#58;1214&#41;
            &#91;java&#93; 	at org.eclipse.ant.internal.core.ant.InternalAntRunner.run&#40;InternalAntRunner.java&#58;635&#41;
            &#91;java&#93; 	at org.eclipse.ant.internal.core.ant.InternalAntRunner.run&#40;InternalAntRunner.java&#58;412&#41;
            &#91;java&#93; 	at sun.reflect.NativeMethodAccessorImpl.invoke0&#40;Native Method&#41;
            &#91;java&#93; 	at sun.reflect.NativeMethodAccessorImpl.invoke&#40;Unknown Source&#41;
            &#91;java&#93; 	at sun.reflect.DelegatingMethodAccessorImpl.invoke&#40;Unknown Source&#41;
            &#91;java&#93; 	at java.lang.reflect.Method.invoke&#40;Unknown Source&#41;
            &#91;java&#93; 	at org.eclipse.ant.core.AntRunner.run&#40;AntRunner.java&#58;350&#41;
            &#91;java&#93; 	at org.eclipse.ant.internal.ui.launchConfigurations.AntLaunchDelegate$1.run&#40;AntLaunchDelegate.java&#58;182&#41;
            &#91;java&#93; 	at java.lang.Thread.run&#40;Unknown Source&#41;

    I thank you in advance.

    Thanks!

  • #2
    The JAXP XML parsing library is wrongly configured somehow. Spring is trying, and failing, to use the standard DOM API. Spring isn't doing anything special: any XML parsing using the standard APIs would fail.

    The best place to search would be for the Eclipse/Ant integration. Could be to do with Eclipse class loading.

    Comment


    • #3
      How do I do that

      How do I load the Eclipse Ant classes files? I am guessing but I guess I should just add the jars to my classpath?

      Is this correct?

      Thanks!

      Comment


      • #4
        I got it working!

        I got it working... I didn't have all of the JAXP jar file in my class path.

        Thanks so much!

        Comment

        Working...
        X