Liferay Portlet Error - "NoSuchResourceActionException <Portlet>_WAR_<PortletApp>#VIEW" - grails

I have created a custom Liferay 6.2 portlet using Grails 2.0.4, the Portlets Plugin 0.9.2, and Liferay Portlets Plugin 0.4.
I am getting a strange error after deploying the portlet. Here is what happens:
Upload the WAR file through the web interface
Add the portlet to a page
Receive an error that says "There was an unexpected error. Please refresh the current page."
Refresh the page to find that none of the portlets on the page work anymore, and the following error is displayed: "Internal Server Error - An error occurred while accessing the requested resource." (see the image below)
The logs indicate the following error:
com.liferay.portal.NoSuchResourceActionException: <Portlet>_WAR_<PortletApp>#VIEW
I've seen other instances where the "#VIEW" says "#ADD_TO_PAGE". Please note that the portlet is deploying and working just fine on my vanilla version of Liferay 6.2 that I use for development.
Does anyone know what the issue could possibly be? Thank you.
Stacktrace:
Jan 16, 2014 10:42:40 AM org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
com.liferay.portal.NoSuchResourceActionException: <Portlet>_WAR_<PortletApp>#VIEW
at com.liferay.portal.service.impl.ResourceActionLocalServiceImpl.getResourceAction(ResourceActionLocalServiceImpl.java:196)
at sun.reflect.GeneratedMethodAccessor308.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:115)
at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:175)
at com.sun.proxy.$Proxy85.getResourceAction(Unknown Source)
at com.liferay.portal.service.impl.ResourcePermissionLocalServiceImpl.doUpdateResourcePermission(ResourcePermissionLocalServiceImpl.java:1190)
at com.liferay.portal.service.impl.ResourcePermissionLocalServiceImpl.updateResourcePermission(ResourcePermissionLocalServiceImpl.java:1312)
at com.liferay.portal.service.impl.ResourcePermissionLocalServiceImpl.setOwnerResourcePermissions(ResourcePermissionLocalServiceImpl.java:1038)
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.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:115)
at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:62)
at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:51)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:175)

The problem ended up being higher in the stacktrace. I was receiving the following error:
net.sf.ehcache.CacheException: Unable to load class net.sf.ehcache.store.DefaultElementValueComparator
I was able to fix the problem by reading this link. Here are the steps I took:
Navigate to $liferay_home/tomcat/webapps/ROOT/WEB-INF/lib/
Copy ehcache.jar somewhere to back it up (like the root $liferay_home directory)
Copy ehcache.jar again somewhere to work with it (like the desktop)
Change the name ehcache.jar to ehcache.zip
Unzip the ehcache.zip file
Copy the updated ClassLoaderUtil.class file to the folder's net/sf/ehcache/util/ directory, replacing the current ClassLoaderUtil.class file.
Zip the ehcache directory
Change the name ehcache.zip to ehcache.jar
Put this new ehcache.jar file in $liferay_home/tomcat/webapps/ROOT/WEB-INF/lib/, replacing the current ehcache.jar

I don't know how portlets work wih grails but your error can be fixed by resolving how to define permission using grails.
Liferay official documentation about permissions can be found here :
http://www.liferay.com/community/wiki/-/wiki/Main/Permissioning+in+Plugin+Environment#section-Permissioning+in+Plugin+Environment-DEFINING+PERMISSION+FOR+A+PORTLET+RESOURCE+IN+PLUGIN+ENVIRONMENT

Since I use ehcache-2.10.4.jar in my project, I had the same issue after upgrading to Liferay EE 6.2.10 EE GA1. So instead of fiddling with compiled classes, I replaced ehcache.jar in the $liferay_home/tomcat/webapps/ROOT/WEB-INF/lib/ directory with the one that is provided by the Maven dependency.

Related

General error during conversion: java.lang.NoClassDefFoundError: org/codehaus/groovy/grails/commons/ApplicationAttributes

