Quantcast

NullPointerException when using Mapper

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

NullPointerException when using Mapper

Javier Domingo
Hi,

I have been doing a webapp (a CRUD interface for a db) and I am using as guideline the jpetstore, with the exception that:
  1. I am also using the mybatis-generator's code. 
  2. Services. I don't want to have services as a separate part. I want to use the Mappers directly on the Action bean
  3. I have all mappers.xml, mappers.java, example.java and entities.java (all the generator's code) in one folder (org.lmb97.data)
And I am encountering a NullPointerException when I try to use a mapper. I checked all I could, but still not getting to the solution. I don't know which is the problem. Everything has been said... but no idea. I think it is something with the configuration. I have checked various bugs in the bug tracker that seemed to be related but none was.

I am attaching apache tomcat's log and the normal log. log4j is configured in ALL. And the repo is here[1], I am putting the exact commit, so that if I work with the repo, you can see the actual state.

The netbeans project is configured so that if you clone it, you have all libraries included with it, with no external dependencies.

I will be waiting for your reply, and don't hesitate mailing me to ask for more data,

Sincerely,

Javier Domingo


mybatis-mail.7z (30K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

NullPointerException when using Mapper

Javier Domingo
Hi,

I have been doing a webapp (a CRUD interface for a db) and I am using as guideline the jpetstore, with the exception that:
  1. I am also using the mybatis-generator's code. 
  2. Services. I don't want to have services as a separate part. I want to use the Mappers directly on the Action bean
  3. I have all mappers.xml, mappers.java, example.java and entities.java (all the generator's code) in one folder (org.lmb97.data)
And I am encountering a NullPointerException when I try to use a mapper. I checked all I could, but still not getting to the solution. I don't know which is the problem. Everything has been said... but no idea. I think it is something with the configuration. I have checked various bugs in the bug tracker that seemed to be related but none was.

I am attaching apache tomcat's log and the normal log. log4j is configured in ALL. And the repo is here[1], I am putting the exact commit, so that if I work with the repo, you can see the actual state.

The netbeans project is configured so that if you clone it, you have all libraries included with it, with no external dependencies.

I will be waiting for your reply, and don't hesitate mailing me to ask for more data,

Sincerely,

Javier Domingo



mybatis-mail.7z (30K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: NullPointerException when using Mapper

Eduardo Macarron
Hola Javier,

basePackage property is a package name, so this:
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="org.lmb97.data.*Mapper" />
 </bean>

should be:
 <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="org.lmb97.data" />
 </bean>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: NullPointerException when using Mapper

Javier Domingo

Hola, gracias! 

Yes that was a problem, but the one that was giving problems was that @Autowire is used in Spring managed ones, for Stripes ones, I have to use @SpringBean. Doing both solved the problems.

The related StackOverflow question is this:

http://stackoverflow.com/questions/10280004/nullpointerexception-using-spring-to-autowire-mybatis-mapper

I didn't have any real mybatis problems still :D

Cheers

El 23/04/2012 17:45, "Eduardo Macarron" <[hidden email]> escribió:
Hola Javier,

basePackage property is a package name, so this:
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
       <property name="basePackage" value="org.lmb97.data.*Mapper" />
 </bean>

should be:
 <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
       <property name="basePackage" value="org.lmb97.data" />
 </bean>
Loading...