Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Francisco Gomez
ext-spring DataSource problem [SOLVED]
January 4, 2013 6:05 PM
Answer

Francisco Gomez

Rank: New Member

Posts: 2

Join Date: December 18, 2012

Recent Posts

Hello.

I have a small problem with my ext-spring.xml file, I've tried configuring a external data source to my portlet, I've seen that adding a new bean with the datasource might enable the use of diferent datasources.

This is my current file.

 1<?xml version="1.0"?>
 2
 3<beans
 4   default-destroy-method="destroy"
 5   default-init-method="afterPropertiesSet"
 6   xmlns="http://www.springframework.org/schema/beans"
 7   xmlns:aop="http://www.springframework.org/schema/aop"
 8   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 9   xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
10
11   <bean id="myDataSource" lazy-init="true"  class="org.springframework.jdbc.datasource.DriverManagerDataSource">
12      <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
13      <property name="url" value="jdbc:oracle:thin:@server:1521:db"/>
14      <property name="username" value="user" />
15      <property name="password" value="pass" />
16   </bean>
17   <bean id="liferayHibernateSessionFactory"   class="com.liferay.portal.spring.hibernate.PortletHibernateConfiguration">
18      <property name="dataSource" ref="myDataSource" />
19   </bean>
20</beans>


Service builder works, I get the war file I need but the moment when I deploy it on server I get a long stack trace:

 1Dec 21, 2012 5:11:50 PM org.apache.catalina.startup.HostConfig deployDirectory
 2INFO: Deploying web application directory /usr/local/apache-tomcat-7.0.27/webapps/testSB2-portlet
 3Loading file:/usr/local/apache-tomcat-7.0.27/temp/45-testSB2-portlet/WEB-INF/classes/service.properties
 417:11:50,771 ERROR [PortletApplicationContext:87] org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 10 in XML document from ServletContext resource [/WEB-INF/classes/META-INF/ext-spring.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 10; columnNumber: 13; Open quote is expected for attribute "id" associated with an  element type  "bean".
 5org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 10 in XML document from ServletContext resource [/WEB-INF/classes/META-INF/ext-spring.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 10; columnNumber: 13; Open quote is expected for attribute "id" associated with an  element type  "bean".
 6    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
 7    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
 8    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
 9    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
10    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
11    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
12    at com.liferay.portal.spring.context.PortletApplicationContext.loadBeanDefinitions(PortletApplicationContext.java:76)
13    at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:93)
14    at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
15    at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:467)
16    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:397)
17    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:282)
18    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204)
19    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
20    at com.liferay.portal.spring.context.PortletContextLoaderListener.contextInitialized(PortletContextLoaderListener.java:99)
21    at com.liferay.portal.kernel.servlet.PortalClassLoaderServletContextListener.doPortalInit(PortalClassLoaderServletContextListener.java:91)
22    at com.liferay.portal.kernel.util.BasePortalLifecycle.portalInit(BasePortalLifecycle.java:42)
23    at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLifecycleUtil.java:61)
24    at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLifecycleUtil.java:53)
25    at com.liferay.portal.kernel.util.BasePortalLifecycle.registerPortalLifecycle(BasePortalLifecycle.java:52)
26    at com.liferay.portal.kernel.servlet.PortalClassLoaderServletContextListener.contextInitialized(PortalClassLoaderServletContextListener.java:50)
27    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779)
28    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273)
29    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
30    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:895)
31    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871)
32    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
33    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1099)
34    at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1621)
35    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
36    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
37    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
38    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
39    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
40    at java.lang.Thread.run(Thread.java:722)
41Caused by: org.xml.sax.SAXParseException; lineNumber: 10; columnNumber: 13; Open quote is expected for attribute "id" associated with an  element type  "bean".
42    at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
43    at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
44    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
45    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
46    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
47    at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source)
48    at org.apache.xerces.impl.XMLScanner.scanAttributeValue(Unknown Source)
49    at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanAttribute(Unknown Source)
50    at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
51    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
52    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
53    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
54    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
55    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
56    at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
57    at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
58    at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
59    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
60    ... 34 more
61...


The first thing I can notice is this : Line 10 in XML document from ServletContext resource [/WEB-INF/classes/META-INF/ext-spring.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 10; columnNumber: 13; Open quote is expected for attribute "id" associated with an element type "bean".

Which is weird because there seams to be no problem on the xml itself, but I'm stumped by this right now, maybe its something I haven't configured/noticed yet?

Thanks.
Sushil Saini
RE: ext-spring DataSource problem
December 22, 2012 2:38 PM
Answer

Sushil Saini

Rank: Regular Member

Posts: 104

Join Date: July 27, 2011

Recent Posts

Hi Francisco,
According to the details everything looks fine. It can be character encoding problem. Can you try by removing the quotes in your xml file and type them again.
Thanks
Sushil Saini
Amit Doshi
RE: ext-spring DataSource problem
December 26, 2012 4:36 AM
Answer

Amit Doshi

Rank: Liferay Master

Posts: 549

Join Date: December 29, 2010

Recent Posts

Hi Francisco,

I have already written the blog regarding the same.
Please refer this link.

Hope it will be useful.

Thanks & Regards,
Amit Doshi
Priyanka Dhingra
RE: ext-spring DataSource problem
December 26, 2012 4:47 AM
Answer

Priyanka Dhingra

Rank: Liferay Master

Posts: 501

Join Date: December 19, 2011

Recent Posts

you can check this link
Francisco Gomez
RE: ext-spring DataSource problem
January 4, 2013 6:07 PM
Answer

Francisco Gomez

Rank: New Member

Posts: 2

Join Date: December 18, 2012

Recent Posts

Hello.
Sorry for not responding on time.

Thanks to Priyanka's and Amit's responses I've been able to solve my problem.
I tried re-doing my portlet acording to each method, although both are correct I found Priyanka's solution better because it seams more portalble to define the data source on the portlet.

But I think that If I'm going to use the same data source on multiple portlets I better define it on the server like Amit did.

Thank you! :-)