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

  • Hibernate javax/xml/parsers/ParserConfigurationException

    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>(
    at org.springframework.beans.factory.xml.XmlBeanFacto ry.<init>(
    at com.service.ClaimFinancialApplicationContext.confi gure(
    at com.dataaccess.bean.test.InsertTest.setUp(InsertTe
    at junit.framework.TestCase.runBare( )
    at junit.framework.TestResult$1.protect(TestResult.ja va:106)
    at junit.framework.TestResult.runProtected(TestResult .java:124)
    at )
    at junit.framework.TestSuite.runTest( 73)
    at junit.framework.TestSuite.runTest( 73)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(

    Conf file:
    <?xml version="1.0"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "">

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

    <bean id="claimFinancialSessionFactory" class="org.springframework.orm.hibernate.LocalSess ionFactoryBean">
    <property name="hibernateProperties">
    <!-- 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"></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>

    <property name="mappingResources">

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

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

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


    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.



    • #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


      • #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



        • #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.