I added a short stacktrace. Will try to provide better one. Somehow is
seems, like the system is not fully initialized, like some injection
missing.. Without the (configurationService.getBoolean, everything loads
normally. Is the MDB system initialized before EJBs?


Here is the Singleton snippet:
@Singleton
@Startup
@ConcurrencyManagement(ConcurrencyManagementType.BEAN)
public class UniversalConfigurationService {

    @Inject
    UniversalConfigurationDao configDao;

    private ConcurrentHashMap<Integer, ConcurrentHashMap<Integer,
ConfigValue>> configCache = new ConcurrentHashMap<>();

    @PostConstruct
    public void init() {
        this.configCache = configDao.getAllConfigurations();
    }
}

and here te MDB

MessageDriven(activationConfig = {
    @ActivationConfigProperty(propertyName = "destinationType",
propertyValue = "javax.jms.Queue"),
    @ActivationConfigProperty(propertyName = "destination", propertyValue =
"EtaStatisticalRes")})
@DependsOn("UniversalConfigurationService")
public class EtaStatisticalResHandler implements MessageListener {

    @Inject
    public Logger logger;

    @Inject
    UniversalConfigurationService configurationService;

    @Override
    public void onMessage(Message message) {

        if (configurationService.getBoolean(ETA.getCode(),
EMBEDDED_ETA_REPORTING.getCode())) {
            return;
        }
}





2015-03-08 5:31 GMT+01:00 David Blevins <[email protected]>:

> The @DependsOn annotation only works for other @Singleton beans.
>
> Definitely use CONTAINER concurrency.  Understand that this code is just a
> plain jvm ReentrantReadWriteLock under the covers.  It would be hard to do
> much better.
>
>  -
> http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/locks/ReentrantReadWriteLock.html
>
> All methods annotated with an @Lock(READ) acquire a read lock.  All
> methods annotated with @Lock(WRITE) acquire a write lock.
>
> That said, if you're already doing the configuration initialization in the
> @PostConstruct of the @Singleton, this issue shouldn't exist.
>
> Can you paste the stacktrace of your NPE?
>
>
> --
> David Blevins
> http://twitter.com/dblevins
> http://www.tomitribe.com
>
> On Mar 7, 2015, at 3:51 AM, Matej <[email protected]> wrote:
>
> > Hi everybody.
> >
> > We have an annoying problem on our production system. We have an
> > Configuration Singleton which reads config things from DB. Then in one
> MDB
> > we inject this Singleton to control operation based on configs. Our
> problem
> > is that the system is quite heavely loadded and while the system startups
> > already MDB recievs onMessage events while the Singleton still
> initliazes.
> > Which produces some NPEs and system doesn't boot.
> >
> > The depneds on annotation seems not to help. We are doing BEAN
> conncurency
> > management could this be the issue? And the Singleton has an
> Postconstruct
> > annotation.
> >
> > Anyone has any pattern or tips how to handle this type of scenario.
> >
> > BR
> >
> > Matej
>
>
Mar 06, 2015 1:02:07 PM org.apache.geronimo.connector.work.WorkerContext run
INFO: Removing non-required WorkContextHandler with no context: 
org.apache.geronimo.connector.work.TransactionContextHandler@44d39268
Mar 06, 2015 1:02:07 PM org.apache.geronimo.connector.work.WorkerContext run
INFO: Removing non-required WorkContextHandler with no context: 
org.apache.openejb.core.security.SecurityContextHandler@4a146482
Mar 06, 2015 1:02:07 PM org.apache.geronimo.connector.work.WorkerContext run
INFO: Removing non-required WorkContextHandler with no context: 
org.apache.geronimo.connector.work.HintsContextHandler@4e2bf918
Mar 06, 2015 1:02:07 PM org.apache.openejb.core.transaction.EjbTransactionUtil 
handleSystemException
SEVERE: EjbTransactionUtil.handleSystemException: Singleton failed to initialize
javax.ejb.NoSuchEJBException: Singleton failed to initialize
        at 
org.apache.openejb.core.singleton.SingletonInstanceManager.createInstance(SingletonInstanceManager.java:210)
        at 
org.apache.openejb.core.singleton.SingletonInstanceManager.access$100(SingletonInstanceManager.java:69)
        at 
org.apache.openejb.core.singleton.SingletonInstanceManager$1.call(SingletonInstanceManager.java:120)
        at 
org.apache.openejb.core.singleton.SingletonInstanceManager$1.call(SingletonInstanceManager.java:118)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at 
org.apache.openejb.core.singleton.SingletonInstanceManager.getInstance(SingletonInstanceManager.java:129)
        at 
org.apache.openejb.core.singleton.SingletonContainer.invoke(SingletonContainer.java:200)
        at 
org.apache.openejb.core.ivm.EjbObjectProxyHandler.synchronizedBusinessMethod(EjbObjectProxyHandler.java:308)
        at 
org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxyHandler.java:303)
        at 
org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler.java:92)
        at 
