Giter VIP home page Giter VIP logo

Comments (10)

hazendaz avatar hazendaz commented on July 29, 2024

from cdi.

FuoriDiTesta avatar FuoriDiTesta commented on July 29, 2024

With weld, to be honest, no, but if i'm not wrong, Weld doesn't support EJB.... or i'm wrong?

from cdi.

mnesarco avatar mnesarco commented on July 29, 2024

@FuoriDiTesta I have downloaded your sample.zip project. unziped and run mvn test. It does not compile.

MybatisFactoryProducers.java:[6,29] package org.apache.derby.jdbc does not exist

So there is some problem in your configuration.

from cdi.

mnesarco avatar mnesarco commented on July 29, 2024

@FuoriDiTesta after I have fixed your derby dependecy, I tried:

mvn -P arquillian-jbossas-managed test ...... [No Errors]
mvn -P GlassFish test ................................... [No Errors]
mvn -P tomee-embedded test ........................ [No Errors]

So I will close this now. If you provide new evidence this can be reopened. But I recommend you to move to mybatis-cdi-1.1.0 anyway.

from cdi.

mnesarco avatar mnesarco commented on July 29, 2024

@FuoriDiTesta Ok, your sample zip is not running any test, I just figured it now, your class ArquillianMyBatisSample must be named ArquillianMyBatisSampleTest to be executed in tests.

  1. I fixed the class name and your reported exception appears.
  2. I have upgraded to mybatis-cdi-1.1.0 and the problem remains.

This requires further investigation.

from cdi.

mnesarco avatar mnesarco commented on July 29, 2024

@FuoriDiTesta, I am not an Arquillian user. Please provide more info/tests to help us encounter the problem. I suspect the problem is not in mybatis-cdi but in your configuration, but because I do not know Arquillian, I can be wrong. One possible test is to setup a project using tomcat embedded without Arquillian.

from cdi.

rpdeadly avatar rpdeadly commented on July 29, 2024

I have the same problem with Arquillian. I've traced the problem to how @Mapper is injected.

public static SqlSessionManagerRegistry getRegistry(CreationalContext creationalContext) {
final BeanManager beanManager = getBeanManager();
Iterator<Bean<?>> beans = beanManager.getBeans(SqlSessionManagerRegistry.class).iterator();
return (SqlSessionManagerRegistry) beanManager.getReference(beans.next(), SqlSessionManagerRegistry.class,
creationalContext);
}

SqlSessionManagerRegistry.class is not managed by CDI and the call to beanManager returns an empty iterator.

from cdi.

rpdeadly avatar rpdeadly commented on July 29, 2024

Injecting SqlSessionFactory seems to work. So a work around to this problem is to call sqlSessionFactory.openSession().getMapper( ) to instantiate your DAO class.

from cdi.

mnesarco avatar mnesarco commented on July 29, 2024

SqlSessionManagerRegistry.class is not managed by CDI and the call to beanManager returns an empty iterator.

SqlSessionManagerRegistry actually IS a managed bean:

https://github.com/mybatis/cdi/blob/master/src/main/java/org/mybatis/cdi/SqlSessionManagerRegistry.java

from cdi.

hazendaz avatar hazendaz commented on July 29, 2024

Few years later, trying to clean things up so I took the download which was a mess as noted here. I fixed the same issues but got it to work. Arquillian requires 'SqlSessionManagerRegistry.class' added or it will not load it. Once it loads it, it works fine with the test product. To save others work if they stumble on this, I have updated the sample project. It should work with simple 'mvn clean install' or however you like. It is tied to the snapshot of this project now though so I could confirm latest changes I've been doing don't break anything.

ArquillianMybatisExample.zip.

I'm going to add a note to readme specifically for arquillian as this was first I have ever used it and the issue was considerably hard to figure out.

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.