cancel
Showing results for 
Search instead for 
Did you mean: 

Spring & Hibernate: Could not parse mapping document from input stream

Former Member
0 Kudos

Hi,

While deploying an ejb project (via a SAP EAR file), everything is deployed.

Upon the ejb receiving a message from a jms queue, the relevant ejbCreate method is called, and in turn it calls various spring methods and initialises other beans required in the project.

However, i seem to be greeted with this error:

Cannot resolve reference to bean 'hibernateSessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateSessionFactory' defined in class path resource dts-application-context.xml: Invocation of init method failed; nested exception is org.hibernate.InvalidMappingException: Could not parse mapping document from input stream

I would have thought that this would have been followed by the filename that could not be parsed....

Anyone ever come across this before?

Regards,

Andrew

Edited by: Andrew Morton on Feb 15, 2008 2:46 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi!

Have you got this application running on another AppServer like JBoss or Glassfish? The filename you mentioned is only listed if Hibernate tries to load the mapping-file from a resource. In your case Hibernate tries to read from an input stream.

Best Regards,

Robin

Former Member
0 Kudos

Hi,

This application runs on Sun App Server no problem.

The only thing that has been changed is the ear file in which it is deployed, and the fact that the libraries it uses are deployed with it - in the Sun app version we were able to place the jars in the file system to be loaded from there.

I take it that it is saying this as it is reading the files (or attempting to) from the ejb jar file, and not anywhere the file system.

Regards,

Andrew

Edited by: Andrew Morton on Feb 15, 2008 3:26 PM

Former Member
0 Kudos

Hi Andrew!

Could you please sketch the structure of your EAR-file? It could be that the ClassLoader that loads Hibernate is not able to see classes and resources of your application. You could try to keep only the ANTLR jar-file in the lib-folder of your EAR and all other jar-files into the root-folder of your EAR. Maybe it could look like this:

yourApplication.ear/lib/antlr.jar

yourApplication.ear/hibernate.jar

yourApplication.ear/spring.jar

...

yourApplication.ear/yourEJB.jar

Best Regards,

Robin

Former Member
0 Kudos

Robin,

The ear file was created by adding all libraries and the ejb jar as j2ee module dependancies.

The layout is as follows:

myApp.ear/<libjars>

myApp.ear/<ejbjar>

myApp.ear/META-INF/jms-resources.xml

myApp.ear/META-INF/data-sources.xml

myApp.ear/META-INF/application-j2ee-engine.xml

I am going to try and deploy it with the antlr jar in the lib folder.

(Update: Tried that, but the build procedure just put the antlr jar in the root of the ear with all the other jars...)

Regards,

Andrew

Edited by: Andrew Morton on Feb 15, 2008 4:13 PM

Edited by: Andrew Morton on Feb 15, 2008 4:20 PM

Former Member
0 Kudos

Hi!

What do you use for packaging your application? If it is some OS tool like ANT or Maven your buildfile would be of interest. BTW: I will be out of office this week and probably won't be able to have a look at the forum.

Best Regards,

Robin

Former Member
0 Kudos

Hi Robin,

We use jDeveloper to package the application.

Regards,

Andrew

Former Member
0 Kudos

Some further info.

I have turned on spring and hibernate to debug level to see what was going on.

It seems that hibernate finds the mapping files, and goes through the first one ok.

At the end of the config is a one-to-many:

<set name="catdbFiles" inverse="true" lazy="true">

<key>

<column name="CAT_ID" precision="22" scale="0" not-null="true"/>

</key>

<one-to-many class="CatdbFile"/>

</set>

which matches to the log file entry of:

DEBUG 2008-02-19 10:41:21,348 [Managed_Application_Thread_13] org.hibernate.cfg.HbmBinder: Mapped property: catdbFiles:

But no other configuration files are loaded - and we have another 11 files to go!

The next entry in the file is as follows:

INFO 2008-02-19 11:05:58,201 [Managed_Application_Thread_14] org.springframework.beans.factory.support.DefaultListableBeanFactory: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory.... (then a list of our beans is appended)

The error remains the same in the SAP AS logs, regarding the InvalidMappingException.

Regards.

Andrew

Former Member
0 Kudos

Hi Andrew!

Thanks for the detailed information. I am very sorry, but without having the application in our hands we have no idea what is going wrong here. We had other (ClassLoader-related) issues with Spring/Hibernate in our Server but this does not seem to be related with those issues. Since we as SAP do not officially support Spring and/or Hibernate on NetWeaver I sadly cannot give you any other support or point you to an expert on that topic. However I recommend you to post on the respective user-mailinglists of Spring and Hibernate.

If you have the time you could also try to migrate your JPA model to use JPA annotations instead of the XML-mapping files. That would at least skip the step of analyzing the mapping files.

Best Regards,

Robin

Former Member
0 Kudos

Robin,

I appreciate the fact that it is difficult without the application in front of you.

