Tomee/CDI SEVERE: Type interface ke.chege.accounts.mybatis.OauthRepository is not known to the MapperRegistry

9 views
Skip to first unread message

Chege Kĩnũthia

unread,
Jun 29, 2020, 1:26:39 AM6/29/20
to mybatis-user
Hi,

I have a web application being developed on Apache Tomee 8.0.1 whose config looks as follows.

pom.xml

       <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
            <version>3.5.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis-cdi</artifactId>
            <version>1.1.1</version>
            <scope>provided</scope>
        </dependency>

mybatis.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
  PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
  "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
    <environments default="development">
        <environment id="development">
            <transactionManager type="MANAGED" >
                <!--<property-->
            </transactionManager>
            <dataSource type="JNDI">
                <property name="data_source" value="java:openejb/Resource/marketPlace" />
            </dataSource>
        </environment>
    </environments>
    <mappers>
        <mapper resource="oauth.xml"/>
    </mappers>
</configuration>

oauth.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="ke.chege.accounts.mybatis.OauthRepository">
.
.
.
</mapper>

CDI Producer

    @Produces
    @ApplicationScoped
    @SessionFactoryProvider
    public SqlSessionFactory produceFactory() throws Exception {
        InputStream inputStream = Resources.getResourceAsStream("mybatis.xml");
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
        return sqlSessionFactory;
    }


OauthRepository

import org.mybatis.cdi.Mapper;
@Mapper
public interface OauthRepository {
...
}

This setup works most of the time. The problem arises when netbeans reloads/redeploys which makes development painfully slow.

Stacktrace.

SEVERE: Type interface ke.chege.accounts.mybatis.OauthRepository is not known to the MapperRegistry.
org.apache.ibatis.binding.BindingException: Type interface ke.chege.accounts.mybatis.OauthRepository is not known to the MapperRegistry.
    at org.apache.ibatis.binding.MapperRegistry.getMapper(MapperRegistry.java:47)
    at org.apache.ibatis.session.Configuration.getMapper(Configuration.java:823)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.getMapper(DefaultSqlSession.java:291)
    at ke.chege.accounts.JdbcDataProvider.doGetClient(JdbcDataProvider.java:104)

Is there a workaround to this issue?

Thanks,
Chege.




Reply all
Reply to author
Forward
0 new messages