com.googlecode.sarasvati.SarasvatiException: Failed to instantiate ExecutionListener

5 views
Skip to first unread message

Cheong Chung Onn

unread,
Aug 26, 2009, 9:22:10 AM8/26/09
to sarasvat...@googlegroups.com
Hi Paul,

I encountered a problem with ListenerCache today while profiling my application using JProfiler. Below is the stack trace. First I defined all my ExecutionListeners as anonymous innerclasses and that poses a problem for the ListenerCache and interesting enough this problem did not surface until today when we use JProfiler. In the past my application seems to be running despite this time-bomb is because the ListenerCache is never cleared till my team do the profiling today.

Would it be better to change from

	void addExecutionListener(ExecutionListener listener, ExecutionEventType... eventTypes) 
to

	void addExecutionListener(Class<ExecutionListener> listenerClass, ExecutionEventType... eventTypes) 

Regards
chungonn


 [11:08:58:956] ERROR [com.greenfossil.ponesan.model.service.impl.HibernateService] - Session callback failed
com.googlecode.sarasvati.SarasvatiException: Failed to instantiate ExecutionListener of type com.greenfossil.ponesan.model.service.impl.ResourceServiceImpl$17$1
    at com.googlecode.sarasvati.event.ListenerCache.getListener(ListenerCache.java:43)
    at com.googlecode.sarasvati.hib.HibGraphProcess$1.initEventQueue(HibGraphProcess.java:167)
    at com.googlecode.sarasvati.hib.HibGraphProcess$1.fireEvent(HibGraphProcess.java:142)
    at com.googlecode.sarasvati.impl.BaseEngine.fireEvent(BaseEngine.java:559)
    at com.googlecode.sarasvati.impl.BaseEngine.completeNodeToken(BaseEngine.java:345)
    at com.googlecode.sarasvati.impl.BaseEngine.completeNodeExecution(BaseEngine.java:325)
    at com.googlecode.sarasvati.impl.BaseEngine.complete(BaseEngine.java:247)
    at com.greenfossil.ponesan.model.service.impl.ResourceServiceImpl$25.callback(ResourceServiceImpl.java:931)
    at com.greenfossil.ponesan.model.service.impl.ResourceServiceImpl$25.callback(ResourceServiceImpl.java:922)
    at com.greenfossil.ponesan.model.service.impl.HibernateService.doCallback(HibernateService.java:77)
    at com.greenfossil.ponesan.model.service.impl.HibernateService.callbackSession(HibernateService.java:70)
    at com.greenfossil.ponesan.model.service.impl.ResourceServiceImpl.completeTask(ResourceServiceImpl.java:922)
    at com.greenfossil.ponesan.web.staff.workflow.exam.TaskActionPanel.completeTask(TaskActionPanel.java:188)
    at com.greenfossil.ponesan.web.staff.workflow.exam.TaskActionPanel.access$200(TaskActionPanel.java:62)
    at com.greenfossil.ponesan.web.staff.workflow.exam.TaskActionPanel$1$1.onSubmit(TaskActionPanel.java:105)
    at org.apache.wicket.ajax.markup.html.form.AjaxFallbackButton$1.onSubmit(AjaxFallbackButton.java:74)
    at org.apache.wicket.ajax.form.AjaxFormSubmitBehavior.onEvent(AjaxFormSubmitBehavior.java:143)
    at org.apache.wicket.ajax.AjaxEventBehavior.respond(AjaxEventBehavior.java:177)
    at org.apache.wicket.ajax.AbstractDefaultAjaxBehavior.onRequest(AbstractDefaultAjaxBehavior.java:299)
    at org.apache.wicket.request.target.component.listener.BehaviorRequestTarget.processEvents(BehaviorRequestTarget.java:113)
    at org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92)
    at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1241)
    at org.apache.wicket.RequestCycle.step(RequestCycle.java:1320)
    at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1419)
    at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
    at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:456)
    at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:289)
    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:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
    at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.InstantiationException: com.greenfossil.ponesan.model.service.impl.ResourceServiceImpl$17$1
    at java.lang.Class.newInstance0(Class.java:340)
    at java.lang.Class.newInstance(Class.java:308)
    at com.googlecode.sarasvati.event.ListenerCache.getListener(ListenerCache.java:38)
    ... 38 more

Paul Lorenz

unread,
Aug 26, 2009, 9:46:43 AM8/26/09
to sarasvat...@googlegroups.com
How about either or both of:

1. If passed a new listener, we do listener.getClass().newInstance() immediately, so it will fast fail if passed an inappropriate class, and we can return an exception with a helpful error message.
2. We add the version that takes classes and have the version that takes a listener just call that with listener.getClass(), again throwing an exception with a helpful error message.

