Foros de discusión

NoClassDefFoundError: com/liferay/portlet/StrutsPortlet

giorgio morini, modificado hace 14 años.

NoClassDefFoundError: com/liferay/portlet/StrutsPortlet

New Member Mensajes: 20 Fecha de incorporación: 3/07/07 Mensajes recientes
I've developed a struts portlet with the SDK plugin liferay environment for liferay 5.2.3.
I have followed all the step needs but when I deploy it I'have the following error:

11:43:12,055 ERROR [PortletHotDeployListener:436] java.lang.NoClassDefFoundError: com/liferay/portlet/StrutsPortlet
java.lang.NoClassDefFoundError: com/liferay/portlet/StrutsPortlet
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1876)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:889)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1353)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1232)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.initPortlet(PortletHotDeployListener.java:432) ....

Have you some suggestions to solve the problem?


[Thanks in advance for your help.
thumbnail
Minhchau Dang, modificado hace 14 años.

RE: NoClassDefFoundError: com/liferay/portlet/StrutsPortlet

Liferay Master Mensajes: 598 Fecha de incorporación: 22/10/07 Mensajes recientes
Did you follow Step 8 in the Struts Action Portlet tutorial?
carlos alberto, modificado hace 13 años.

RE: NoClassDefFoundError: com/liferay/portlet/StrutsPortlet

New Member Mensajes: 10 Fecha de incorporación: 12/05/10 Mensajes recientes
Minhchau Dang:
Did you follow Step 8 in the Struts Action Portlet tutorial?


hi! i have the same problem. I have followed the step 8 and dont work emoticon

i use liferay last version 6.0.3 with tomcat 6.0.26. Are there problems with the last version?
carlos alberto, modificado hace 13 años.

RE: NoClassDefFoundError: com/liferay/portlet/StrutsPortlet

New Member Mensajes: 10 Fecha de incorporación: 12/05/10 Mensajes recientes
Nobody has the same problem with the last version??
thumbnail
Tina Agrawal, modificado hace 13 años.

RE: NoClassDefFoundError: com/liferay/portlet/StrutsPortlet

Expert Mensajes: 297 Fecha de incorporación: 3/01/08 Mensajes recientes
Looks like you have defined your portlet class to be something like this -
<portlet-class>com.liferay.portlet.StrutsPortlet</portlet-class>


If you are doing so you need to change the class loader.

A better idea is to use the Apache Struts Bridge Portlet class in Plugins SDK.

<portlet-class>org.apache.portals.bridges.struts.StrutsPortlet</portlet-class>


Regards,
Tina
carlos alberto, modificado hace 13 años.

RE: NoClassDefFoundError: com/liferay/portlet/StrutsPortlet

New Member Mensajes: 10 Fecha de incorporación: 12/05/10 Mensajes recientes
Tina Agrawal:
Looks like you have defined your portlet class to be something like this -
<portlet-class>com.liferay.portlet.StrutsPortlet</portlet-class>


If you are doing so you need to change the class loader.

A better idea is to use the Apache Struts Bridge Portlet class in Plugins SDK.

<portlet-class>org.apache.portals.bridges.struts.StrutsPortlet</portlet-class>


Regards,
Tina


thks for your answer, but i think this is a "patch" because the real problem exists yet. If i want to use libreries that is in webapps\ROOT\WEB-INF\lib, what will i do? context.xml in version 6 don't work me!!
Vikas Jindal, modificado hace 13 años.

RE: NoClassDefFoundError: com/liferay/portlet/StrutsPortlet

New Member Mensajes: 19 Fecha de incorporación: 6/11/08 Mensajes recientes
Hi,

This solution will work if you are using tomcat :

Chekck if META-INF/context.xml exists in your portlet war with folloing content:


<?xml version="1.0" encoding="UTF-8"?>

<Context>
<Loader
loaderClass="com.liferay.support.tomcat.loader.PortalClassLoader"
/>

</Context>


Also check if "support-tomcat.jar" in your tomcat 's server\lib.

Thanks
-Vikas
carlos alberto, modificado hace 13 años.

RE: NoClassDefFoundError: com/liferay/portlet/StrutsPortlet

New Member Mensajes: 10 Fecha de incorporación: 12/05/10 Mensajes recientes
Vikas Jindal:
Hi,

This solution will work if you are using tomcat :

Chekck if META-INF/context.xml exists in your portlet war with folloing content:


<?xml version="1.0" encoding="UTF-8"?>

<Context>
<Loader
loaderClass="com.liferay.support.tomcat.loader.PortalClassLoader"
/>

</Context>


Also check if "support-tomcat.jar" in your tomcat 's server\lib.

Thanks
-Vikas


yes, this is "the step 8" that said Minhchau Dang in the second answer, but dont work me. I think is a problem with a liferay 6.0.3, because with 5.2 works me! emoticon
george xiang, modificado hace 13 años.

RE: NoClassDefFoundError: com/liferay/portlet/StrutsPortlet

New Member Mensajes: 7 Fecha de incorporación: 18/10/07 Mensajes recientes
I hava the same situation,my portlet can work on liferay 5.2.* version ,but cannot work on liferay 6.0.* version ,I doubt it is a liferay 6.0.* bug ,anyone who can help me to solve the problem ?
s t, modificado hace 13 años.

RE: NoClassDefFoundError: com/liferay/portlet/StrutsPortlet

Junior Member Mensajes: 48 Fecha de incorporación: 19/10/10 Mensajes recientes
Hi there,

I have the same problem with 5.2.9. (haven't tried with anything else).
Step 8 mentioned above doesn't help here either.
My portlet class extends com.liferay.portlet.StrutsPortlet.
At the beginning it didn't even compile with ant. I had to add the portal-impl.jar to the classpath in build-common.xml

Anybody out there knowing a solution to this?

Thanks for any advice
s t
thumbnail
Gianluca Pindinelli, modificado hace 13 años.

RE: NoClassDefFoundError: com/liferay/portlet/StrutsPortlet

Junior Member Mensajes: 33 Fecha de incorporación: 17/03/10 Mensajes recientes
If that can help you, I had same problem with LF 6.0.5. I had to use an apache struts portlet instead of a com.liferay.portlet.StrutsPortlet.
In the past I always used StrutsPortlet without problems (LF 5.2.3/Tomcat bundled).

Is this a bug?
thumbnail
Minhchau Dang, modificado hace 13 años.

RE: NoClassDefFoundError: com/liferay/portlet/StrutsPortlet

Liferay Master Mensajes: 598 Fecha de incorporación: 22/10/07 Mensajes recientes
Gianluca Pindinelli:
Is this a bug?

Well, specifying class loaders is a feature specific to each application server. If you compare the Tomcat 5.5 documentation (where any class loader is valid) and the Tomcat 6.0 documentation (where only specific class loaders inheriting from Tomcat's class loader are valid), you'll find that it's technically not a bug, but rather intended behavior.

If you want to be able to use Liferay's portal-impl.jar classes in your plugins portlet, you'll have to figure out how to put Liferay 6.0 back onto Tomcat 5.5 (and lose any of the bugs or performance fixes that occurred between the Tomcat releases), since we no longer provide a bundle for it.
thumbnail
Gianluca Pindinelli, modificado hace 13 años.

RE: NoClassDefFoundError: com/liferay/portlet/StrutsPortlet

Junior Member Mensajes: 33 Fecha de incorporación: 17/03/10 Mensajes recientes
Ok..all clear emoticon
I believe the same problem also occurs with JBoss 5.1.0 then, because even with this AS the problem persists.
I hope we can find a solution as soon as possible.

Thanks Minhchau ;)
s t, modificado hace 13 años.

RE: NoClassDefFoundError: com/liferay/portlet/StrutsPortlet

Junior Member Mensajes: 48 Fecha de incorporación: 19/10/10 Mensajes recientes
hi there,

thanks for your replies.

I found a few links that might be of interest:
http://www.liferay.com/community/forums/-/message_boards/message/4824410
http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/Developing+Struts+Based+Portlets+on+Liferay+Portal

However the workarounds in those links either didn't work for me or opened up other problems (like class cast exceptions).


@Minhchau: Is there an official Liferay suggestion for developing struts portlets? Or is this topic out of scope completely. I couldn't find any answer out there so far. (I mean there are sample projects in the trunk that don't work with new tomcat versions, like the sample-struts-liferay-portlet.)


Any help is appreciated
Thanks
s t
thumbnail
Minhchau Dang, modificado hace 13 años.

RE: NoClassDefFoundError: com/liferay/portlet/StrutsPortlet

Liferay Master Mensajes: 598 Fecha de incorporación: 22/10/07 Mensajes recientes
s t:
@Minhchau: Is there an official Liferay suggestion for developing struts portlets? Or is this topic out of scope completely.

The answer largely boils down to why you're choosing Struts as a framework as opposed to all the other frameworks that are available out there (JSF, Spring MVC, GWT, etc.).

If what you want is something that is Struts specific and cannot be easily achieved in another framework, then the Struts portlet 1.0 bridge is known to work, but since it's no longer maintained, there are limitations to what you can do with it as well as bugs you need to workaround when using it.
s t, modificado hace 13 años.

RE: NoClassDefFoundError: com/liferay/portlet/StrutsPortlet

Junior Member Mensajes: 48 Fecha de incorporación: 19/10/10 Mensajes recientes
The answer largely boils down to why you're choosing Struts as a framework as opposed to all the other frameworks that are available out there (JSF, Spring MVC, GWT, etc.).


I wouldn't do struts if I didn't have portlets within a portal that is about to receive an upgrade from 5.2 SP4 to SP5 (and that is where the tomcat version changed and struts portlets aren't working in the way they did).


Thanks
s t
thumbnail
Brian Scott Schupbach, modificado hace 12 años.

RE: NoClassDefFoundError: com/liferay/portlet/StrutsPortlet

Expert Mensajes: 329 Fecha de incorporación: 23/10/08 Mensajes recientes
So, it is decided that in order to fix this the only way to do so is to use tomcat 5.5 instead of 6?
stephan t, modificado hace 12 años.

RE: NoClassDefFoundError: com/liferay/portlet/StrutsPortlet

Junior Member Mensajes: 48 Fecha de incorporación: 19/10/10 Mensajes recientes
Hi Brian,

after reading a while I came to the conclusion that the way the newer tomcat 6 works is the way it should work and you should develop portlets. That is: do not include jars of the ROOT application (in this case Liferay's portal-impl.jar). This is on first sight a limitation but enforces cleaner architecture and dependencies. Portlet should be independent of the container they run in.

In a post on a random website I found this quote:
You should use apache struts bridge to handle lifecycle of struts portlet (refer sample-struts-portlet in community svn plugin repository

https://liferaycms.wordpress.com/2011/01/25/why-i-cant-use-portal-impl-in-my-portlet/

I actually never tried the sample portlet and converted the portlets I had into MVCPortlets.

Hope that helps.
Much success
Stephan