Announcement Announcement Module
Collapse
No announcement yet.
JPA Integration Testing w/ Maven: StackOverflowError Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JPA Integration Testing w/ Maven: StackOverflowError

    I'm trying to add integration tests to my Maven build. I'm using Maven, Spring 2.0. (I just tried moving to 2.0.2, but got an XML parse error from my applicationContext.xml file.), and Hibernate as a JPA provider.

    I have tied tests to the integration-test life cycle in Maven. I have a test that attempts to instantiate an ApplicationContext, but it fails when attempting to start my entityManager with a StackOverflowException:

    Code:
     Error creating bean with name 'entityManagerFactory' defined in URL [file:/Users/mark/projects/quadran/target/classes/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.StackOverflowError
    Caused by: java.lang.StackOverflowError
        at java.lang.String.toLowerCase(String.java:2213)
        at java.lang.String.toLowerCase(String.java:2277)
        at org.apache.xerces.util.URI.setScheme(URI.java:908)
        at org.apache.xerces.util.URI.initializeScheme(URI.java:576)
        at org.apache.xerces.util.URI.initialize(URI.java:400)
        at org.apache.xerces.util.URI.<init>(URI.java:211)
        at org.apache.xerces.util.URI.<init>(URI.java:195)
        at org.apache.xerces.impl.XMLEntityManager.expandSystemId(XMLEntityManager.java:1140)
        at org.apache.xerces.impl.XMLEntityManager.resolveEntity(XMLEntityManager.java:581)
        at org.apache.xerces.impl.xs.XMLSchemaLoader.xsdToXMLInputSource(XMLSchemaLoader.java:625)  
        at org.apache.xerces.impl.xs.XMLSchemaLoader.processJAXPSchemaSource(XMLSchemaLoader.java:580)
        at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:489)
        at org.apache.xerces.impl.xs.XMLSchemaLoader.processJAXPSchemaSource(XMLSchemaLoader.java:588)
        at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:489)
        at org.apache.xerces.impl.xs.XMLSchemaLoader.processJAXPSchemaSource(XMLSchemaLoader.java:588)
    
    these last two lines repeat for a long time.
    It looks to me like it can't parse the persistence.xml file. I've tried adding a xerces dependency and changing it to various different versions to see if that would clear up the problem. Then tried setting xerces to scope=test. None of which worked.

    Any ideas you might have would be appreciated.

    Mark

  • #2
    Get a newer Xerces

    This is a known bug in Xerces 2.0.2, which Maven2 includes automatically via some transitive dependency that I didn't track down. You can work around it by explicitly requiring a newer version, e.g.:

    Code:
    <dependency>
    	<groupId>xerces</groupId>
    	<artifactId>xercesImpl</artifactId>
    	<version>2.8.1</version>
    </dependency>
    (See also http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16014)

    Comment


    • #3
      Thank you. Thank you. Thank you.

      You dug a ways back to find this post. You're advice worked and now my context starts, initializes and loads my JPA persistence context and I can run my integration tests.

      Mark

      Comment


      • #4
        Hi guys,
        I was very happy to find this post. The manifestation matches my problem exactly. StackOverflow with jpa while trying to read persistence.xml. Only trouble is, I'm not using Spring so I don't know how to fix it.

        I'm trying my first gwt application using jpa on the server. Compiling with my own ant script via Netbeans5.5 and then running with java1.6, source level 1.5, using toplink essentials for persistence provider. Netbeans seems to have xerces2.8 in ide7/modules directory. Netbeans will run other projects using its own ant script (with the same persistence.xml). Yet I still get the StackOverflowError while trying to create an EntityManagerFactory.

        Anyone any idea where I should look for a bad xerces??

        regards

        Dukha

        Comment


        • #5
          Stackoverflwo with Xerces

          Hi guys,
          I was very happy to find this post. The manifestation matches my problem exactly. StackOverflow with jpa while trying to read persistence.xml. Only trouble is, I'm not using Spring so I don't know how to fix it.

          I'm trying my first gwt application using jpa on the server. Compiling with my own ant script via Netbeans5.5 and then running with java1.6, source level 1.5, using toplink essentials for persistence provider. Netbeans seems to have xerces2.8 in ide7/modules directory. Netbeans will run other projects using its own ant script (with the same persistence.xml). Yet I still get the StackOverflowError while trying to create an EntityManagerFactory.

          Anyone any idea where I should look for a bad xerces??

          regards

          Dukha

          Comment


          • #6
            This problem specifically talked about Maven, if you are using it then I would guess the exist answer should tell you. If not then just check the classpath of the application. The lib directory is usually a good starting point.
            Last edited by karldmoore; Aug 29th, 2007, 12:15 PM.

            Comment


            • #7
              Thanks for the help, Karl.
              I'm looking at the same Stackoverflow as wtih Maven but the source is probably different. It looks as if Google are using the same old Xerces version packaged in gwt 1.3 (the latest!). I'm going further with a work around using
              Code:
              -Djava.endorsed.dirs
              and
              Code:
              -javaagent:
              as args in the call to java.
              I'll post again if it works.

              dukha

              Comment


              • #8
                gwt and xerces

                The problem appears to be solved but not as I proposed above.

                Indeed it is so that gwt 1.3.3 (released Feb07) uses a version of Xerces from 2002. I. expanded gwt-dev-linux.jar to a directory, expanded xerces 2.9 to a dir and hand copied from xerces to gwt.

                Thanks Google! I hope I don't find out the reason for such weirdness further down the track.

                regards

                dukha

                Comment


                • #9
                  Originally posted by dukha View Post

                  Anyone any idea where I should look for a bad xerces??
                  I had a similar problem with Castor 1.1.1 which has a dependency on xerces 1.4.0, which, by the way, is incompatible with xsd schemas !

                  In that case, specifying explicitely a newer version of xerces won't work because xerces has been relocated to xercesimpl. The lightest solution I found was to edit the castor pom in my local repository and make it dependant upon xercesimpl 2.8.1 instead of xerces 1.4.0.

                  The main problem is that the project is no more portable. Can anyone think about a portable solution to this problem ?

                  Comment


                  • #10
                    Giving up for now

                    Hi volga,
                    I've given up for now and wait until GWT supports Java 1.5

                    dukha

                    Comment


                    • #11
                      It was happening with me too, but I perceived that both librarys was being used by maven. It was happening because two of my libraries has a dependency to this version of xerces. Im my case the problematic libraries was commons-pool and commons-dbcp.
                      To solve the problem I changed the version of commons-pool to another more new that donīt have this dependency and I have to make a little change in the pom of commons-dbcp and put the dependecy to xerces as optional. I know that it is a very durty solution, but i actualy need to use these libraries. If somebody knows another solution I will be very apreciate.
                      Thanks

                      Comment

                      Working...
                      X