java - SEVERE: Could not dispatch event: Eventbus com.google.common.eventbus.SubscriberExceptionContext -
for eventbus, merged code inside java spring app , have full control of result didn't change.
when run eventbus in spring sts (javaw), there no issue when run in server java -jar project.jar gives same severe: not dispatch event: error
the below didn't work me..
package edu.uams.event; import java.awt.eventqueue; import java.lang.reflect.invocationtargetexception; import java.util.concurrent.executor; import org.apache.log4j.logger; import com.google.common.eventbus.asynceventbus; import com.google.common.eventbus.eventhandler; import com.google.common.eventbus.subscriberexceptionhandler; import edu.uams.domain.tirevent; import edu.uams.pacs.incomingfilemonitor; public class aysnctraumaeventbus extends asynceventbus { private final static logger logger = logger.getlogger(aysnctraumaeventbus.class); private string name = null; public aysnctraumaeventbus(executor executor, subscriberexceptionhandler subscriberexceptionhandler) { super(executor, subscriberexceptionhandler); logger.info("aysnctraumaeventbus created."); } public aysnctraumaeventbus(string name, executor executor) { super(name,executor); this.name=name; logger.info("aysnctraumaeventbus created. name:"+this.name); } @override public void register(object object) { super.register(object); } @override public void unregister(object object) { super.unregister(object); } @override public void dispatch(object event, eventhandler wrapper) { try { logger.info("let's dispatch aysnchroneous trauma event:"+ ((tirevent) event).getresultmessage()); wrapper.handleevent(event); } catch (invocationtargetexception e) { // logger logger.error("could not dispatch event: " + event + " handler " + wrapper+" e:"+e.getmessage()); logger.info("lets try disptach again!"); super.post(new exceptionevent(event, e)); } } public static final class exceptionevent { public final object event; public final invocationtargetexception exception; public exceptionevent(final object event, final invocationtargetexception exception) { this.event = event; this.exception = exception; } }
}
somehow eventhandler can't invoke target event..
wrapper.handleevent(event);
when wrapper (eventhandler):
public void handleevent(object event) throws invocationtargetexception { checknotnull(event); try { method.invoke(target, new object[] { event }); } catch (illegalargumentexception e) { throw new error("method rejected target/argument: " + event, e); } catch (illegalaccessexception e) { throw new error("method became inaccessible: " + event, e); } catch (invocationtargetexception e) { if (e.getcause() instanceof error) { throw (error) e.getcause(); } throw e; } }
you see method.invoke(target, new object[] { event }); throws invocationtargetexception method.class
public object invoke(object obj, object... args) throws illegalaccessexception, illegalargumentexception, invocationtargetexception { if (!override) { if (!reflection.quickcheckmemberaccess(clazz, modifiers)) { class<?> caller = reflection.getcallerclass(1); checkaccess(caller, clazz, obj, modifiers); } } methodaccessor ma = methodaccessor; // read volatile if (ma == null) { ma = acquiremethodaccessor(); } return ma.invoke(obj, args); }
somehow can't invoke.. interesting part same jar file along eventbus can run fine in sts run (javaw) when run java commandline java -jar project.jar can't dispatch event..
@subscribe @allowconcurrentevents public void receiveddicomfile(tirevent event){ try { } catch (classnotfoundexception e) { logger.error(e.getmessage()); } catch (sqlexception e) { logger.error(e.getmessage()); } catch(exception e){ logger.error(e.getmessage()); } }
it needs try catch.. @dwnz help
Comments
Post a Comment