-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CDI injection does not work in WebSphere Application Server 8.5.5.5 #19
Comments
Possibly using @any might work. Sent by Outlook for Android On Thu, Jul 23, 2015 at 1:47 PM -0700, "isaiasbsf" notifications@github.com wrote: @Inject or @Inject Eclipse IDE gives me a warnning at the @Inject mentioned abouve: I have a Producer method with ApplicationScoped: @ApplicationScoped When I run my application on WebSphere Liberty Profile V8.5 it woks since it does not have injection points validation at start up. When the application is acessed the @produces method is called and the factory is loaded with session and mapper proxys.This cenario works fine. But when I run my application on the Application Server Full, it uses the OpenWebBeans CDI Container and it tries to validate all injection points at startup and does not find any class of type "SqlSession" or "InerfaceXXXMapper" being produced. The type produced is "SqlSessionFactory" that holds the proxys for SqlSession and its Mappers registred. How can I make it work? Thanks, Isaias Reply to this email directly or view it on GitHub: |
I got the same resut: @Inject [7/23/15 20:42:56:172 BRT] 0000007e WebContainerL I WebContainerLifecycle startApplication OpenWebBeans Container is starting... |
Is your producer class also scoped in application scope? Sent by Outlook for Android On Thu, Jul 23, 2015 at 5:05 PM -0700, "isaiasbsf" notifications@github.com wrote: @Inject [7/23/15 20:42:56:172 BRT] 0000007e WebContainerL I WebContainerLifecycle startApplication OpenWebBeans Container is starting... Reply to this email directly or view it on GitHub: |
I wasn´t, but now it is and didn´t work. @ApplicationScoped @ApplicationScoped It seems like it needs to load the factory at startup so that it doesn´t fail the following validation. Is there a way to load the factory at startup? at org.apache.webbeans.util.InjectionExceptionUtils.throwUnsatisfiedResolutionException(InjectionExceptionUtils.java:92) |
It doesn't work for me too. I'm on WAS 8.5.5.3 with mybatis-cdi 1.0.0-beta3. Same errors at start-up. |
Hi @isaiasbsf and @ilkomiliev thanks for reporting this, can you give a try with beta5? Take into accout there are breaking changes: http://www.mybatis.org/cdi/changes.html |
I have tested beta5 with Payara 4.1 (Glassfish 4.1), TomEE-Plus 7.0.1, WildFly 10.1.0 |
In version beta6 (SNAPSHOT for now) a fix for issue #40 was implemented, which solved the UnsatisfiedResolutionException in WebBeans. This fix might solve the WebSphere issues as well.
Cheers, |
Hi @isaiasbsf , @ilkomiliev , can you help us testing if beta6 fixed the issue? |
Hi,
I'm sorry but I don't have access to WAS installations anymore. Perhaps someone else could help here.
… On 17 Feb 2017, at 18:53, Frank David Martínez M ***@***.***> wrote:
Hi @isaiasbsf , @ilkomiliev , can you help us testing if beta6 fixed the issue?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Hi, We had to look for another solution since it took too long to solve. However, I got a copy of the project from the time we were using MyBatis CDI, upgraded my dependencies to mybatis-3.4.2.jar / mybatis-cdi-1.0.0-beta6.jar and adjusted the code to the breaking changes: @Mapper annotation is now mandatory in Mapper Interfaces and forbidden in injection points. The server started up ok, but when I tried to access a bean which injects a service that has a Mapper interface injected, I get the following error: Caused by: java.lang.IllegalStateException: Unable to access CDI |
Hi @isaiasbsf , Caused by: java.lang.IllegalStateException: Unable to access CDI Sounds like a container / configuration problem. Do you have a bean.xml file properly placed? Can you share your code? I am trying to solve this in the darkness. |
Yes I do. CDI is working in the project, except for the bean I changed to inject the Mapper interface directly in the new way according to the breaking changes. My project uses JSF with @ConversationScoped beans. In my SqlSessionFactoryProvider.java I have two providers: @ApplicationScoped @ApplicationScoped @ArarasFactory and @ArarasSegFactory are just qualifiers to resolve ambiguities. In my conversationScoped bean I have: @nAmed In my service implementation I have: public class UsuarioServiceImpl implements UsuarioService, Serializable { In this Mapper interface I Have: @Mapper If I change the service implementation to inject the SqlSessionFactory instead of the Mapper interface it works, but than I lose the transactional features of MyBatisCDI, which is the reason I wanted to use. public class UsuarioServiceImpl implements UsuarioService, Serializable { |
Ok. Sounds like a "Passivation issue with the Conversation Scope" I have commited a fix for Issue #45 and it can be related. Please try beta7-snapshot. It works with payara and tomee. |
I didn't find beta7 in Maven central. |
@mnesarco Please take a look at the change I made to make serialization tests pass. If that seems appropriate, I can release beta7. @isaiasbsf Are you ok if we force java 7 usage? |
No problem, we're already using Java 7. |
@hazendaz your addition is ok. (I have removed Serializable by accident) |
@isaiasbsf I have released 1.0.0-beta7. It should be available via poms immediately and will show in maven central in a couple of hours. Can you try this again and let us know if it works? Thanks. |
@hazendaz I changed to beta 7 but got the same error: Caused by: java.lang.IllegalStateException: Unable to access CDI |
@isaiasbsf This is very strange. It works with OpenWebBeans in Tomee. Can you deploy the Sample App just to see if it works? (https://github.com/mnesarco/mybatis-cdi-samples/). TomEE uses OpenWebBeans 1.6.3, maybe WAS uses some different version? |
@isaiasbsf @hazendaz I have tested it today with WebSphere Application Server Version 16.0.0.4 Liberty and it works out of the box. |
We're using the WebSphere Application Server 8.5.5.3 (Liberty Profile) for development and WebSphere Application Server 8.5.5.5 (Full application server) on production environment. I deployed the sample App (https://github.com/mnesarco/mybatis-cdi-samples/) and got the following error when accessing the web context: Caused by: javax.servlet.ServletException: SRVE0320E: O filtro [SampleWebFilter] foi localizado, mas ocorreu uma falha na injeção de recursos. |
java.lang.NoClassDefFoundError: javax/enterprise/inject/spi/CDI Means that
it is using an old version of webbeans or there is another problem with the
container not with mybatis-cdi.
With WAS Liberty with Java EE 7 Full Platform 16.0.0.4 it works out of the
box.
…On Thu, Mar 2, 2017 at 1:54 PM, isaiasbsf ***@***.***> wrote:
We're using the WebSphere Application Server 8.5.5.3 (Liberty Profile) for
development and WebSphere Application Server 8.5.5.5 (Full application
server) on production environment. I deployed the same App (
https://github.com/mnesarco/mybatis-cdi-samples/) and got the following
error when accessing the web context:
Caused by: javax.servlet.ServletException: SRVE0320E: O filtro
[SampleWebFilter] foi localizado, mas ocorreu uma falha na injeção de
recursos.
... 3 more
Caused by: com.ibm.wsspi.injectionengine.InjectionException: Unable to
obtain an instance for @Inject <https://github.com/Inject>
java.lang.reflect.Field.userMapper: java.lang.NoClassDefFoundError:
javax/enterprise/inject/spi/CDI
at com.ibm.wsspi.injectionengine.InjectionBinding.getInjectionObject(
InjectionBinding.java:1123)
... 1 more
Caused by: java.lang.NoClassDefFoundError: javax/enterprise/inject/spi/CDI
at org.mybatis.cdi.CDIUtils.findSqlSessionFactory(CDIUtils.java:46)
at org.mybatis.cdi.SerializableMapperProxy.getMapper(
SerializableMapperProxy.java:57)
at org.mybatis.cdi.SerializableMapperProxy.(SerializableMapperProxy.java:
44)
at org.mybatis.cdi.MyBatisBean.create(MyBatisBean.java:116)
at org.apache.webbeans.component.third.ThirdpartyBeanImpl.
create(ThirdpartyBeanImpl.java:93)
... 1 more
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#19 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABCXVTsO8gs5DUVsDGR5nYreBS6oGK-Qks5rhxB0gaJpZM4FetP0>
.
--
Frank D. Martínez M.
|
@isaiasbsf @hazendaz WAS CDI support started in 8.5.5 (CDI 1.0 I suppose), but it was updated to CDI 1.2 in 8.5.5.6. You need at least CDI 1.1 to use mybatis-cdi. |
It's true, we're using cdi-1.0 since it is the CDI version supported on our version of the application server. I understand now that MyBatis-CDI minimal compliance is cdi-1.1. However, we're not upgrading our application server at this time because of this. The CDI container works for everything else, except for MyBatis CDI. This issue was opened almost 2 years ago and we were using the latest version of WebSphere Application Server at the time. As I said before, we switched to another solution (MyBatis-Guice) and I was just trying to help solve the problem with our version. When we decide to upgrade our application server in the future, we'll consider switching back to MyBatis-CDI. |
Thanks. So based on everything I think we can close this. If we don't already note minimum supported versions we should add that to the Readme. Given overall age of original support need I'd say this is good enough so we can bring into GA release under version 1.0.0. Thanks for all the effort in testing and confirming overall state.
Get Outlook for Android<https://aka.ms/ghei36>
…________________________________
From: isaiasbsf <notifications@github.com>
Sent: Thursday, March 2, 2017 3:52:53 PM
To: mybatis/cdi
Cc: Jeremy Landis; Mention
Subject: Re: [mybatis/cdi] CDI injection does not work in WebSphere Application Server 8.5.5.5 (#19)
It's true, we're using cdi-1.0 since it is the CDI version supported on our version of the application server. I understand now that MyBatis-CDI minimal compliance is cdi-1.1. However, we're not upgrading our application server at this time because of this. The CDI container works for everything else, except for MyBatis CDI. This issue was opened almost 2 years ago and we were using the latest version of WebSphere Application Server at the time. As I said before, we switched to another solution (MyBatis-Guice) and I was just trying to help solve the problem with our version. When we decide to upgrade our application server in the future, we'll consider switching back to MyBatis-CDI. Thanks for your time.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#19 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AA7ho1IrIcW8zb2BtWt1botM5x83b3frks5rhywlgaJpZM4FetP0>.
|
@isaiasbsf @hazendaz Ok Guys, Thanks for your help. I am closing this now. I have updated the README with info about the CDI versions supported. |
I have an UnsatisfiedResolutionException problem with the mapper like isaiasbspf. Was there a solution to this problem afterwards? |
@znzlspt17 What version of WAS and mybatis-cdi are you using? Based on this thread, you need to be at cdi 1.1 which is least supported version. We have profiles in pleace on github actions to run through all configuration needs from 1.1 to 2.0 with various java configurations. Those are known supported. This thread was in regards to WAS 8.5.5.5 which I'm guessing from context here was still cdi 1.0. I'd sort of hope you were not still trying to use that as it is long vulnerable and well over 5 years old based at this point in time. |
@hazendaz hello im using mybatis 3.5.9, mybatis-cdi 1.1.2, owb 2.0.17, aries cdi 1.1.5 using on java 11 base karaf 4.3.7 Should I create a new post? |
@znzlspt17 Yes open new ticket with stack trace of issue you are facing. This ticket is specific to WAS and legacy usage which was noted as resolved in indicating newer version necessary. The library usage you have looks ok. |
@hazendaz Hello, I opened a new ticket. #302 (comment) |
I have a web application with JSF 2.0, mybatis-3.3.0 and mybatis-cdi-1.0.0-beta2. The following two cases does not work running on WebSphere Application Server 8.5.5.5:
@Inject
private SqlSession session;
or
@Inject
@Mapper
private InerfaceXXXMapper mapper;
Eclipse IDE gives me a warning at the @Inject mentioned above:
"No bean is eligible for injection to the injection point [JSR-299 §5.2.1]"
I have a Producer method with ApplicationScoped:
@ApplicationScoped
@produces
public SqlSessionFactory produceFactory() {...}
When I run my application on WebSphere Liberty Profile V8.5 it works since it does not have injection points validation at start up. When the application is accessed the @produces method is called and the factory is loaded with session and mapper proxies.This scenario works fine.
However, when I run my application on the Application Server Full, it uses the OpenWebBeans CDI Container and it tries to validate all injection points at startup, but does not find any class of type "SqlSession" or "InerfaceXXXMapper" being produced. The type produced is "SqlSessionFactory" that holds the proxys for SqlSession and its Mappers registred.
Here is the exception I get at start up:
[7/23/15 16:33:42:226 BRT] 000000b0 WebContainerL I WebContainerLifecycle startApplication OpenWebBeans Container is starting...
[7/23/15 16:33:44:486 BRT] 000000b0 Extension I MyBatis CDI Module - Activated
[7/23/15 16:33:46:196 BRT] 000000b0 BeansDeployer E BeansDeployer deploy
javax.enterprise.inject.UnsatisfiedResolutionException: Api type [org.apache.ibatis.session.SqlSession] is not found with the qualifiers
How can I make it work?
Thanks,
Isaias
The text was updated successfully, but these errors were encountered: