留言板

Error with datasource in liferay

ramakanth reddy,修改在10 年前。

Error with datasource in liferay

Junior Member 帖子: 27 加入日期: 13-4-17 最近的帖子
Hi

I have configured datasource in "${CATALINA_HOME/config/context.xml" but when i start tomcat server it deletes the resource which i have configured in context.xml file

Added code in context.xml as below:

<Resource name="jdbc/mydb"
auth="Container"
type="javax.sql.DataSource"
maxActive="10"
maxIdle="3"
maxWait="10000"
closeMethod="close"
username="root"
password="XXXX"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/liferay1?autoReconnect=true" />

the above piece of code will be deleted in server next run:

Code in my applicationContext.xml (spring configuration)

<jee:jndi-lookup jndi-name="java:comp/env/jdbc/mydb" id="dataSource" />

<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>

<property name="annotatedClasses">
<list>
<value>com.tek.dao.ExpandoTable</value>
</list>
</property>
</bean>

i have also tried configuring resource-ref in web.xml but still it is working and at server start up it throws the below Exception stack trace:



Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationCon
ingframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation
this Context. Unable to find [java:comp].
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1305)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1067)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/applicationContext
] is not bound in this Context. Unable to find [java:comp].
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1401)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
... 42 more
Caused by: javax.naming.NameNotFoundException: Name [java:comp/env/jdbc/mydb] is not bound in this Context. Unable to find [java:comp].
at org.apache.naming.NamingContext.lookup(NamingContext.java:820)
at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:158)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:154)

Related cause:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invo
und in this Context. Unable to find [java:comp].
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1401)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)


Caused by: javax.naming.NameNotFoundException: Name [java:comp/env/jdbc/mydb] is not bound in this Context. Unable to find [java:comp].
at org.apache.naming.NamingContext.lookup(NamingContext.java:820)
at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:158)
at javax.naming.InitialContext.lookup(InitialContext.java:392)

02-May-2013 14:44:41 org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
02-May-2013 14:44:41 org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/HibernateIntegration-portlet] startup failed due to previous errors
02-May-2013 14:44:41 org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
14:44:41,437 INFO [pool-2-thread-2][PluginPackageUtil:1033] Reading plugin package for HibernateIntegration-portlet
02-May-2013 14:44:41 org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
java.lang.NullPointerException
at com.tek.portlet.HibernatePortlet.init(HibernatePortlet.java:39)
at javax.portlet.GenericPortlet.init(GenericPortlet.java:107)
at com.liferay.portlet.InvokerPortletImpl.init(InvokerPortletImpl.java:256)
at com.liferay.portlet.PortletInstanceFactoryImpl.init(PortletInstanceFactoryImpl.java:221)
at com.liferay.portlet.PortletInstanceFactoryImpl.create(PortletInstanceFactoryImpl.java:140)
at com.liferay.portlet.PortletInstanceFactoryUtil.create(PortletInstanceFactoryUtil.java:41)
at org.apache.jsp.html.portal.render_005fportlet_jsp._jspService(render_005fportlet_jsp.java:577)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at com.liferay.portal.servlet.DirectRequestDispatcher.include(DirectRequestDispatcher.java:97)
at com.liferay.portal.servlet.PACLRequestDispatcherWrapper.doDispatch(PACLRequestDispatcherWrapper.java:90)
at com.liferay.portal.servlet.PACLRequestDispatcherWrapper.include(PACLRequestDispatcherWrapper.java:54)
at com.liferay.portal.util.PortalImpl.renderPortlet(PortalImpl.java:5158)

Liferay version i am using Liferay 6.1 CE Tomcat 7

Please help me if anyone have idea regarding this.

Regards
Ramakanth
thumbnail
David H Nebinger,修改在10 年前。

RE: Error with datasource in liferay

Liferay Legend 帖子: 14915 加入日期: 06-9-2 最近的帖子
ramakanth reddy:
HI have configured datasource in "${CATALINA_HOME/config/context.xml" but when i start tomcat server it deletes the resource which i have configured in context.xml file


I think you left a key point out, that you are restarting tomcat within Eclipse (Liferay IDE).

The IDE has a project called "Servers". You have to fold open this project, find your Liferay server and open it, and edit the context.xml file in there.

Every time you start within the IDE, it pushes this context file to the bundle (overwriting what you've put in). Making the change here will keep it across restarts.
ramakanth reddy,修改在10 年前。

RE: Error with datasource in liferay

Junior Member 帖子: 27 加入日期: 13-4-17 最近的帖子
Hi David

Thanks for your reply,

But when i start server from command prompt still i am getting the same issue,server configured in IDE and server which i am running from command prompt are same.


Regards
Ramakanth
Otto Laitila,修改在10 年前。

RE: Error with datasource in liferay

New Member 发布: 1 加入日期: 13-11-4 最近的帖子
I think Liferay Security Manager prevents your portlet from accessing JNDI resources (read more about security manager).

You should define the needed resources in your portlet's liferay-plugin-package.properties or set portal.security.manager.strategy=none in portal-ext.properties.
thumbnail
Simon Göransson,修改在10 年前。

RE: Error with datasource in liferay

New Member 帖子: 5 加入日期: 10-10-25 最近的帖子
I had the same problem for a customer and to set portal.security.manager.strategy=none helped me.

Thanks