I think the problem is related to the class loader as we have a web application which uses exactly the same jars and hibernate mappings, and it is able to parse all of the mappings no problem.

The problem only seems to manifest itself though in the enterprise application.

I shall continue to post my findings on the forum - in case it can be of help to anyone!

Regards,

Andrew

Former Member
0 Kudos

I have created a test application with mdbs to see if i could find the problem.

I created a simple mdb and deployed it.

All was well.

I added spring, and the spring context was successfully parsed.

I then added hibernate. my hibernate factory bean had a collection of mappingResources associated with it.

Everytime it was able to parse the first xml mapping file, but not the rest. This was true no matter which file was first. (ie the files are sound).

Regards,

Andrew

Former Member
0 Kudos

Hi Andrew!

I don't know whether you have read it yet, but maybe [this blog |https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/6447] [original link is broken] [original link is broken] [original link is broken];on using Hibernate in NetWeaver CE is helpful for you.

Best Regards,

Robin

Former Member
0 Kudos

Hi

I don't have any experience about spring bit in case of Hibernate it cannot work with SAP Netweaver. Or u have to override configration class.

The main incompatibility is transaction of hibernate and sap jee5.

Thank You

Syed Saifuddin

Former Member
0 Kudos

Hi Syed!

Sorry, but you are wrong. If you follow the rules in the blog post mentioned above Hibernate runs smoothly on SAP NetWeaver.

Best Regards,

Robin

Former Member
0 Kudos

Just a bit of further information.

I managed to get a bit more information out of the system.

It seems that the problem is manifesting itself in the dom4j reader that hibernate uses.

The error message received is:

org.dom4j.DocumentException: Validation not supported for XMLReader: com.sun.org.apache.xerces.internal.parsers.SAXParser@7fe10a01 Nested exception: Feature 'http://xml.org/sax/features/validation' is not recognized. Nested exception: Validation not supported for XMLReader: com.sun.org.apache.xerces.internal.parsers.SAXParser@7fe10a01 Nested exception: Feature 'http://xml.org/sax/features/validation' is not recognized.:

So im trying to see how / if i can change the parser to one that does support this feature..

Regards,

Andrew

Former Member
0 Kudos

Hi Andrew!

Please try to place your Xerces library in the lib folder of your as described in Georgi's blog. If your IDE packages your application differently you can repackage it afterwards and evaluate whether the application runs then. If you are successful then you could think about alternatives packaging your application. If you don't want to use our IDE you could for example use Maven or ANT and then import the project in the IDE of your choice.

Best Regards,

Robin

Former Member
0 Kudos

Robin,

Its funny you should say that - i have just managed to get hibernate to parse the files.

I replaced our current version of xerces (2.6.2) with the latest version and replaced the xercesImpl.jar and xml-apis.jar.

Now i get a very different error:

WARN 2008-02-21 12:32:12,921 [Managed_Application_Thread_6] org.hibernate.util.JDBCExceptionReporter: SQL Error: 0, SQLState: 08003:

ERROR 2008-02-21 12:32:12,921 [Managed_Application_Thread_6] org.hibernate.util.JDBCExceptionReporter: ResourceException occurred in method ConnectionFactoryImpl.getConnection(): com.sap.engine.services.connector.exceptions.BaseResourceException: Cannot get connection. Reason: the thread of component "ejbContexts/sap.com/dts-ejb-demo-ear/dts-ejb-demo.jar/TestBean" in application "sap.com/dts-ejb-demo-ear" is currently associated with a restricted resource set and it is not allowed to get connection within it.:

It seems the beans (or hibernate for that matter) is not allowed access to the datasource - is this normal operation or should i be doing something else?

The datasource is deployed as part of the jar along with other jms resources.

Regards,

Andrew

Former Member
0 Kudos

Hi Andrew!

Nice that you solved the parser issue. I faced a similar issue with Spring/Hibernate on Jetty. It was terrible to debug.. Regarding your latest error I assume that it is related to [this post|http://www.mail-archive.com/hibernate-dev@lists.jboss.org/msg02307.html] on the Hibernate dev-list.

Best Regards,

Robin

Former Member
0 Kudos

Robin,

Turns out it was something to do with the transaction manager and the way hibernate was configured.

So far I got the application working except for some other wee tiny oracle errors.

I will close this thread off and continue them in another one.

Many thanks for your help.

Regards,

Andrew

Former Member
0 Kudos

Hello Andrew,

I am getting more are like similar error:

org.hibernate.InvalidMappingException: Could not parse mapping document from resource

I am getting this error while I am trying to deploy our inhouse developed adapter in PI 7.1. This adapter has several times deployed in anothet PI system with out any problem.

I expect the PI uses its own Parser in this case to parse the Ihbernate XML Files and produce this kind of error. Please let me know how you managed to know which parser uses PI to parse the XML Files and how you replaced them with the latest version of Parser.

Thanks,

Satish.

Answers (0)