Code Monkey home page Code Monkey logo

Comments (7)

mnesarco avatar mnesarco commented on June 2, 2024

If this happens only at deploy time, it looks like the ejb container is instantiating the cdi proxy before some CDI scoped resources are in place, but at that time no real mapper method is called. So if the stateless bean is then returned to the pool just to wait for a client, the proxy will be serialized and then deserialized when a real client uses the stateless bean, but at that time all the CDI beans are ready so it works. Its just a theory, apparently this case is not present in weld, maybe only in webbeans?

from cdi.

mcbeelen avatar mcbeelen commented on June 2, 2024

Recently we change some of the design of our application.
Since we made that change this issue has resurfaced and now it is interfering with the proper functionality of our application.

We have a MessageDrivenBean (the Receiver) in our application, which receives a JMS Message and delegates processing that message to another Stateless Session Bean(the MessageRouter).
After going through some of our classes it will invoke a method on a another Stateless Session Bean (the MyBatisPaymentRequestRepository), which needs the Mapper.

The injection of the Mapper into the constructed MyBatisPaymentRequestRepository fails due to this NullPointerException in getting the Mapper from the SerializableMapperProxy.
After some time the initialization of the SerializableMapperProxy or the SqlSessionFactory is complete and then the application is going to work properly, but processing the first couple of JMS-message has already failed.

2017-01-25 15:27:33 [Default JMS Resource Adapter-worker- - 7] ERROR OpenEJB - The bean instance MyBatisPaymentRequestRepository threw a system exception:java.lang.NullPointerException
java.lang.NullPointerException: null
	at org.mybatis.cdi.SerializableMapperProxy.getMapper(SerializableMapperProxy.java:61)
	at org.mybatis.cdi.SerializableMapperProxy.<init>(SerializableMapperProxy.java:47)
	at org.mybatis.cdi.MyBatisBean.create(MyBatisBean.java:117)
	at org.apache.webbeans.component.third.ThirdpartyBeanImpl.create(ThirdpartyBeanImpl.java:96)
	at org.apache.webbeans.context.DependentContext.getInstance(DependentContext.java:68)
	at org.apache.webbeans.context.AbstractContext.get(AbstractContext.java:125)
	at org.apache.webbeans.container.BeanManagerImpl.getReference(BeanManagerImpl.java:754)
	at org.apache.webbeans.container.BeanManagerImpl.getInjectableReference(BeanManagerImpl.java:628)
	at org.apache.webbeans.inject.AbstractInjectable.inject(AbstractInjectable.java:95)
	at org.apache.webbeans.inject.InjectableField.doInjection(InjectableField.java:65)
	at org.apache.webbeans.portable.InjectionTargetImpl.injectFields(InjectionTargetImpl.java:208)
	at org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:194)
	at org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:184)
	at org.apache.openejb.cdi.CdiEjbBean$EjbInjectionTargetImpl.inject(CdiEjbBean.java:388)
	at org.apache.openejb.BeanContext.inject(BeanContext.java:1660)
	at org.apache.openejb.BeanContext.newInstance(BeanContext.java:1489)
	at org.apache.openejb.core.stateless.StatelessInstanceManager.createInstance(StatelessInstanceManager.java:207)
	at org.apache.openejb.core.stateless.StatelessInstanceManager.getInstance(StatelessInstanceManager.java:199)
	at org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:186)
	at org.apache.openejb.core.ivm.EjbObjectProxyHandler.synchronizedBusinessMethod(EjbObjectProxyHandler.java:317)
	at org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxyHandler.java:312)
	at org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler.java:92)
	at org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:325)
	at xx.xx.xx.xx.transaction.TransactionStartedMessageOrchestrator.doProcess(TransactionStartedMessageOrchestrator.java:42) [1 skipped]
	at xx.xx.xx.xx.transaction.TransactionStartedMessageOrchestrator.doProcess(TransactionStartedMessageOrchestrator.java:26)
	at xx.xx.xx.xx.AbstractMessageOrchestrator.process(AbstractMessageOrchestrator.java:10)
	at xx.xx.xx.xx.MessageProcessorFactory.buildProcessorAndStartProcessing(MessageProcessorFactory.java:59)
	at xx.xx.xx.xx.MessageRouter.unmarshalMessageAndRouteToProcessor(MessageRouter.java:90)
	at xx.xx.xx.xx.MessageRouter.routeMessageToProcessor(MessageRouter.java:72)
	at org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:192) [4 skipped]
	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 org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:192) [4 skipped]
	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.stateless.StatelessContainer._invoke(StatelessContainer.java:227)
	at org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:194)
	at org.apache.openejb.core.ivm.EjbObjectProxyHandler.synchronizedBusinessMethod(EjbObjectProxyHandler.java:317)
	at org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxyHandler.java:312)
	at org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler.java:92)
	at org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:325)
	at xx.xx.xx.xx.MessageRouter$$LocalBeanProxy.routeMessageToProcessor(xx.xx.xx.xx.xx/MessageRouter.java)
	at xx.xx.xx.xx.Receiver.processMessageText(Receiver.java:82)
	at xx.xx.xx.xx.Receiver.onMessage(Receiver.java:69)
	at org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:192) [4 skipped]
	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 org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:192) [4 skipped]
	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 xx.xx.xx.xx.Receiver$$LocalBeanProxy.onMessage(xx.xx.xx.xx.xx/Receiver.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)

