Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to avoid ClassCastException in Struts 1.3.x due to its class loading strategy?
    text
    copied!<p><strong>EDIT :</strong> I made changes since I think my question may be missing some technical details</p> <p><strong>The problem occurs in Struts 1.3.x and is described by the following :</strong></p> <p>When modify classes related to Struts (e.g ActionForm, Action, and/or any class I use with them) then I get ClassCastException when I test my modifications (<strong>Without restarting my webapp</strong>).</p> <p>If I restart my webapp after making the same modifications then there is no exception and changes made are visible when testing.</p> <p><strong>This behaviour is said to be NORMAL because of the following reasons :</strong></p> <p>My web container (weblogic) is configured to reload servlet and classes if changes are made</p> <p>I assume that a different ClassLoader is used when modifications are made to my classes. Which may causes ClassCastException.</p> <p><strong>Thus I have to restart webapp everytime I want to test my source modifications...</strong></p> <p><strong>What I wanna know is what can I do (programming pattern ? best practice ?) to avoid this kind of ClassCastException or to avoid restarting webapp to view my changes ?</strong></p> <p>Here is the stack trace :</p> <pre><code>java.lang.ClassCastException: my.package.here.MyActionClassNameHere at org.apache.struts.chain.commands.servlet.CreateAction.getAction(CreateAction.java:65) at org.apache.struts.chain.commands.AbstractCreateAction.execute(AbstractCreateAction.java:91) at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51) at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191) at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:305) at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191) at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1914) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:463) at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) at javax.servlet.http.HttpServlet.service(HttpServlet.java:821) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3650) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2174) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1446) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201) at weblogic.work.ExecuteThread.run(ExecuteThread.java:173) </code></pre> <p>I have seen <strong>JRebel</strong> about page. It may be a solution but I am not ready to use it for my purpose (which is some <strong>very simple</strong> test using struts 1.3.x).</p> <p>I'll continue to do some parallel tests to understand a little more about this exception...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload