问题
My project uses spring and spring-dm for bean/service configuration. When I try to import an old project which also use spring for DI, bean will not be created.
An example to make clear,
I first define a url-alias in spring-appContext.xml
<bean name="xxxx" class="XRegistry" init-method="init">
<property name="webRoot" value="/WebContent"></property>
<property name="alias" value="/test"></property>
<property name="cAliasPattern" value="/test/*.do" />
<property name="conConfigFile" value="ddd.xml"/>
</bean>
in ddd.xml, I define some controller bean with url like /test/abc.do
No errors occur when launching as OSGi framework in eclipse. But when I try to access the URL(/test/abc.do),"Unknown OSGi URL:" is met.
The problem really confuses me is I am not clear where to start. My bundle has depended on spring bundles and have appContext.xml and dispatcher.xml. Just a normal spring usage scenario.
As spring looks like black box to me, I can only try some other possible reasons I can think, but haven't fixed it till now. Is somebody know how to moniter the spring startup process or helpful logs?
Thanks.
Edit when using spring-dm, you need to create a new fragment including log4j.properties to enable logging. This can help u to track spring startuping error.
As I explain in the 1st answer, the root cause is found, two choice,
- For those bundles exist in both workspace and target platform, increase the bundle's version in current workspace. When error happens , you should also look into the dependency bundles
- Remove the high version bundles in target platform.
回答1:
Have you tried setting the log level for the spring framework to debug?
E.g.
log4j.rootLogger=WARN, stdout
[...]
log4j.logger.org.springframework=DEBUG
This is always my first starting point when trying to diagnose problems with bean creation.
来源:https://stackoverflow.com/questions/6967917/is-there-a-good-way-to-diagnose-spring-bean-service-creation-problem