In either case, the error message would state that executionlistener classes must have a default constructor, and if they are inner classes, must be static inner classes.

cheers,
Paul

Cheong Chung Onn

unread,
Aug 26, 2009, 11:44:16 AM8/26/09
to sarasvat...@googlegroups.com
Either approach sounds good for me. Just one minor suggestion -
reflecting for a default constructor rather then
listener.getClass().newInstance().

Regards
chung-onn

Paul Lorenz wrote:
> How about either or both of:
>
> 1. If passed a new listener, we do listener.getClass().newInstance()
> immediately, so it will fast fail if passed an inappropriate class,
> and we can return an exception with a helpful error message.
> 2. We add the version that takes classes and have the version that
> takes a listener just call that with listener.getClass(), again
> throwing an exception with a helpful error message.
>
> In either case, the error message would state that executionlistener
> classes must have a default constructor, and if they are inner
> classes, must be static inner classes.
>
> cheers,
> Paul
>
> On Wed, Aug 26, 2009 at 9:22 AM, Cheong Chung Onn <chun...@gmail.com
> <mailto:chun...@gmail.com>> wrote:
>
> Hi Paul,
>
> I encountered a problem with ListenerCache today while profiling my application using JProfiler. Below is the stack trace. First I defined all my ExecutionListeners as anonymous innerclasses and that poses a problem for the ListenerCache and interesting enough this problem did not surface until today when we use JProfiler. In the past my application seems to be running despite this time-bomb is because the ListenerCache is never cleared till my team do the profiling today.
>
> Would it be better to change from
>
> void *addExecutionListener*(ExecutionListener <http://sarasvati.googlecode.com/svn/java/tags/v1.0.0-rc2/doc/javadoc/com/googlecode/sarasvati/event/ExecutionListener.html> listener, ExecutionEventType <http://sarasvati.googlecode.com/svn/java/tags/v1.0.0-rc2/doc/javadoc/com/googlecode/sarasvati/event/ExecutionEventType.html>... eventTypes)
> to
>
> void *addExecutionListener*(Class<ExecutionListener> <http://sarasvati.googlecode.com/svn/java/tags/v1.0.0-rc2/doc/javadoc/com/googlecode/sarasvati/event/ExecutionListener.html> listenerClass, ExecutionEventType <http://sarasvati.googlecode.com/svn/java/tags/v1.0.0-rc2/doc/javadoc/com/googlecode/sarasvati/event/ExecutionEventType.html>... eventTypes)

Paul Lorenz

unread,
Aug 26, 2009, 1:26:52 PM8/26/09
to sarasvat...@googlegroups.com
The reason I was thinking that newInstance might be better, is that an inner class might have a default constructor, but it would still not be invokable.

cheers,
Paul

Cheong Chung Onn

unread,
Aug 26, 2009, 9:01:59 PM8/26/09
to sarasvat...@googlegroups.com
Ah, I missed that inner class default constructor behavior and was too
concern about efficiency :). Anyway I would be implementing static inner
classes for my ExecutionListener classes.

Paul Lorenz

unread,
Aug 27, 2009, 10:26:52 AM8/27/09
to sarasvat...@googlegroups.com
Done. I converted all the arguments that were ExecutionListener to Class<? extends ExecutionListener>. This made the most sense for remove and process level adds, so I figured it made sense to make the global add consistent.

cheers,
Paul

Cheong Chung Onn

unread,
Aug 27, 2009, 10:58:40 AM8/27/09
to sarasvat...@googlegroups.com
Cool!, I can saved typing "new" :)

cheers,
chung-onn

Paul Lorenz wrote:
> Done. I converted all the arguments that were ExecutionListener to
> Class<? extends ExecutionListener>. This made the most sense for
> remove and process level adds, so I figured it made sense to make the
> global add consistent.
>
> cheers,
> Paul
>
> On Wed, Aug 26, 2009 at 9:01 PM, Cheong Chung Onn <chun...@gmail.com
> <mailto:chun...@gmail.com>> wrote:
>
>
> Ah, I missed that inner class default constructor behavior and was too
> concern about efficiency :). Anyway I would be implementing static
> inner
> classes for my ExecutionListener classes.
>
> Regards
> chung-onn
>
> Paul Lorenz wrote:
> > The reason I was thinking that newInstance might be better, is
> that an
> > inner class might have a default constructor, but it would still not
> > be invokable.
> >
> > cheers,
> > Paul
> >
> > On Wed, Aug 26, 2009 at 11:44 AM, Cheong Chung Onn
> <chun...@gmail.com <mailto:chun...@gmail.com>

Paul Lorenz

unread,
Aug 27, 2009, 11:19:19 AM8/27/09
to sarasvat...@googlegroups.com
:)
Reply all
Reply to author
Forward
0 new messages