论坛

主页 » Liferay Portal » English » 3. Development

组合视图 统一视图 树状图
讨论主题 [ 上一个 | 下一个 ]
toggle
ramakanth reddy
Error with datasource in liferay
2013年5月2日 上午8:08
答复

ramakanth reddy

等级: Junior Member

帖子: 28

加入日期: 2013年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
David H Nebinger
RE: Error with datasource in liferay
2013年5月2日 上午8:31
答复

David H Nebinger

Community Moderator

等级: Liferay Legend

帖子: 8590

加入日期: 2006年9月1日

最近的帖子

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
RE: Error with datasource in liferay
2013年5月2日 上午9:14
答复

ramakanth reddy

等级: Junior Member

帖子: 28

加入日期: 2013年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
RE: Error with datasource in liferay
2013年11月13日 上午3:35
答复

Otto Laitila

等级: New Member

帖子: 1

加入日期: 2013年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.
Simon Göransson
RE: Error with datasource in liferay
2014年1月23日 上午4:45
答复

Simon Göransson

等级: New Member

帖子: 5

加入日期: 2010年10月25日

最近的帖子

I had the same problem for a customer and to set portal.security.manager.strategy=none helped me.

Thanks