org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:308)
        at 
com.lecip.tms.generic.configuration.universal.UniversalConfigurationService$$LocalBeanProxy.getBoolean(com/lecip/tms/generic/configuration/universal/UniversalConfigurationService.java)
        at 
com.lecip.tms.generic.handler.eta.EtaStatisticalResHandler.onMessage(EtaStatisticalResHandler.java:39)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at 
org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:192)
        at 
org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:173)
        at 
org.apache.openejb.monitoring.StatsInterceptor.record(StatsInterceptor.java:181)
        at 
org.apache.openejb.monitoring.StatsInterceptor.invoke(StatsInterceptor.java:100)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at 
org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:192)
        at 
org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:173)
        at 
org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:85)
        at 
org.apache.openejb.core.mdb.MdbContainer._invoke(MdbContainer.java:402)
        at 
org.apache.openejb.core.mdb.MdbContainer.invoke(MdbContainer.java:373)
        at 
org.apache.openejb.core.mdb.EndpointHandler.deliverMessage(EndpointHandler.java:228)
        at 
org.apache.openejb.core.mdb.EndpointHandler.invoke(EndpointHandler.java:169)
        at 
com.lecip.tms.generic.handler.eta.EtaStatisticalResHandler$$LocalBeanProxy.onMessage(com/lecip/tms/generic/handler/eta/EtaStatisticalResHandler.java)
        at 
org.apache.activemq.ra.MessageEndpointProxy$MessageEndpointAlive.onMessage(MessageEndpointProxy.java:123)
        at 
org.apache.activemq.ra.MessageEndpointProxy.onMessage(MessageEndpointProxy.java:64)
        at org.apache.activemq.ActiveMQSession.run(ActiveMQSession.java:994)
        at 
org.apache.activemq.ra.ServerSessionImpl.run(ServerSessionImpl.java:169)
        at 
org.apache.geronimo.connector.work.WorkerContext.run(WorkerContext.java:366)
        at 
org.apache.geronimo.connector.work.pool.NamedRunnable.run(NamedRunnable.java:32)
        at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.openejb.InvalidateReferenceException: 
java.rmi.RemoteException: The bean encountered a non-application exception; 
nested exception is:
        java.lang.NullPointerException: The bean encountered a non-application 
exception; nested exception is:
        java.lang.NullPointerException
        at 
org.apache.openejb.core.transaction.EjbTransactionUtil.handleSystemException(EjbTransactionUtil.java:156)
        at org.apache.openejb.BeanContext.newInstance(BeanContext.java:1595)
        at 
org.apache.openejb.core.singleton.SingletonInstanceManager.createInstance(SingletonInstanceManager.java:179)
        ... 41 more
Caused by: java.rmi.RemoteException: The bean encountered a non-application 
exception; nested exception is:
        java.lang.NullPointerException
        at 
org.apache.openejb.core.transaction.EjbTransactionUtil.handleSystemException(EjbTransactionUtil.java:155)
        ... 43 more
Caused by: java.lang.NullPointerException
        at 
org.apache.openejb.core.stateless.StatelessInstanceManager.getInstance(StatelessInstanceManager.java:182)
        at 
org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:186)
        at 
org.apache.openejb.core.ivm.EjbObjectProxyHandler.synchronizedBusinessMethod(EjbObjectProxyHandler.java:308)
        at 
org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxyHandler.java:303)
        at 
org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler.java:92)
        at 
org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:308)
        at 
com.lecip.tms.generic.configuration.universal.UniversalConfigurationDao$$LocalBeanProxy.getAllConfigurations(com/lecip/tms/generic/configuration/universal/UniversalConfigurationDao.java)
        at 
com.lecip.tms.generic.configuration.universal.UniversalConfigurationService.init(UniversalConfigurationService.java:27)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at 
org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:192)
        at 
org.apache.openejb.core.interceptor.ReflectionInvocationContext$LifecycleInvocation.invoke(ReflectionInvocationContext.java:223)
        at 
org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:173)
        at 
org.apache.openejb.monitoring.StatsInterceptor.record(StatsInterceptor.java:181)
        at 
org.apache.openejb.monitoring.StatsInterceptor.PostConstruct(StatsInterceptor.java:109)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect..

Reply via email to