0

i'm using MybBatis and i'm getting a ClassNotFound error which is in an exnternal project, and i'm using that class in the resultMap in one Mapper.xml file.
This is my code:

-Mapper.xml: I will only put the resultMapAquí solo colocaré el resultMap, as is the place where i'm getting problems.

<resultMap id="BaseResultMapGeneralConfig" type="classpath:com.iecisa.tecdoc.sirene.common.types.GeneralConfig">
    <id column="id" jdbcType="NUMERIC" property="id" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="value" jdbcType="VARCHAR" property="value" />
    <result column="type" jdbcType="NUMERIC" property="type" />
  </resultMap>  

Note that "type=com.etc...." is the Class in external proyect.
-The error code i'm getting:

Struts has detected an unhandled exception:

Messages:   
Cannot find class: classpath:com.iecisa.tecdoc.sirene.common.types.GeneralConfig
Could not resolve type alias 'classpath:com.iecisa.tecdoc.sirene.common.types.GeneralConfig'. Cause: java.lang.ClassNotFoundException: Cannot find class: classpath:com.iecisa.tecdoc.sirene.common.types.GeneralConfig
Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'classpath:com.iecisa.tecdoc.sirene.common.types.GeneralConfig'. Cause: java.lang.ClassNotFoundException: Cannot find class: classpath:com.iecisa.tecdoc.sirene.common.types.GeneralConfig
Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'classpath:com.iecisa.tecdoc.sirene.common.types.GeneralConfig'. Cause: java.lang.ClassNotFoundException: Cannot find class: classpath:com.iecisa.tecdoc.sirene.common.types.GeneralConfig
Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'classpath:com.iecisa.tecdoc.sirene.common.types.GeneralConfig'. Cause: java.lang.ClassNotFoundException: Cannot find class: classpath:com.iecisa.tecdoc.sirene.common.types.GeneralConfig
### Error building SqlSession. ### The error may exist in com/iecisa/tecdoc/sirene/db/map/SireneConfigMapper.xml ### The error occurred while processing mapper_resultMap[BaseResultMapGeneralConfig] ### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'classpath:com.iecisa.tecdoc.sirene.common.types.GeneralConfig'. Cause: java.lang.ClassNotFoundException: Cannot find class: classpath:com.iecisa.tecdoc.sirene.common.types.GeneralConfig
Error inicializando SqlSession. Causa: org.apache.ibatis.exceptions.PersistenceException: ### Error building SqlSession. ### The error may exist in com/iecisa/tecdoc/sirene/db/map/SireneConfigMapper.xml ### The error occurred while processing mapper_resultMap[BaseResultMapGeneralConfig] ### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'classpath:com.iecisa.tecdoc.sirene.common.types.GeneralConfig'. Cause: java.lang.ClassNotFoundException: Cannot find class: classpath:com.iecisa.tecdoc.sirene.common.types.GeneralConfig
Error creando SqlSession: java.lang.RuntimeException: Error inicializando SqlSession. Causa: org.apache.ibatis.exceptions.PersistenceException: ### Error building SqlSession. ### The error may exist in com/iecisa/tecdoc/sirene/db/map/SireneConfigMapper.xml ### The error occurred while processing mapper_resultMap[BaseResultMapGeneralConfig] ### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'classpath:com.iecisa.tecdoc.sirene.common.types.GeneralConfig'. Cause: java.lang.ClassNotFoundException: Cannot find class: classpath:com.iecisa.tecdoc.sirene.common.types.GeneralConfig  

I already added the external proyect in my main proyect in the Projects tab on Java Build Path and i also checked the external project check on Order and Export tab.

I tried differents ways, like put the class without the "classpath:", i didn't find the way to solve it.
Any idea? I did some mistake?
Thanks for the help!

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
M.Gea
  • 27
  • 1
  • 1
  • 8
  • Maybe this can help you: https://stackoverflow.com/questions/13501069/reusing-mybatis-resultmap-in-multiple-mapper-xml – Mario Petrovic Sep 20 '17 at 10:33
  • That seems to be another kind of problem, i only want to refer an external class in the type on the resultMap. Thanks btw @MarioPetrovic – M.Gea Sep 20 '17 at 10:45
  • I mean, it seems like `com.iecisa.tecdoc.sirene.common.types.GeneralConfig` isn't on the classpath. In any case, unrelated to S2 and XML, so detagging. – Dave Newton Sep 20 '17 at 14:00

1 Answers1

0

I got the solution. The problem was on the projects. My main project is a Maven project, but the external is not maven. So i just get the .jar of the external project, added it via maven on my main project and the dependences on the pom.xml.

And that's all, thanks for your help!

M.Gea
  • 27
  • 1
  • 1
  • 8