I am getting the following exception while running grails. Recently i have upgraded grails from version 2.x to 3.3.6. Please let me know what i am missing. Thanks General error during conversion: java.lang.NoClassDefFoundError: org/codehaus/groovy/grails/commons/ApplicationAttributes
java.lang.RuntimeException: java.lang.NoClassDefFoundError: org/codehaus/groovy/grails/commons/ApplicationAttributes
at org.codehaus.groovy.control.CompilationUnit.convertUncaughtExceptionToCompilationError(CompilationUnit.java:1123)
at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1101)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:624)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:602)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:579)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558)
at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:174)
at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:56)
at org.gradle.api.internal.tasks.compile.daemon.AbstractDaemonCompiler$CompilerWorkerAdapter.execute(AbstractDaemonCompiler.java:73)
at org.gradle.api.internal.tasks.compile.daemon.AbstractDaemonCompiler$CompilerWorkerAdapter.execute(AbstractDaemonCompiler.java:64)
at org.gradle.workers.internal.WorkerDaemonServer.execute(WorkerDaemonServer.java:29)
at org.gradle.api.internal.tasks.compile.daemon.AbstractDaemonCompiler$CompilerDaemonServer.execute(AbstractDaemonCompiler.java:91)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
This class was moved to grails.core.ApplicationContext, if it is in your code, so please update it to the new package. If it in the plugin seems that you need to update version or remove it(or you can upgrade it to grails 3 used docs)
This bug during the groovy compilation process i.e
General error during instruction selection: java.lang.NoClassDefFoundError:
could happen due to 3-4 things
A specific module that has the required dependency was not declared.
The dependency was declared but could have been declared with "implementation" in the build.gradle file rather than "api".
The dependency was declared but the compilation process may have gotten confused due to a mix of "compile" and "implementation" dependencies being simultaneously present on the compile classpath. It would be better to move all of them to the new gradle style and avoid 'compile' and 'testCompile' dependencies.
The compilation process has gotten confused due to some classes (of another module) being compiled with one version of a jar and some other classes being compiled with a more recent version. The best way would be to do a proper clean build of all modules.

Grails error initializing application: null

When I try to run "grails run-app", I get the error and small stacktrace:
context.GrailsContextLoaderListener Error initializing the application: null
java.lang.NullPointerException
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:617)
at java.lang.Thread.run(Thread.java:745)
I'm using Grails 2.5.0 and Java 1.8.0_51.
How can I get more information about what's going wrong?
edit: I've tried grails clean and grails refresh-dependencies in all related projects.
I think this is related to reloading or recompilation. Could you retry booting after a grails clean
Our app consists of two projects. Project 1 has all the Bootstrap files and Project 2 all the domain/view/controller files. The branch I was on for Project 1 had a bootstrap file which used a domain object that was on a different branch of Project 2, so I commented out the bootstrap file. As it turns out, this is what was causing the error. To fix it, I had to DELETE the bootstrap file to get the app to run.
I guess Grails doesn't like it when there's a Bootstrap file with no code in it..

Sling webapp installation deploy error

I'm trying to run sling framework.
After building it from sources I have org.apache.sling.launchpad-7-SNAPSHOT.war file.
When I'm deploying it in tomcat7 I'm getting
SEVERE: sling: Failed installing jndi:/localhost/sling/WEB-INF/resources/org.apache.sling.launchpad.base.jar
java.io.FileNotFoundException: /var/lib/tomcat7/sling/_sling /Loader_tmp_1397075933316org.apache.sling.launchpad.base.jar (Permission denied)
at java.io.FileOutputStream.open(Native Method)
Have you any suggestions how to overcome this problem?
The Loader_tmp_ pattern in the problematic file makes me think this happens in the Sling Loader class when it tries to create a temporary file there. I'd check whether the tomcat process has read/write access to the /var/lib/tomcat7/sling folder.

"state is undetermined" when starting Grails app on CloudFoundry

