iku
iku

Reputation: 1067

Why NoSuchEJBException is thrown in Wildfly between subsequent calls?

Running wildfly 8.1.Final after obtaining a NullPointerException in bean annotated with @Singleton in a next invocation I receive javax.ejb.NoSuchEJBException with following log:

javax.ejb.NoSuchEJBException: JBAS014300: Could not find EJB with id {[-127, 119, 43, -88, -83, -123, 67, 109, -77, 112, 107, -30, -42, -101, 114, -111]}
        at org.jboss.as.ejb3.component.stateful.StatefulComponentInstanceInterceptor.processInvocation(StatefulComponentInstanceInterceptor.java:62) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
        at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:251) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]
        at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:342) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]
        at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:239) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
        at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
        at org.jboss.as.ejb3.component.invocationmetrics.WaitTimeInterceptor.processInvocation(WaitTimeInterceptor.java:43) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
        at org.jboss.as.ejb3.security.SecurityContextInterceptor.processInvocation(SecurityContextInterceptor.java:95) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
        at org.jboss.as.ejb3.component.interceptors.ShutDownInterceptorFactory$1.processInvocation(ShutDownInterceptorFactory.java:64) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
        at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
        at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
        at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:55) [wildfly-ejb3-8.1.0.Final.jar:8.1.0.Final]
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
        at org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:64)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
        at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:326)
        at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:439)
        at org.jboss.invocation.AccessCheckingInterceptor.processInvocation(AccessCheckingInterceptor.java:61)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
        at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:326)
        at org.jboss.invocation.PrivilegedWithCombinerInterceptor.processInvocation(PrivilegedWithCombinerInterceptor.java:80)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
        at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
        at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:185)
        at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:182)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
        at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
        at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:73)
        at com.bazaarbt.strategy.mm.multilevelstrategy.MultiLevelStrategySingletonEJB$$$view69.updateOnOrderBook(Unknown Source) [classes:]
        at com.bazaarbt.strategy.StrategyRunner.runStrategy(StrategyRunner.java:65) [classes:]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_05]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [rt.jar:1.8.0_05]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_05]
        at java.lang.reflect.Method.invoke(Method.java:483) [rt.jar:1.8.0_05]
        at org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:52)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

I read that one of possible reason may be using @Remove annotation but I don't use it. Does anyone have any idea why it's happening?

EDITED

@Slf4j
@MessageDriven(name = "MessageReceiver", activationConfig = {
    @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "jms/tswReply"),
    @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"),
    @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge") })
public class MyMDB implements MessageListener {

    @EJB 
    private LogicBean lba;

    @Override
    public void  onMessage(Message message) {
        lba.update(message);
    }

    ...
}


@Slf4j
@Stateless
@Named
public class LogicBeanA {

    @EJB
    private LogicBeanB lbb;

    public void update(Message message) {
        ...
        lbb.run();
        ..
    }    
}

@Slf4j
@Setter
@Stateful
@Startup
public class LogicBeanB {
    @Inject
    private LogicBeanC lbc;

    public void run(){
        lbc.doSomething();
    }


}

@Slf4j
@Getter
@Setter
@Dependent
public class LogicBeanC {        
    public void doSomething(){
        internalLogic(); // from here I got NPE 
    }
}

The problem is that only first time when onMessage is executed NPE is thrown. On subsequent calls I got NoSuchEJBException and I would really appreciate if someone would explain why it happens and also how to disable this behaviour. Thanks in advance. (The NPE I can handle, but what worries me most is that when any exception occurs it kills the bean and the entire application crashes because of this).

Upvotes: 1

Views: 2147

Answers (1)

iku
iku

Reputation: 1067

OK. My mistake. Originally I planned to use @Singleton instead of @Stateful. And for @Stateful specification states that an instance is destroyed if 'instance throws system exception from any method'.

Upvotes: 2

Related Questions