Code Monkey home page Code Monkey logo

Comments (12)

christianpoitras avatar christianpoitras commented on June 8, 2024

Try adding @ApplicationScoped to your SqlSessionFactoryProvider.

from cdi.

pholding avatar pholding commented on June 8, 2024

I've just tried adding @ApplicationScoped to the SqlSessionFactoryProvider class but I'm still getting a MybatisCdiConfigurationException thrown with the description "There are no SqlSessionFactory producers properly configured."

from cdi.

christianpoitras avatar christianpoitras commented on June 8, 2024

I guess it will be difficult to find the reason why Weld behaves differently in 2.2.2 compared to 2.1.2.

My only other suggestion would be to force the declaration of the bean in beans.xml and see if that helps.
You could also try to add the Default and/or Any annotation to qualifiers.

beans = beanManager.getBeans(SqlSessionFactory.class, new AnnotationLiteral() {});

from cdi.

pholding avatar pholding commented on June 8, 2024

I've tried adding @Default and @Any to the method but the problem still remains.

I've also found out that there seems to be a GlassFish specific release of Weld, although I don't know what is different between the standard release and the GlassFish release, and there doesn't appear to be a GlassFish specific release of Weld 2.1.2 in Maven Central. I tried downloading the GlassFish release of Weld 2.2.10.SP1 from Maven Central (https://repo1.maven.org/maven2/org/jboss/weld/weld-osgi-bundle/2.2.10.SP1/) but that didn't fix the problem either.

Any idea how I would force the declaration of SqlSessionFactoryProvider in beans.xml? I've taken a look on Google but the only examples I can find are for declaring interceptors and decorators.

from cdi.

christianpoitras avatar christianpoitras commented on June 8, 2024

Normally, using

beans = beanManager.getBeans(SqlSessionFactory.class, new AnnotationLiteral() {});

CDI should return all SqlSessionFactory beans. To test this, you will need to create your own copy of mybatis-cdi.

After checking, it is not possible to force the declaration of a bean in beans.xml. You can only force the use of alternatives. I am not a CDI expert, sorry.

from cdi.

pholding avatar pholding commented on June 8, 2024

I've copied the various classes that make up mybatis-cdi directly into my program and have registered the extension in META-INF/services/javax.enterprise.inject.spi.Extension, and I can now successfully inject mappers into my program and run queries using MyBatis.

Given that this works in Weld without any changes and also in GlassFish when I copy the mybatis-cdi classes into my program, I'm wondering whether this is either a bug in GlassFish itself or the GlassFish specific release of Weld.

from cdi.

christianpoitras avatar christianpoitras commented on June 8, 2024

Thanks. That's an interesting bit of information. I'll have a look into it and see if there is anything to do to solve the issue.

from cdi.

hazendaz avatar hazendaz commented on June 8, 2024

Just a few ideas...

Could this have something to do with beans.xml not being setup for 2.2.x? While it is not required in glassfish 4.1, if I recall correctly, what it does changed. Annotations are default now.


Other possible issue is the fact that newer CDI no longer just injects things for sake of injection. It requires a scope regardless. @dependent is the scope that should be set on anything that is performing injection if no scope is to be listed meaning it is going to be part of some other scope. So lets us say the piece you didn't show where you are @Inject on the producer you have, does that class have a scope itself?

from cdi.

fgianneschi avatar fgianneschi commented on June 8, 2024

I'm running WildFly 8.2.1 and I've the same problem. Any updates?

from cdi.

sjljsw avatar sjljsw commented on June 8, 2024

hello ,I run glassfish 4.1 or payrar, the same and you have the same problem. You do not know the problem has been solved? I am very anxious to solve this problem.My weld-osgi-bundle upgrade to 2.3.2.final. Can not solve the problem.

I suspect that
beans = beanManager.getBeans(SqlSessionFactory.class, qualifiers.toArray(new Annotation[]{}));.
Can not find an instance

from cdi.

quarkalone avatar quarkalone commented on June 8, 2024

Hello,
I'm having a difficult time with glassfish 4.1. Does anyone have a working example? Currently, when I try to inject a mapper I get this message in the log:

Severe: Error Rendering View[/index.xhtml]
org.mybatis.cdi.MybatisCdiConfigurationException: There are no SqlSessionFactory producers properly configured.

However, some lines before I get:
Info: MyBatis CDI Module - Activated
Info: MyBatis CDI Module - Mapper dependency discovered: org.jayasoft.mapper.PersonaMapper

Regards.

from cdi.

mnesarco avatar mnesarco commented on June 8, 2024

Hi, I have tested the beta5 against Payara 4.1 (Glassfish 4.1) and TomEE-Plus 7.0.1.
The test code can be found here: https://github.com/mnesarco/mybatis-cdi-samples

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.