You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-dev@portals.apache.org by Zhong ZHENG <he...@gmail.com> on 2005/09/09 16:50:16 UTC

Bug fixed for bug PLUTO-159: PortletPreferencesImpl throws a ClassNotFoundException.

Hi,

I found the reason for the bug PLUTO-159: That's a class loader problem.

Since the class PortletPreferencesImpl resides in $CATALINA_HOME/shared/lib, 
it was loaded by the SHARED class loader. But the preferences validator 
class resides in $CATALINA_HOME/webapps/testsuite/WEB-INF/classes, it can 
only be loaded by the webapp class loader of testsuite. That's why we got a 
ClassNotFoundException.

To fix this bug, we just need to use the class loader of the current thread 
to load the validator class, instead of using the class loader of 
PortletPreferencesImpl: that's what the PortletServlet (which was also 
loaded by the SHARED class loader) did when it loaded the Portlet class:

ClassLoader loader = Thread.currentThread().getContextClassLoader();
try {
Class clazz = loader.loadClass(validatorClass);
PreferencesValidator validator =
(PreferencesValidator) clazz.newInstance();
validator.validate(this);
...
} catch ...

I fixed the bug, tested the patch, and attached an SVN diff file to the JIRA 
issue:

http://issues.apache.org/jira/browse/PLUTO-159

Hope that helps.

Regards.

-- 

ZHENG Zhong

1 Avenue Alphand
75116 Paris, France
+33 6 76 80 45 90

heavyzheng {AT} gmail {D0T} com

http://heavyz.sourceforge.net
http://heavyz.blogspot.com
http://spaces.msn.com/members/zhengzhong

Re: Bug fixed for bug PLUTO-159: PortletPreferencesImpl throws a ClassNotFoundException.

Posted by Zhong ZHENG <he...@gmail.com>.
BTW, now I didn't have the ClassNotFoundException any more. But a new 
ValidatorException was thrown out:

javax.portlet.ValidatorException: One or more preferences do not comply with 
the validation criteria
at org.apache.pluto.core.impl.PreferencesValidatorImpl.validate(
PreferencesValidatorImpl.java:70)
at org.apache.pluto.core.impl.PortletPreferencesImpl.store(
PortletPreferencesImpl.java:227)
at 
org.apache.pluto.testsuite.test.SimplePreferenceTest.checkResetPreferences(
SimplePreferenceTest.java:268)
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:324)
at org.apache.pluto.testsuite.test.AbstractReflectivePortletTest.invoke(
AbstractReflectivePortletTest.java:118)
at org.apache.pluto.testsuite.test.AbstractReflectivePortletTest.doTest(
AbstractReflectivePortletTest.java:54)
at org.apache.pluto.testsuite.TestPortlet.processAction(TestPortlet.java
:130)
at org.apache.pluto.core.PortletServlet.dispatch(PortletServlet.java:180)
at org.apache.pluto.core.PortletServlet.doGet(PortletServlet.java:123)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
ApplicationFilterChain.java:173)
at org.apache.catalina.core.ApplicationDispatcher.invoke(
ApplicationDispatcher.java:672)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(
ApplicationDispatcher.java:574)
at org.apache.catalina.core.ApplicationDispatcher.include(
ApplicationDispatcher.java:499)
at org.apache.pluto.core.PortletInvoker.invoke(PortletInvoker.java:154)
at org.apache.pluto.core.PortletInvoker.action(PortletInvoker.java:84)
at org.apache.pluto.core.PortletContainerImpl.doAction(
PortletContainerImpl.java:176)
at org.apache.pluto.driver.PortalDriverServlet.doGet(
PortalDriverServlet.java:109)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(
StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(
StandardContextValve.java:178)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(
AuthenticatorBase.java:407)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java
:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java
:105)
at org.apache.catalina.core.StandardEngineValve.invoke(
StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java
:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:856)
at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection
(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(
PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(
LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(
ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:536)

The portlet preferences did not pass the validation... I will check for that 
later.

Regards.

-- 

ZHENG Zhong

1 Avenue Alphand
75116 Paris, France
+33 6 76 80 45 90

heavyzheng {AT} gmail {D0T} com

http://heavyz.sourceforge.net
http://heavyz.blogspot.com
http://spaces.msn.com/members/zhengzhong