spring mapper beans / MapperScannerConfigurer

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

spring mapper beans / MapperScannerConfigurer

eckardjf
I am fairly new to both spring & mybatis - while creating a sample
project I encountered a strange error I can't seem to figure out - any
help would be appreciated.

Using the mybatis generator, I created artifacts (models, mappers &
xml) for a just a few of the 800+ total tables of an existing
database.
I was then able to successfully inject one of the mappers into a
service bean, and run a simple unit test to verify actual data was
being rerieved from the database.

However, when I created artifacts for all of the tables and attempted
to run the same unit test, I get:

... lines omitted ...

16:54:36.984 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory -
Creating shared instance of singleton bean 'userLoginMapper'
16:54:36.984 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory -
Creating instance of bean 'userLoginMapper'
16:54:36.985 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory -
Eagerly caching bean 'userLoginMapper' to allow for resolving
potential circular references
16:54:36.985 [main] DEBUG o.s.b.f.annotation.InjectionMetadata -
Processing injected method of bean 'userLoginMapper':
AutowiredMethodElement for public final void
org.mybatis.spring.support.SqlSessionDaoSupport.setSqlSessionTemplate(org.mybatis.spring.SqlSessionTemplate)
16:54:36.986 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory -
Returning cached instance of singleton bean
'org.springframework.transaction.config.internalTransactionAdvisor'
16:54:36.986 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory -
Returning eagerly cached instance of singleton bean 'userLoginMapper'
that is not fully initialized yet - a consequence of a circular
reference
16:54:36.987 [main] DEBUG o.s.b.f.annotation.InjectionMetadata -
Processing injected method of bean 'userLoginMapper':
AutowiredMethodElement for public final void
org.mybatis.spring.support.SqlSessionDaoSupport.setSqlSessionFactory(org.apache.ibatis.session.SqlSessionFactory)
16:54:36.988 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory -
Returning cached instance of singleton bean 'sqlSessionFactory'
16:54:37.135 [main] ERROR o.s.web.context.ContextLoader - Context
initialization failed
java.lang.NoClassDefFoundError:
org.springframework.beans.BeansException
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:
527) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:
456) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory
$1.getObject(AbstractBeanFactory.java:294) ~[spring-
beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:
225) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:
291) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:
193) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:
585) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:
913) ~[spring-context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:
464) ~[spring-context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:
385) ~[spring-web-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:
284) ~[spring-web-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:
111) [spring-web-3.1.1.RELEASE.jar:3.1.1.RELEASE]


At one point I discovered that if I did nothing else but reduce the
number of mapper interfaces to some number below 370-375, the problem
goes away.
Which mappers I choose makes no difference, as long as the number is
below 370 - and if I choose to include a number between 370 and 375,
it appears to be random whether the problem occurs or not.

org.springframework.beans.BeansException is clearly on the
classpath... I thought it might be a memory problem, so I tried
running with -Xmx512m and -Xmx1024m but neither helped.

Reply | Threaded
Open this post in threaded view
|

Re: spring mapper beans / MapperScannerConfigurer

joseluis@i2e.es
This post has NOT been accepted by the mailing list yet.
I have the same problem in the deployment of an application. Have you solved the error? Would I could say as?
Reply | Threaded
Open this post in threaded view
|

Re: spring mapper beans / MapperScannerConfigurer

jose luis ramirez
In reply to this post by eckardjf
I have the same problem in the deployment of an application. Have you solved the error? Would I could say as?

El sábado, 14 de abril de 2012 23:21:38 UTC+2, eckardjf escribió:
I am fairly new to both spring & mybatis - while creating a sample
project I encountered a strange error I can't seem to figure out - any
help would be appreciated.

Using the mybatis generator, I created artifacts (models, mappers &
xml) for a just a few of the 800+ total tables of an existing
database.
I was then able to successfully inject one of the mappers into a
service bean, and run a simple unit test to verify actual data was
being rerieved from the database.

However, when I created artifacts for all of the tables and attempted
to run the same unit test, I get:

... lines omitted ...

16:54:36.984 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory -
Creating shared instance of singleton bean 'userLoginMapper'
16:54:36.984 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory -
Creating instance of bean 'userLoginMapper'
16:54:36.985 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory -
Eagerly caching bean 'userLoginMapper' to allow for resolving
potential circular references
16:54:36.985 [main] DEBUG o.s.b.f.annotation.InjectionMetadata -
Processing injected method of bean 'userLoginMapper':
AutowiredMethodElement for public final void
org.mybatis.spring.support.SqlSessionDaoSupport.setSqlSessionTemplate(org.mybatis.spring.SqlSessionTemplate)
16:54:36.986 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory -
Returning cached instance of singleton bean
'org.springframework.transaction.config.internalTransactionAdvisor'
16:54:36.986 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory -
Returning eagerly cached instance of singleton bean 'userLoginMapper'
that is not fully initialized yet - a consequence of a circular
reference
16:54:36.987 [main] DEBUG o.s.b.f.annotation.InjectionMetadata -
Processing injected method of bean 'userLoginMapper':
AutowiredMethodElement for public final void
org.mybatis.spring.support.SqlSessionDaoSupport.setSqlSessionFactory(org.apache.ibatis.session.SqlSessionFactory)
16:54:36.988 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory -
Returning cached instance of singleton bean 'sqlSessionFactory'
16:54:37.135 [main] ERROR o.s.web.context.ContextLoader - Context
initialization failed
java.lang.NoClassDefFoundError:
org.springframework.beans.BeansException
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:
527) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:
456) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory
$1.getObject(AbstractBeanFactory.java:294) ~[spring-
beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:
225) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:
291) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:
193) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:
585) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:
913) ~[spring-context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:
464) ~[spring-context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:
385) ~[spring-web-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:
284) ~[spring-web-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:
111) [spring-web-3.1.1.RELEASE.jar:3.1.1.RELEASE]


At one point I discovered that if I did nothing else but reduce the
number of mapper interfaces to some number below 370-375, the problem
goes away.
Which mappers I choose makes no difference, as long as the number is
below 370 - and if I choose to include a number between 370 and 375,
it appears to be random whether the problem occurs or not.

org.springframework.beans.BeansException is clearly on the
classpath... I thought it might be a memory problem, so I tried
running with -Xmx512m and -Xmx1024m but neither helped.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: spring mapper beans / MapperScannerConfigurer

Babu Saginadham
In reply to this post by eckardjf
Any update on this issue??

Anybody found what could be an issue.. and how we can resolve if we have more tables to configure..

Thanks


On Sunday, 15 April 2012 02:51:38 UTC+5:30, eckardjf wrote:
I am fairly new to both spring & mybatis - while creating a sample
project I encountered a strange error I can't seem to figure out - any
help would be appreciated.

Using the mybatis generator, I created artifacts (models, mappers &
xml) for a just a few of the 800+ total tables of an existing
database.
I was then able to successfully inject one of the mappers into a
service bean, and run a simple unit test to verify actual data was
being rerieved from the database.

However, when I created artifacts for all of the tables and attempted
to run the same unit test, I get:

... lines omitted ...

16:54:36.984 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory -
Creating shared instance of singleton bean 'userLoginMapper'
16:54:36.984 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory -
Creating instance of bean 'userLoginMapper'
16:54:36.985 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory -
Eagerly caching bean 'userLoginMapper' to allow for resolving
potential circular references
16:54:36.985 [main] DEBUG o.s.b.f.annotation.InjectionMetadata -
Processing injected method of bean 'userLoginMapper':
AutowiredMethodElement for public final void
org.mybatis.spring.support.SqlSessionDaoSupport.setSqlSessionTemplate(org.mybatis.spring.SqlSessionTemplate)
16:54:36.986 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory -
Returning cached instance of singleton bean
'org.springframework.transaction.config.internalTransactionAdvisor'
16:54:36.986 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory -
Returning eagerly cached instance of singleton bean 'userLoginMapper'
that is not fully initialized yet - a consequence of a circular
reference
16:54:36.987 [main] DEBUG o.s.b.f.annotation.InjectionMetadata -
Processing injected method of bean 'userLoginMapper':
AutowiredMethodElement for public final void
org.mybatis.spring.support.SqlSessionDaoSupport.setSqlSessionFactory(org.apache.ibatis.session.SqlSessionFactory)
16:54:36.988 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory -
Returning cached instance of singleton bean 'sqlSessionFactory'
16:54:37.135 [main] ERROR o.s.web.context.ContextLoader - Context
initialization failed
java.lang.NoClassDefFoundError:
org.springframework.beans.BeansException
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:
527) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:
456) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory
$1.getObject(AbstractBeanFactory.java:294) ~[spring-
beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:
225) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:
291) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:
193) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:
585) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:
913) ~[spring-context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:
464) ~[spring-context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:
385) ~[spring-web-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:
284) ~[spring-web-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:
111) [spring-web-3.1.1.RELEASE.jar:3.1.1.RELEASE]


