cancel
Showing results for 
Search instead for 
Did you mean: 

Document root element is missing: migrating spring app from tomcat

Former Member
0 Kudos

Hi!

can anybody help me with this issue?

I have ported my tomcat spring application to netweaver(6.40, SP 17, Windows 2k SP4) and i get the following error:

"

Error occured in invoking event "contextInitialized()" on listener clas

s com.webapp.listener.StartupListener. The error is: org.springfram

ework.beans.factory.BeanCreationException: Error creating bean with nam

e 'sessionFactory' defined in ServletContext resource [/WEB-INF/applica

tionContext-hibernate.xml]: Initialization of bean failed; nested excep

tion is org.hibernate.MappingException: Could not parse mapping documen

t in input stream

org.hibernate.MappingException: Could not parse mapp

ing document in input stream

at org.hibernate.cfg.Configuration.addIn

putStream(Configuration.java:430)

at org.springframework.orm.hibernat

e3.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.j

ava:654)

at org.springframework.beans.factory.support.AbstractAutowir

eCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactor

y.java:1059)

at org.springframework.beans.factory.support.AbstractAut

owireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.j

ava:363)

at org.springframework.beans.factory.support.AbstractBeanFac

tory.getBean(AbstractBeanFactory.java:226)

at org.springframework.bea

ns.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java

:147)

at org.springframework.beans.factory.support.DefaultListableBea

nFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:269)

at org.springframework.context.support.AbstractApplicationContext.ref

resh(AbstractApplicationContext.java:320)

at org.springframework.web.

context.support.AbstractRefreshableWebApplicationContext.refresh(Abstra

ctRefreshableWebApplicationContext.java:134)

at org.springframework.w

eb.context.ContextLoader.createWebApplicationContext(ContextLoader.java

:246)

at org.springframework.web.context.ContextLoader.initWebApplica

tionContext(ContextLoader.java:184)

at org.springframework.web.contex

t.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:4

9)

at com.ifx.webapp.listener.StartupListener.contextInitialized(Star

tupListener.java:42)

at com.sap.engine.services.servlets_jsp.server.r

untime.context.WebEvents.contextInitialized(WebEvents.java:45)

at com

.sap.engine.services.servlets_jsp.server.container.ApplicationThreadIni

tializer.run(ApplicationThreadInitializer.java:112)

at com.sap.engine

.core.thread.impl3.ActionObject.run(ActionObject.java:37)

at java.sec

urity.AccessController.doPrivileged(Native Method)

at com.sap.engine.

core.thread.impl3.SingleThread.execute(SingleThread.java:100)

at com.

sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)

C

aused by: org.dom4j.DocumentException: Error on line 1 of document : D

ocument root element is missing. Nested exception: Document root elemen

t is missing.

at org.dom4j.io.SAXReader.read(SAXReader.java:482)

at

org.hibernate.cfg.Configuration.addInputStream(Configuration.java:421)

... 18 more

"

And yes, the xml files are valid xml files at least in anything i've used to look at them (eclipse, ultraedit, notepad, ie) :).....

Thank you!

ps. the file:

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"

"http://www.springframework.org/dtd/spring-beans.dtd">

<beans>

<!-- Hibernate SessionFactory -->

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">

<property name="dataSource" ref="dataSource"/>

<property name="mappingResources">

<list>

<value>package/ModelObj1.hbm.xml</value>

<value>package/ModelObj2.hbm.xml</value>

</list>

</property>

<property name="hibernateProperties">

<props>

<prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>

</props>

</property>

</bean>

<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->

<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">

<property name="sessionFactory" ref="sessionFactory"/>

</bean>

<!-- Generic DAO - can be used when doing standard CRUD -->

<bean id="dao" class="com.dao.hibernate.BaseDAOHibernate">

<property name="sessionFactory" ref="sessionFactory"/>

</bean>

</beans>

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member188321
Contributor
0 Kudos

Hi,

I have no idea about hybernate. But just confirm that you should have a ejbCreate() method(even if its empty) in all of your EJBs(session as well). If you don't have an ejbCreate method in your session beans, you will face prob. in generating them on SAP WAS.

Hope this help.

Thanks & Regards,

Daman.

Former Member
0 Kudos

Thank you for your help guys!

Solved, the hbm.xml files looked like valid xmls but after i saved them in ultraedit and i've opened them in eclipse there were 2 extra chars at the start of them (because utf-8???). So after i've deleted in eclipse these 2 extra chars and i've deployed the app, it started to work:) So now the frameworks/technologies used are:

springfrmwrk1.2.7, hibernater3.0, ajax using dwr lib and it's running smoothly under tomcat and sap too:)).

Former Member
0 Kudos

hi istvan,

we are also migrating from websphere to netweaver.

But in spring framework we r facing problems.

We hav spring-beans.jar file in lib dir of Web Application. But When we are creating BeanFactory from xml as,

BeanFactory beanFactory = new ClassPathXmlApplicationContext ("client-config.xml");

clent-config.xml file contains :

[code<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<beans>

<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" >

<property name="location">

<value>conf/service-client/client.properties</value>

</property>

</bean></beans>

[/code]

But code is giving exception: ClassNotFoundException -org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.

Wat is the problem ?

Kindly help.

We are also using JAAS for authentication.We are refering above code from our LoginModules login() method.

Regards,

sagar.

Former Member
0 Kudos

Hi,

sorry but i'm new to netweaver and for me seems to be a little bit tricky to configure jaas in netweaver (based on the forum questions...), so could you pls tell me where and how is your jaas auth configured?

Pls see: http://static.springframework.org/spring/docs/1.2.x/reference/beans.html#context-create

maybe will help.....

Former Member
0 Kudos

Hi,

Pls check applicationContext-hibernate.xml if its a valid xml file. You can use any xml loader like XML spy to check the validity of the xml. Looks like there is a problem with one or more of the elements of the xml

regards,

Sujesh