NullPointerException when using Mapper

35 views
Skip to first unread message

Javier Domingo

unread,
Apr 23, 2012, 7:00:25 AM4/23/12
to mybati...@googlegroups.com
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

Javier Domingo

unread,
Apr 22, 2012, 7:37:12 PM4/22/12
to mybati...@googlegroups.com
mybatis-mail.7z

Eduardo Macarron

unread,
Apr 23, 2012, 11:45:01 AM4/23/12
to mybati...@googlegroups.com
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>

Javier Domingo

unread,
Apr 23, 2012, 5:50:18 PM4/23/12
to mybati...@googlegroups.com

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

Reply all
Reply to author
Forward
0 new messages