[Javassist user questions] - Making delegators thread-safe
by cpopetz
Hi,
I'm experiencing an exception under heavy load using hibernate, which I believe is a javassist bug.
The code that ProxyFactory.makeForwarder generates to invoke the handler is:
| * if (methods[index * 2] == null) {
| * methods[index * 2]
| * = RuntimeSupport.findMethod(this, <overridden name>, <desc>);
| * methods[index * 2 + 1]
| * = RuntimeSupport.findMethod(this, <delegator name>, <desc>);
| * or = null // the original method is abstract.
| * }
| * return ($r)handler.invoke(this, methods[index * 2],
| * methods[index * 2 + 1], $args);
|
|
This is problematic, because two threads could the same proxy in close enough succession that handler.invoke() could be called with a null third argument:
Thread a: methods[index *2] = ...;
Thread b: if (methods[index * 2] == null) //will evaluate to false
Thread b: loads a null methods[index *2 + 1], invokes handler
Thread a: methods[index *2 + 1] = ...;
and we get a NPE along the lines of:
| java.lang.NullPointerException
| at javassist.util.proxy.RuntimeSupport$DefaultMethodHandler.invoke(RuntimeSupport.java:37)
| at edu.academyart.model.Post_$$_javassist_2.getTextTitles(Post_$$_javassist_2.java)
|
I think this can be fixed by simply reversing the order that the methods are stored in the array, which ensures both exist if the if() block is skipped, as in the below patch.
| $ cvs diff -c2p src/main/javassist/util/proxy/ProxyFactory.java
| Index: src/main/javassist/util/proxy/ProxyFactory.java
| ===================================================================
| RCS file: /cvsroot/jboss/javassist/src/main/javassist/util/proxy/ProxyFactory.java,v
| retrieving revision 1.26
| diff -c -2 -p -r1.26 ProxyFactory.java
| *** src/main/javassist/util/proxy/ProxyFactory.java 2 Oct 2007 03:49:11 -0000 1.26
| --- src/main/javassist/util/proxy/ProxyFactory.java 27 Dec 2007 02:47:28 -0000
| *************** public class ProxyFactory {
| *** 846,851 ****
| code.addIndex(0);
|
| - callFindMethod(code, "findSuperMethod", arrayVar, origIndex, meth.getName(), desc);
| callFindMethod(code, "findMethod", arrayVar, delIndex, delegatorName, desc);
|
| int pc2 = code.currentPc();
| --- 846,851 ----
| code.addIndex(0);
|
| callFindMethod(code, "findMethod", arrayVar, delIndex, delegatorName, desc);
| + callFindMethod(code, "findSuperMethod", arrayVar, origIndex, meth.getName(), desc);
|
| int pc2 = code.currentPc();
|
|
Please let me know if this seems reasonable, and I'll open a JIRA issue with a patch.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4115630#4115630
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4115630
17 years
[JBoss Seam] - Re: java.lang.IllegalStateException: No page context active
by neilac333
Problem solved. I had a property annotated with @DataModel(scope=ScopeType.PAGE). Once I remove that, it works.
This does beg some questions though. I am trying to figure out the right context for a very common scenario:
1) User enters search criteria on a page and presses a button
2) Widget search results are presented on the same page below the form
3) User clicks on the widget link in the table and gets to see all the details about it
4) If user is authorized, user then may edit the information about the chosen widget OR user may go back to see the search results again to select another widget OR user may just read about the widget and hyperlink out to some other part of the site
I am working with JavaBeans, and the collection is annotated with @DataModel and the particular widget with @DataModelSelection.
My questions are these:
1) Is the default scope of EVENT sufficient for this? I ask because I am a bit unclear on what EVENT actually means. Even though I had PAGE before to cause that error I mentioned, CONVERSATION seems like it might be the best choice when I think about it. But if this is so, how would the conversation end in the case where the user just reads the widget details (no editing) and just decides to click a hyperlink to venture off to some unrelated area?
2) What is the best way to simulate the above paths in a FacesRequest test? Can I simply write a single method and call the run() method on the different requests one after another?
Thanks again for the insight.
And I can understand getting bored doing family stuff.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4115628#4115628
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4115628
17 years
[JBoss Seam] - Re: Catch-22 with Seam2 and converterId in page parameter -
by terryb
I guess you meant, in .page.xml. yes I tried that and get similar error.
| <param name="settlementDateFrom" converterId="javax.faces.convert.DateTimeConverter" value="#{paymentReconciliation.settlementDateFrom}"/>
|
|
| Error:
| 10:51:51,939 FATAL [application] JSF1006: Cannot instantiate converter of type javax.faces.convert.DateTimeConverter
| 10:51:51,939 WARN [Param] could not create converter for: settlementDateFrom
| javax.faces.FacesException: Expression Error: Named Object: javax.faces.convert.DateTimeConverter not found.
| at com.sun.faces.application.ApplicationImpl.createConverter(ApplicationImpl.java:726)
| at org.jboss.seam.jsf.SeamApplication.createConverter(SeamApplication.java:112)
| at org.jboss.seam.navigation.Param.getConverter(Param.java:52)
| at org.jboss.seam.navigation.Param.getStringValueFromModel(Param.java:142)
| at org.jboss.seam.navigation.Pages.updateStringValuesInPageContextUsingModel(Pages.java:820)
| at org.jboss.seam.jsf.SeamStateManager.saveSerializedView(SeamStateManager.java:61)
| at org.ajax4jsf.application.AjaxStateManager.saveSerializedView(AjaxStateManager.java:317)
| at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:615)
| at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
| at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:216)
| at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
| at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
| at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
| at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
| at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
| at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
| at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
| at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
| at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
| at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:44)
| at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
| at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
| at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
| at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
| at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
| at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
| at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
| at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
| at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
| at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
| at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
| at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
| at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
| at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
| at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
| at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
| at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
| at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
| at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
| at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:543)
| at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
| at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
| at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
| at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
| at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
| at java.lang.Thread.run(Thread.java:619)
|
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4115627#4115627
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4115627
17 years