[
https://issues.apache.org/jira/browse/PLUTO-101?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Antony Stubbs updated PLUTO-101:
--------------------------------
Attachment: plutoCLpatch.diff
May I suggest this patch?
It adds a more detailed error message on class cast exception.
Also adds two launch configurations, one that will run the pluto:install goal
and one that will copy the packaged jar from pluto-container into tomcat for
you.
> ClassCastException in PortletServlet.init()
> -------------------------------------------
>
> Key: PLUTO-101
> URL: https://issues.apache.org/jira/browse/PLUTO-101
> Project: Pluto
> Issue Type: Bug
> Components: portlet container
> Affects Versions: 1.0.1-rc2
> Environment: Windows 2000, SP4 with Java 1.5
> Reporter: Wayne Holder
> Attachments: plutoCLpatch.diff
>
>
> After downloading rc2 and installing it to run using Java 1.5, I created a
> new web app named wfh which contianed a portlet named TestPortletWFH but,
> when I tried to run it, I always got a ClassCastException in
> PortletServlet.init() on this line of code:
> portletClass = (javax.portlet.Portlet)
> Thread.currentThread().getContextClassLoader().loadClass(classString).newInstance();
> I then moved the same portlet into the testSuite app and, after making the
> needed adjustments to the XML, founf that it ran fine there, but not in the
> wfh app. Note: I changed portletcontexts.txt to include a path to wfh along
> with the path to testsuite.
> As I was unable to easily debug the code, I decided to rebuild rc2 from
> source, changing the code in PortletServlet.init(), as follows:
> public void init (ServletConfig config) throws ServletException {
> super.init(config);
> portletInitialized = false;
> String classString = config.getInitParameter("portlet-class");
> try {
> ClassLoader loader = Thread.currentThread().getContextClassLoader();
> System.out.println("ClassLoader.toString(): " + loader);
> System.out.println("classString: " + classString);
> Class pClass = loader.loadClass(classString);
> System.out.println("pClass: " + pClass);
> Object pObj = pClass.newInstance();
> System.out.println("pObj.getClass(): " + pObj.getClass());
> System.out.println("pObj instanceof javax.portlet.Portlet: " + (pObj
> instanceof javax.portlet.Portlet));
> portletClass = (javax.portlet.Portlet) pObj;
> //portletClass = (javax.portlet.Portlet)
> Thread.currentThread().getContextClassLoader().loadClass(classString).newInstance();
> ...
> and a related function, getInterfaces(), that lists the interfaces
> implemented by the loaded class.
> When I then access the portlet in the wfh app I get a traces like this in the
> console:
> ClassLoader.toString(): WebappClassLoader
> delegate: false
> repositories:
> /WEB-INF/classes/
> ----------> Parent Classloader:
> [EMAIL PROTECTED]
> classString: com.nglm.fwk.sys.TestPortletWFH
> pClass: class com.nglm.fwk.sys.TestPortletWFH
> implements: interface javax.portlet.Portlet, interface
> javax.portlet.PortletConfig
> pObj.getClass(): class com.nglm.fwk.sys.TestPortletWFH
> pObj instanceof javax.portlet.Portlet: false <--- ???
> - StandardWrapper.Throwable
> java.lang.ClassCastException: com.nglm.fwk.sys.TestPortletWFH
> at org.apache.pluto.core.PortletServlet.init(PortletServlet.java:69)
> at
> org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1053)
> which seems completely illogical since, as you can see, the code reports that
> the loaded class implements javax.portlet.Portlet, yet the "instanceof
> javax.portlet.Portlet" test returns false... To make matters even stranger,
> running the exact same portlet in testsuite yields this trace:
> ClassLoader.toString(): WebappClassLoader
> delegate: false
> repositories:
> /WEB-INF/classes/
> ----------> Parent Classloader:
> [EMAIL PROTECTED]
> classString: com.nglm.fwk.sys.TestPortletWFH
> pClass: class com.nglm.fwk.sys.TestPortletWFH
> implements: interface javax.portlet.Portlet, interface
> javax.portlet.PortletConfig
> pObj.getClass(): class com.nglm.fwk.sys.TestPortletWFH
> pObj instanceof javax.portlet.Portlet: true
> So, either my computer has slipped into the twilight zone, or there's
> something really screwy going on with the classloader, or the JVM.
> BTW, the exact same wfh app runs fine under rc1, so this seems to be a new
> issue. It's possible this may be related to Java 1.5, but I've yet to have
> enough time to delve that deeply into the issue.
> Wayne
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.