Announcement Announcement Module
Collapse
No announcement yet.
Hibernate javax/xml/parsers/ParserConfigurationException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hibernate javax/xml/parsers/ParserConfigurationException

    Hi
    When I run this code from my JUnit I get a weird error
    System.out.println(new ClassPathResource("ClaimFinancialHibernateConfigur ation.xml").exists());
    beanFactory = new XmlBeanFactory(new ClassPathResource("ClaimFinancialHibernateConfigur ation.xml"));
    System.out.println gives me true but still it gives me NoClassDefError
    for second line
    Conf file is also attached below


    java.lang.NoClassDefFoundError: javax/xml/parsers/ParserConfigurationException
    at org.springframework.beans.factory.xml.XmlBeanFacto ry.<init>(XmlBeanFactory.java:48)
    at org.springframework.beans.factory.xml.XmlBeanFacto ry.<init>(XmlBeanFactory.java:57)
    at com.service.ClaimFinancialApplicationContext.confi gure(ClaimFinancialApplicationContext.java:37)
    at com.dataaccess.bean.test.InsertTest.setUp(InsertTe st.java:43)
    at junit.framework.TestCase.runBare(TestCase.java:138 )
    at junit.framework.TestResult$1.protect(TestResult.ja va:106)
    at junit.framework.TestResult.runProtected(TestResult .java:124)
    at junit.framework.TestResult.run(TestResult.java:109 )
    at junit.framework.TestCase.run(TestCase.java:131)
    at junit.framework.TestSuite.runTest(TestSuite.java:1 73)
    at junit.framework.TestSuite.run(TestSuite.java:168)
    at junit.framework.TestSuite.runTest(TestSuite.java:1 73)
    at junit.framework.TestSuite.run(TestSuite.java:168)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:329)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:218)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:151)


    Conf file:
    <?xml version="1.0"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

    <beans>
    <bean id="config" class="com.service.ClaimFinancialApplicationContex t" singleton="true">
    </bean>

    <bean id="claimFinancialSessionFactory" class="org.springframework.orm.hibernate.LocalSess ionFactoryBean">
    <property name="hibernateProperties">
    <props>
    <!-- Database Settings -->
    <prop key="hibernate.default_schema">T321DBA</prop>
    <prop key="hibernate.dialect">net.sf.hibernate.dialect.D B2390Dialect</prop>
    <!-- Set the property to display all the generated sql. Caution, setting to
    true will produce large numbers of log statements -->
    <prop key="hibernate.connection.driver_class">COM.ibm.db 2.jdbc.app.DB2Driver</prop>
    <prop key="hibernate.connection.username">abc</prop>
    <prop key="hibernate.connection.password">abc</prop>
    <prop key="hibernate.connection.url">jdbc:db2B2T301</prop>

    <prop key="hibernate.show_sql">true</prop>
    <prop key="hibernate.query.substitutions">0</prop>

    <!-- JDBC Settings -->
    <prop key="hibernate.jdbc.use_streams_for_binary">true</prop>
    <prop key="hibernate.max_fetch_depth">1</prop>
    <prop key="hibernate.use_outer_join">true</prop>
    <!-- Cache settings -->
    <prop key="hibernate.cache.provider_class">net.sf.hibern ate.cache.HashtableCacheProvider</prop>
    </props>
    </property>

    <property name="mappingResources">
    <list>
    <value>com/dataaccess/hibernate/mapping/PaymentDataBean.hbm.xml</value>
    </list>
    </property>
    </bean>

    <!--Transaction manager -->
    <bean id="transactionManager" class="org.springframework.orm.hibernate.Hibernate TransactionManager">
    <property name="sessionFactory">
    <ref local="claimFinancialSessionFactory" />
    </property>
    </bean>

    <bean id="dataAccessServiceBean" class="com.dataaccess.hibernate.persistence.Hibern atePersistImpl">
    <property name="sessionFactory">
    <ref bean="claimFinancialSessionFactory"/>
    </property>
    </bean>

    <bean id="paymentPersistenceLookup" class="com.dataaccess.hibernate.persistence.Paymen tPersistenceLookup">
    <property name="dataAccessService">
    <ref bean="dataAccessServiceBean"/>
    </property>
    <property name="transactionManager">
    <ref bean="transactionManager"/>
    </property>
    </bean>

    </beans>


    Help needed urjently
    Thanks in advance

  • #2
    It looks like a simple lack of xml parser in your classpath.
    Can you tell us more about the jdk used when running junit and eventually if you run code correctly in an app server ?
    It may be a simple lack of xml-api.jar and an xml implementation when running in bare j2se 1.3.

    Olivier

    Comment


    • #3
      I am running the code from WSAD 5.0 having JDK 1.3
      I do have dom4j in my classpath. I do not know if any other jar is required for parsing

      Comment


      • #4
        Yes, dom4j is just a hi level xml manipulation api. It relies on low level support (namely jaxp and such from memory) which are provided via xml-apis.jar (the specification of xml services in java) and an implementation, like xercesImplxxx.jar or crimson.jar. Those jar are bundled in the application server but if you're running junit in a standalone way. they're not in the classpath, you have to manually had those. As a note, in jdk 1.4+, those jar are part of the basic runtime.

        Hope it helps

        Olivier

        Comment


        • #5
          Hi Friend,
          I got the solution, Actually it was missing xmlParserAPIs.jar which was having implementation for the exception i was finding for.
          Thanks for your effort.

          Comment

          Working...
          X