1
votes

I'm developing a Java EE application based on Mybatis 3.0.5, Mybatis-spring 1.0.1 and Spring 3.0.5.RELEASE and I've found a problem using Alias in mybatis-config.xml. The trace is:

org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'sqlSessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]:
Invocation of init method failed; nested exception is org.springframework.core.NestedIOException:
Failed to parse config resource: class path resource [mybatis-config.xml]; nested exception is org.apache.ibatis.builder.BuilderException:
Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException:
Error registering typeAlias for 'accesoUsuario'. Cause: java.lang.ClassNotFoundException:
Cannot find class: [PACKAGE OMITTED BY ME].AccesoUsuario

How can I resolve this problem?

This is my mybatis-config.xml (MYPACKAGE = es.my.package).

 <settings>
     <setting name="lazyLoadingEnabled" value="false" />
  </settings>

<typeAliases>
    <typeAlias alias="accesoUsuario" type="MYPACKAGE.persistencia.entidades.AccesoUsuario" />
    <typeAlias alias="agrupacion" type="MYPACKAGE.persistencia.entidades.Agrupacion" />
    <typeAlias alias="consulta" type="MYPACKAGE.persistencia.entidades.Consulta" />
    <typeAlias alias="consultaDim" type="MYPACKAGE.persistencia.entidades.ConsultaDim" />
    <typeAlias alias="consultaFiltro" type="MYPACKAGE.persistencia.entidades.ConsultaFiltro" />
    <typeAlias alias="dato" type="MYPACKAGE.persistencia.entidades.Dato" />
    <typeAlias alias="dimension" type="MYPACKAGE.persistencia.entidades.Dimension" />
            <typeAlias alias="dominio" type="MYPACKAGE.persistencia.entidades.Dominio" />
            <typeAlias alias="dominioDep" type="MYPACKAGE.persistencia.entidades.DominioDep" />
            <typeAlias alias="entidad" type="MYPACKAGE.persistencia.entidades.Entidad" />
    <typeAlias alias="error" type="MYPACKAGE.persistencia.entidades.ErrorProceso" />
    <typeAlias alias="informe" type="MYPACKAGE.persistencia.entidades.Informe" />
    <typeAlias alias="informeCabecera" type="MYPACKAGE.persistencia.entidades.InformeCabecera" />
    <typeAlias alias="informeSeccion" type="MYPACKAGE.persistencia.entidades.InformeSeccion" />
    <typeAlias alias="restriVariable" type="MYPACKAGE.persistencia.entidades.RestriVariable" />
    <typeAlias alias="usuario" type="MYPACKAGE.persistencia.entidades.Usuario" />
    <!-- ... -->
            <typeAlias alias="cadena" type="java.lang.String" />
</typeAliases>
2
Please post your mapping in the mybatis-config.xml file. - Seth

2 Answers

0
votes

Without seeing some of the actual source code, I doubt we can pinpoint any errors, but it might help to take a look at this example on DZone.

One thing they point out in particular is that if you do not follow the correct order in the mybatis-config.xml file, it can cause an exception. It could be that something is just in the wrong place in that file.

If you want to post more of the code, I can try to be of more help.

0
votes

You package is no available for myBatis. You need to define it using configuration:

<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
    <property name="basePackage" value="es.your.packacke"/>
</bean>