Question

I get the error:

Caused by: java.lang.ClassCastException: com.xxx.JbossBirtPortlet cannot be cast to  javax.portlet.Portlet
   at org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl.start(PortletContainerImpl.java:254)

The error is because of a Classloader conflict of tomcat and my portlet, that loads file portlet.jar according to these links: https://community.jboss.org/thread/81246?tstart=0

Deploying a simple Portlet to Liferay - ClassCastException

Then the problem: I need portlet.jar to build my war but my war must not contain portlet.jar, because then arises a ClassLoader conflict.I can not delete portlet.jar from tomcat, because it is needed to other portlets.

So how do I resolve this?

Was it helpful?

Solution

Then the problem: I need portlet.jar to build my war but my war must not contain portlet.jar, because then arises a ClassLoader conflict.I can not delete portlet.jar from tomcat, because it is needed to other portlets.

Correct, you shouldn't include these classes in your WAR if they're provided by the application server.

If you're using Maven, mark your dependency on the portlet API as <scope>provided</scope>. It will be available when your WAR is built, but won't be included in the WAR. If you're not using Maven, RTFM on how to achieve similar functionality with your build tool.

OTHER TIPS

The resolution is to "rename" the classes inside the jar. Don't worry, this isn't so hard. It's actually pretty easy. But it'll take you about 15 - 45 minutes to learn.

The tool you need is called JarJarLinks. It will make a copy of your jar, but with all the conflicting names renamed. It's a little too much to explain here, but here is a simple example.

Hint: If you are unsure of what the conflicts are exactly, there is another great tool which will make a nice report of dependencies for you. It's called Tattletale.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top