Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-30505

A portlet can not use a jndi datasource after portal is started on tomcat 7.0.27

    Details

      Description

      I'm trying to upgrade my portal from liferay 6.0.5 to liferay 6.1.1

      All works fine but i'm facing a big problem.
      My portal is connected to a mysql database via a datasource configured via jndi in tomcat.
      The portal communicates well with the database.

      I have a portlet that use spring + hibernate and use same datasource as the portal.
      When portal is starting Spring lookup the datasource whithout any problem.
      But if i redeploy this portlet after the portal started, spring could not lookup this datasource.
      I have an exception NameNotFoundException :

      GRAVE: Exception lors de l'envoi de l'évènement contexte initialisé (context initialized) à l'instance de classe d'écoute (listener) org.springframework.web.context.ContextLoaderListener
      org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourcePortlet' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Le Nom java:comp/env/jdbc/liferayDS n'est pas lié à ce Contexte
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1422)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:518)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567)
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
      at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:282)
      at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204)
      at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779)
      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1366)
      at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1454)
      at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:295)
      at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
      at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
      at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1379)
      at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1537)
      at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1547)
      at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1526)
      at java.lang.Thread.run(Thread.java:619)
      Caused by: javax.naming.NameNotFoundException: Le Nom java:comp/env/jdbc/liferayDS n'est pas lié à ce Contexte
      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)
      at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
      at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)
      at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)
      at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95)
      at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105)
      at org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:201)
      at org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:187)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$5.run(AbstractAutowireCapableBeanFactory.java:1469)
      at java.security.AccessController.doPrivileged(Native Method)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1467)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1419)
      ... 25 more

      With liferay 6.0.25 and tomcat 6.0.26 this works fine.

      You will find in attachement :

      • the porlet web.xml
      • the portlet spring context applicationContext.xml
      • the tomcat server.xml
      • the tomcat context.xml

      Can you help me please ?

        Attachments

        1. applicationContext.xml
          4 kB
        2. context.xml
          2 kB
        3. server.xml
          9 kB
        4. web.xml
          2 kB

          Activity

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                5 years, 48 weeks, 6 days ago

                Packages

                Version Package
                6.1.1 CE GA2