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

"java.lang.IllegalArgumentException: Active Connection is required" exception is thown when installing a hook on JournalArticleService and calling JournalArticleService from velocity template

    Details

      Description

      java.lang.IllegalArgumentException: Active Connection is required exception is thown when we have a Liferay installation with a custom service builder entity and a hook on JournalArticleService.

      This issue is not reproduced in master, it was fixed in story LPS-54811

      Following commit fixes the issue:

      Steps to reproduce

      1. Configure velocity.engine.restricted.variables= at portal-ext.properties
      2. Install a custom servicebuilder entity with its service, called: DummyEntityLocalService
      3. Install a hook on JournalArticleService, called: JournalArticleHookLocalServiceImpl
      4. Create a velocity template with following code:
        Content: <br>
        #set($articleId = $reserved-article-id.getData())
        #set($otherTemplatekey = "1543215")
        #set($otherDisplay = $journalContentUtil.getDisplay($groupId, "$articleId",  $otherTemplatekey, $viewMode, "$locale", $xmlRequest)) 
        #$otherDisplay.getContent()
        
        #set($dummyEntityLocalService = $serviceLocator.findService("active-connection-required-service-portlet", "com.example.plugins.service.DummyEntityLocalService"))
        #set($myentries = $dummyEntityLocalService.getDummyEntities())
        <p><strong>$myentries.size() dummy entities has been found !!!</strong></p>
        
      5. Create a webcontent using previous template
      6. Activate com.liferay.portal.service.persistence.impl.BasePersistenceImpl traces at DEBUG level
      7. Open created webcontent
      8. Wrong behavior: exception is thrown and $myentries = $dummyEntityLocalService.getDummyEntities() is not calculated correctly, so $myentries.size() is not displayed correcty

      Following exception is thrown:

      14:21:24,446 ERROR [ajp-bio-8009-exec-9][BasePersistenceImpl:244] Caught unexpected exception java.lang.IllegalArgumentException
      14:21:24,448 DEBUG [ajp-bio-8009-exec-9][BasePersistenceImpl:248] java.lang.IllegalArgumentException: Active Connection is required
      java.lang.IllegalArgumentException: Active Connection is required
      	at org.springframework.util.Assert.notNull(Assert.java:112)
      	at org.springframework.jdbc.datasource.ConnectionHolder.getConnection(ConnectionHolder.java:150)
      	at com.liferay.portal.dao.jdbc.CurrentConnectionImpl.getConnection(CurrentConnectionImpl.java:43)
      	at com.liferay.portal.kernel.dao.jdbc.CurrentConnectionUtil.getConnection(CurrentConnectionUtil.java:29)
      	at com.liferay.portal.dao.orm.hibernate.PortletSessionFactoryImpl.openSession(PortletSessionFactoryImpl.java:90)
      	at com.liferay.portal.service.persistence.impl.BasePersistenceImpl.openSession(BasePersistenceImpl.java:238)
      	at com.example.plugins.service.persistence.DummyEntityPersistenceImpl.findAll(DummyEntityPersistenceImpl.java:4951)
      	at com.example.plugins.service.persistence.DummyEntityPersistenceImpl.findAll(DummyEntityPersistenceImpl.java:4872)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:606)
      	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:320)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
      	at com.liferay.portal.dao.shard.advice.ShardPersistenceAdvice.invoke(ShardPersistenceAdvice.java:54)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
      	at com.sun.proxy.$Proxy560.findAll(Unknown Source)
      	at com.example.plugins.service.impl.DummyEntityLocalServiceImpl.getDummyEntities(DummyEntityLocalServiceImpl.java:37)
      
      [...]	
      
      	at com.sun.proxy.$Proxy559.getDummyEntities(Unknown Source)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:606)
      	at com.liferay.portal.bean.VelocityBeanHandler.invoke(VelocityBeanHandler.java:51)
      	at com.sun.proxy.$Proxy561.getDummyEntities(Unknown Source)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:606)
      	at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.doInvoke(UberspectImpl.java:389)
      	at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:378)
      	at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:270)
      	at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:262)
      	at org.apache.velocity.runtime.parser.node.ASTReference.value(ASTReference.java:507)
      	at org.apache.velocity.runtime.parser.node.ASTExpression.value(ASTExpression.java:71)
      	at org.apache.velocity.runtime.parser.node.ASTSetDirective.render(ASTSetDirective.java:142)
      	at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:336)
      	at org.apache.velocity.Template.merge(Template.java:328)
      	at org.apache.velocity.Template.merge(Template.java:235)
      	at com.liferay.portal.velocity.VelocityTemplate.processTemplate(VelocityTemplate.java:112)
      	at com.liferay.portal.template.AbstractTemplate.processTemplate(AbstractTemplate.java:127)
      	at com.liferay.portal.template.RestrictedTemplate.processTemplate(RestrictedTemplate.java:55)
      	at com.liferay.portal.templateparser.Transformer.mergeTemplate(Transformer.java:650)
      	at com.liferay.portal.templateparser.Transformer.transform(Transformer.java:362)
      	at com.liferay.portlet.journal.util.JournalUtil.transform(JournalUtil.java:1343)
      	at com.liferay.portlet.journal.service.impl.JournalArticleLocalServiceImpl.getArticleDisplay(JournalArticleLocalServiceImpl.java:2076)
      	at com.liferay.portlet.journal.service.impl.JournalArticleLocalServiceImpl.getArticleDisplay(JournalArticleLocalServiceImpl.java:2164)
      	at com.liferay.portlet.journal.service.impl.JournalArticleLocalServiceImpl.getArticleDisplay(JournalArticleLocalServiceImpl.java:2274)
      	at sun.reflect.GeneratedMethodAccessor844.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:606)
      	at com.liferay.portal.kernel.bean.ClassLoaderBeanHandler.invoke(ClassLoaderBeanHandler.java:67)
      	at com.sun.proxy.$Proxy489.getArticleDisplay(Unknown Source)
      	at com.liferay.portlet.journal.service.JournalArticleLocalServiceWrapper.getArticleDisplay(JournalArticleLocalServiceWrapper.java:1446)
      	at com.example.plugins.service.impl.JournalArticleHookLocalServiceImpl.getArticleDisplay(JournalArticleHookLocalServiceImpl.java:43)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:606)
      	at com.liferay.portal.kernel.bean.ClassLoaderBeanHandler.invoke(ClassLoaderBeanHandler.java:67)
      	at com.sun.proxy.$Proxy557.getArticleDisplay(Unknown Source)
      	at sun.reflect.GeneratedMethodAccessor844.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:606)
      
      [...]
      
      	at com.liferay.portlet.journal.service.JournalArticleLocalServiceUtil.getArticleDisplay(JournalArticleLocalServiceUtil.java:1386)
      	at com.liferay.portlet.journalcontent.util.JournalContentImpl.getArticleDisplay(JournalContentImpl.java:300)
      	at com.liferay.portlet.journalcontent.util.JournalContentImpl.getDisplay(JournalContentImpl.java:166)
      	at com.liferay.portlet.journalcontent.util.JournalContentUtil.getDisplay(JournalContentUtil.java:84)
      

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  3 years, 22 weeks, 4 days ago

                  Packages

                  Version Package
                  6.2.X EE