At one point I discovered that if I did nothing else but reduce the
number of mapper interfaces to some number below 370-375, the problem
goes away.
Which mappers I choose makes no difference, as long as the number is
below 370 - and if I choose to include a number between 370 and 375,
it appears to be random whether the problem occurs or not.

org.springframework.beans.BeansException is clearly on the
classpath... I thought it might be a memory problem, so I tried
running with -Xmx512m and -Xmx1024m but neither helped.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: spring mapper beans / MapperScannerConfigurer

Iwao AVE!
Hi Babu,

Here's a ticket reporting a similar issue.
https://github.com/mybatis/spring/issues/26
The reporter seemed to have solved the issue, but didn't write how,
unfortunately.
It might be worth leaving a comment there.

As it's most likely be a memory issue, you should try common
troubleshooting methods like using VisualVM.

Regards,
Iwao

2014-04-07 18:20 GMT+09:00 Babu Saginadham <[hidden email]>:

> Any update on this issue??
>
> Anybody found what could be an issue.. and how we can resolve if we have
> more tables to configure..
>
> Thanks
>
>
> On Sunday, 15 April 2012 02:51:38 UTC+5:30, eckardjf wrote:
>>
>> I am fairly new to both spring & mybatis - while creating a sample
>> project I encountered a strange error I can't seem to figure out - any
>> help would be appreciated.
>>
>> Using the mybatis generator, I created artifacts (models, mappers &
>> xml) for a just a few of the 800+ total tables of an existing
>> database.
>> I was then able to successfully inject one of the mappers into a
>> service bean, and run a simple unit test to verify actual data was
>> being rerieved from the database.
>>
>> However, when I created artifacts for all of the tables and attempted
>> to run the same unit test, I get:
>>
>> ... lines omitted ...
>>
>> 16:54:36.984 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory -
>> Creating shared instance of singleton bean 'userLoginMapper'
>> 16:54:36.984 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory -
>> Creating instance of bean 'userLoginMapper'
>> 16:54:36.985 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory -
>> Eagerly caching bean 'userLoginMapper' to allow for resolving
>> potential circular references
>> 16:54:36.985 [main] DEBUG o.s.b.f.annotation.InjectionMetadata -
>> Processing injected method of bean 'userLoginMapper':
>> AutowiredMethodElement for public final void
>>
>> org.mybatis.spring.support.SqlSessionDaoSupport.setSqlSessionTemplate(org.mybatis.spring.SqlSessionTemplate)
>> 16:54:36.986 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory -
>> Returning cached instance of singleton bean
>> 'org.springframework.transaction.config.internalTransactionAdvisor'
>> 16:54:36.986 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory -
>> Returning eagerly cached instance of singleton bean 'userLoginMapper'
>> that is not fully initialized yet - a consequence of a circular
>> reference
>> 16:54:36.987 [main] DEBUG o.s.b.f.annotation.InjectionMetadata -
>> Processing injected method of bean 'userLoginMapper':
>> AutowiredMethodElement for public final void
>>
>> org.mybatis.spring.support.SqlSessionDaoSupport.setSqlSessionFactory(org.apache.ibatis.session.SqlSessionFactory)
>> 16:54:36.988 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory -
>> Returning cached instance of singleton bean 'sqlSessionFactory'
>> 16:54:37.135 [main] ERROR o.s.web.context.ContextLoader - Context
>> initialization failed
>> java.lang.NoClassDefFoundError:
>> org.springframework.beans.BeansException
>>         at
>>
>> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:
>> 527) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
>>         at
>>
>> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:
>> 456) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
>>         at org.springframework.beans.factory.support.AbstractBeanFactory
>> $1.getObject(AbstractBeanFactory.java:294) ~[spring-
>> beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
>>         at
>>
>> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:
>> 225) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
>>         at
>>
>> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:
>> 291) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
>>         at
>>
>> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:
>> 193) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
>>         at
>>
>> org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:
>> 585) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
>>         at
>>
>> org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:
>> 913) ~[spring-context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
>>         at
>>
>> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:
>> 464) ~[spring-context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
>>         at
>>
>> org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:
>> 385) ~[spring-web-3.1.1.RELEASE.jar:3.1.1.RELEASE]
>>         at
>>
>> org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:
>> 284) ~[spring-web-3.1.1.RELEASE.jar:3.1.1.RELEASE]
>>         at
>>
>> org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:
>> 111) [spring-web-3.1.1.RELEASE.jar:3.1.1.RELEASE]
>>
>>
>> At one point I discovered that if I did nothing else but reduce the
>> number of mapper interfaces to some number below 370-375, the problem
>> goes away.
>> Which mappers I choose makes no difference, as long as the number is
>> below 370 - and if I choose to include a number between 370 and 375,
>> it appears to be random whether the problem occurs or not.
>>
>> org.springframework.beans.BeansException is clearly on the
>> classpath... I thought it might be a memory problem, so I tried
>> running with -Xmx512m and -Xmx1024m but neither helped.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "mybatis-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [hidden email].
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: spring mapper beans / MapperScannerConfigurer