I have a Grails app that has been running on CloudFoundry for months. I updated the app from Grails 2.0.4 to 2.1.0 and also updated a few plugins I have been using.
Now when I push the app to CloudFoundry and do the start, I receive the error:
'appname' state is undetermined, not enough information available.
The tomcat Catalina log shows the NoClassDefFoundError below.
I've read about issues with the Ivy cache but have not looked into that yet. I have updated vmc to the latest version (0.3.18).
SEVERE: Error deploying web application directory ROOT
java.lang.NoClassDefFoundError: org/apache/tomcat/PeriodicEventListener
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2818)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1159)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1647)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1128)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1026)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4421)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4734)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.ClassNotFoundException: org.apache.tomcat.PeriodicEventListener
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
... 34 more
I've just had this problem when migrating from Grails 1.3.7 to 2.1.1.
I fixed it by unpacking the WAR file, removing all the tomcat-*.jar files (there are several tomcat-embedded jars) and then restarting Tomcat.
I've got Tomcat 6 running and I wondered if that was the issue? Anyway my app is working for now--though it's not the best installation procedure!
I resolved the issue by rolling back to Grails 2.0.4 from 2.1.0. I think the issue might be the one described here. But the workaround provided by Graeme did not resolve the issue when deploying to cloudfoundry.com.
Running this app locally under Grails 2.1.0 had no problems but it would not work under cloudfoundry.com.
I'm not using CloudFoundry, but experienced the same issue deploying Grails 2.1 WARs to Tomcat 6. For now, I've configured _Events.groovy to remove the embedded tomcat- and grails-plugin-tomcat- jars from the WAR staging area right before WAR generation:
eventCreateWarStart = { warName, stagingDir ->
// Work-around to remove tomcat jars from .war.
File libDir = new File("${stagingDir}/WEB-INF/lib/")
if (libDir.exists() && libDir.isDirectory()) {
ant.echo(message: 'Events.eventCreateWarStart: Removing embedded tomcat .jars from .war.')
libDir.eachFileMatch(FileType.FILES, ~/^(tomcat|grails-plugin-tomcat).*\.jar$/) { File jarToRemove ->
jarToRemove.delete()
}
}
}
(The libDir.exists() && libDir.isDirectory() check may not be necessary.)
This is working for now, but it would be nice to get a real solution rather than a workaround.
I had the same issue with spring apps. After restarting the services ~cloudfoundry/vcap/dev_setup/bin/vcap stop, cloudfoundry/vcap/dev_setup/bin/vcap start I managed to push my application without any issue.Installin the CF on a more powerful machine may help. What is your current HW?
I know this question is about Grails and CF, but Google doesn't care too much about that... ;)
java.lang.ClassNotFoundException: org.apache.tomcat.PeriodicEventListener
may also appear when Eclipse WTP tries to publish a Maven-project and you run it. Somewhere in your hierarchy of dependencies you should find one to a tomcat-library, even if its scope is provided or test.
Check the lib-directory of your WTP-webapp and notice the bunch of tomcat-libraries in there.

SEVERE: Exception sending context initialized event to listener instance of class org.apache.struts2.tiles.StrutsTilesListener

While building the war file (Struts2.0) and deploying it on the local tomcat everything is working file and I can able to access the web page but when I am trying to deploy it on the remote server I am getting the below exception. I checked the DTD tiles veriosn in tiles.xml it looks good. Can you please suggest me the way to solve this error?
Sep 15, 2011 7:34:37 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.apache.struts2.tiles.StrutsTilesListener
java.lang.IllegalStateException: Unable to instantiate container.
at org.apache.tiles.listener.TilesListener.contextInitialized(TilesListener.java:60)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3827)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4336)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:761)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:741)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:825)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:714)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:490)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1206)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:293)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1307)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1571)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1580)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1560)
at java.lang.Thread.run(Unknown Source)
Hi
My struts version is 2.0.6 and tiles is 2.0 and I don have any other errors. Differences between locan and remote also I couldnt see – veeru 9 mins ago
Got the answer . Problem solved. The mistake wa in web.xml .
The local server is on windows where as remote server is on unix
so there is a mistake in mentioning the relating path in web.xml ( / not required in unix server)
This may be caused by missing dependencies. Doing a search for this error turns up several occurences of people not including:
commons-beanutils-VERSION.jar
commons-collections-VERSION.jar
commons-digest-VERSION.jar
Make sure you have all the requirements listed here: To use Tiles in your application you need
Here is another example of the same error: Struts2 & Tiles: When apache.org is down my webapp fails to start
The last one is a DTD version mismatch.
As you can see it can be due to several reasons, but since it works on your local PC and not the remote, I would lean towards missing dependencies.

Resources