from cdi.

mnesarco avatar mnesarco commented on June 2, 2024

Hi @mcbeelen, I have done some important changes in beta5. please take a look at: http://www.mybatis.org/cdi/changes.html
So please upgrade to beta5 and tell me if the problem is still there.

from cdi.

mcbeelen avatar mcbeelen commented on June 2, 2024

Hi @mnesarco ,

We upgraded to beta5 and tweaked our logging.

The behaviour as we currently see it, is this:

  1. mybatis.cdi.Extension finds 5 Mappers in processAnnotatedType().
  2. mybatis.cdi.Extension does not create a bean for all found mappers in afterBeanDiscovery()
  3. As soon a OpenEJB.startup finds a object, which needs on of the 'uninitialized mappers' to throws an UnsatisfiedResolutionException.
10:48:23 [localhost-startStop-1] INFO  org.mybatis.cdi.Extension - MyBatis CDI Module - Mapper type MerchantOrderMapper
10:48:23 [localhost-startStop-1] INFO  org.mybatis.cdi.Extension - MyBatis CDI Module - Mapper type PoiInfoMapper
10:48:23 [localhost-startStop-1] INFO  org.mybatis.cdi.Extension - MyBatis CDI Module - Mapper type TransactionMapper
10:48:23 [localhost-startStop-1] INFO  org.mybatis.cdi.Extension - MyBatis CDI Module - Mapper type PaymentRequestMapper
10:48:23 [localhost-startStop-1] INFO  org.mybatis.cdi.Extension - MyBatis CDI Module - Mapper type FailedMessageMapper

10:48:23 [localhost-startStop-1] INFO  org.mybatis.cdi.Extension - MyBatis CDI Module - SqlSessionFactory producer DataSourceConfig.produceFactory

10:48:24 [localhost-startStop-1] INFO  org.mybatis.cdi.Extension - MyBatis CDI Module - Activated

10:48:24 [localhost-startStop-1] INFO  org.mybatis.cdi.Extension - MyBatis CDI Module - Managed Mapper dependency: xx.xx.xx.PaymentRequestMapper, xx.xx.xx.PaymentRequestMapper
10:48:24 [localhost-startStop-1] INFO  org.mybatis.cdi.Extension - MyBatis CDI Module - Managed Mapper dependency: xx.xx.xx.PoiInfoMapper, xx.xx.xx.PoiInfoMapper
10:48:24 [localhost-startStop-1] INFO  org.mybatis.cdi.Extension - MyBatis CDI Module - Managed Mapper dependency: xx.xx.xx.persistence.mapper.TransactionMapper, xx.xx.xx.TransactionMapper

10:48:24 [localhost-startStop-1] INFO  org.mybatis.cdi.Extension - MyBatis CDI Module - Managed SqlSession: org.apache.ibatis.session.SqlSession, org.apache.ibatis.session.SqlSession


10:48:24 [localhost-startStop-1] ERROR OpenEJB.startup - CDI Beans module deployment failed
org.apache.webbeans.exception.inject.DeploymentException: 
javax.enterprise.inject.UnsatisfiedResolutionException: 
	Api type [xx.xx.xx.MerchantOrderMapper] is not found with the qualifiers 
Qualifiers: [@javax.enterprise.inject.Default()]
for injection into Field Injection Point, field name :  mapper, 
	Bean Owner : [MyBatisMerchantOrderRepository, Name:null, WebBeans Type:ENTERPRISE, 
	API Types:[xx.xx.xx.MerchantOrderRepository,java.io.Serializable,java.lang.Object], Qualifiers:[javax.enterprise.inject.Default,javax.enterprise.inject.Any]]

Further debugging gave us the insight that processInjectionTarget() is not being called for the Field Injection Point, which later causes the UnsatisfiedResolutionException.

from cdi.

mcbeelen avatar mcbeelen commented on June 2, 2024

@mnesarco : Could the process to make a 1.0.0-beta6 release be started?
We would like to use the solution for this issue in our project, but prefer to use released versions instead of SNAPSHOTs.

from cdi.

mnesarco avatar mnesarco commented on June 2, 2024

from cdi.

hazendaz avatar hazendaz commented on June 2, 2024

I did a quick overall review, cleaned up a few very trivial issues, upgraded mockito to 2.7.0 and fixed mockito deprecations. I'll push the release for beta6. It's rather simple to do and takes about 10 minutes max. The binary should show up though in central in about 2 to 3 hours from now.

from cdi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.