Hei Man Chan
In reply to this post by eckardjf
Same problem here. Any solution??

eckardjf於 2012年4月15日星期日 UTC+8上午5時21分38秒寫道:
I am fairly new to both spring & mybatis - while creating a sample
project I encountered a strange error I can't seem to figure out - any
help would be appreciated.

Using the mybatis generator, I created artifacts (models, mappers &
xml) for a just a few of the 800+ total tables of an existing
database.
I was then able to successfully inject one of the mappers into a
service bean, and run a simple unit test to verify actual data was
being rerieved from the database.

However, when I created artifacts for all of the tables and attempted
to run the same unit test, I get:

... lines omitted ...

16:54:36.984 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory -
Creating shared instance of singleton bean 'userLoginMapper'
16:54:36.984 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory -
Creating instance of bean 'userLoginMapper'
16:54:36.985 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory -
Eagerly caching bean 'userLoginMapper' to allow for resolving
potential circular references
16:54:36.985 [main] DEBUG o.s.b.f.annotation.InjectionMetadata -
Processing injected method of bean 'userLoginMapper':
AutowiredMethodElement for public final void
org.mybatis.spring.support.SqlSessionDaoSupport.setSqlSessionTemplate(org.mybatis.spring.SqlSessionTemplate)
16:54:36.986 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory -
Returning cached instance of singleton bean
'org.springframework.transaction.config.internalTransactionAdvisor'
16:54:36.986 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory -
Returning eagerly cached instance of singleton bean 'userLoginMapper'
that is not fully initialized yet - a consequence of a circular
reference
16:54:36.987 [main] DEBUG o.s.b.f.annotation.InjectionMetadata -
Processing injected method of bean 'userLoginMapper':
AutowiredMethodElement for public final void
org.mybatis.spring.support.SqlSessionDaoSupport.setSqlSessionFactory(org.apache.ibatis.session.SqlSessionFactory)
16:54:36.988 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory -
Returning cached instance of singleton bean 'sqlSessionFactory'
16:54:37.135 [main] ERROR o.s.web.context.ContextLoader - Context
initialization failed
java.lang.NoClassDefFoundError:
org.springframework.beans.BeansException
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:
527) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:
456) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory
$1.getObject(AbstractBeanFactory.java:294) ~[spring-
beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:
225) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:
291) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:
193) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:
585) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:
913) ~[spring-context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:
464) ~[spring-context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:
385) ~[spring-web-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:
284) ~[spring-web-3.1.1.RELEASE.jar:3.1.1.RELEASE]
        at
org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:
111) [spring-web-3.1.1.RELEASE.jar:3.1.1.RELEASE]


At one point I discovered that if I did nothing else but reduce the
number of mapper interfaces to some number below 370-375, the problem
goes away.
Which mappers I choose makes no difference, as long as the number is
below 370 - and if I choose to include a number between 370 and 375,
it appears to be random whether the problem occurs or not.

org.springframework.beans.BeansException is clearly on the
classpath... I thought it might be a memory problem, so I tried
running with -Xmx512m and -Xmx1024m but neither helped.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.