History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: XFIRE-150
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Dan Diephouse
Reporter: Jara Cesnek
Votes: 1
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
XFire

Cant use Jsr181HandlerMapping with abstract beans in one context.

Created: 31/Oct/05 12:43 PM   Updated: 06/Dec/05 03:07 AM
Component/s: Annotations
Affects Version/s: 1.0-M5, 1.0-M6
Fix Version/s: 1.0-M6

Time Tracking:
Not Specified

Environment: xfire, Spring , jsr181


 Description  « Hide
When all working I add
<bean id="handlerMapping" class="org.codehaus.xfire.spring.remoting.Jsr181HandlerMapping">
<property name="typeMappingRegistry"><ref bean="xfire.typeMappingRegistry"/></property>
<property name="xfire"><ref bean="xfire"/></property>
<property name="webAnnotations">
<bean id="webAnnotations" class="org.codehaus.xfire.annotations.jsr181.Jsr181WebAnnotations"/>
</property>
</bean>
to my applicationContext.xml.

Now exception is thrown when any abstract=true bean is searched for annotation.

2005-10-31 19:23:57,440 DEBUG [org.codehaus.xfire.spring.remoting.Jsr181HandlerMapping] - <Rejected bean 'DAOModel' since it has no WebService annotation>
2005-10-31 19:23:57,480 ERROR [org.springframework.web.context.ContextLoader] - <Context initialization failed>
org.springframework.beans.factory.BeanIsAbstractException: Error creating bean with name 'TPFparent': Bean definition is abstract
at org.springframework.beans.factory.support.AbstractBeanFactory.checkMergedBeanDefinition(AbstractBeanFactory.java:752)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:213)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
at org.springframework.beans.factory.support.AbstractBeanFactory.getType(AbstractBeanFactory.java:342)
at org.springframework.context.support.AbstractApplicationContext.getType(AbstractApplicationContext.java:569)
at org.codehaus.xfire.spring.remoting.Jsr181HandlerMapping.initApplicationContext(Jsr181HandlerMapping.java:63)
at org.springframework.context.support.ApplicationObjectSupport.setApplicationContext(ApplicationObjectSupport.java:79)

Realy dont know if this is xfire or spring bug.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Igor Pavin - 08/Nov/05 04:46 AM
I'm sure, it's a XFire's problem. I have similar problem with abstract beans.

<bean id="webAnnotations" class="org.codehaus.xfire.annotations.jsr181.Jsr181WebAnnotations"/>

<bean id="handlerMapping" class="org.codehaus.xfire.spring.remoting.Jsr181HandlerMapping">
<property name="typeMappingRegistry" ref="xfire.typeMappingRegistry"/>
<property name="xfire" ref="xfire"/>
<property name="webAnnotations" ref="webAnnotations"/>
<property name="urlPrefix" value="/ws/"/>
</bean>

and I'm getting the NullPointerException:

Rejected bean 'org.springframework.web.servlet.handler.SimpleUrlHandlerMapping' since it has no WebService annotation
Rejected bean 'multipartResolver' since it has no WebService annotation
Rejected bean 'authorizationInterceptor' since it has no WebService annotation
...
Error creating bean with name 'handlerMapping' defined in ServletContext resource [/WEB-INF/applicationContext-webServices.xml]: Initialization of bean failed; nested exception is java.lang.NullPointerException: null
java.lang.NullPointerException
at org.codehaus.xfire.annotations.jsr181.Jsr181WebAnnotations.hasWebServiceAnnotation(Jsr181WebAnnotations.java:27)
at org.codehaus.xfire.spring.remoting.Jsr181HandlerMapping.initApplicationContext(Jsr181HandlerMapping.java:64)

If we peek into the org.codehaus.xfire.annotations.jsr181.Jsr181WebAnnotations.hasWebServiceAnnotation(...) at line 27
we will see the following:
return clazz.isAnnotationPresent(WebService.class);

I persume that the clazz instance for abstract beans is null.


Dan Diephouse - 08/Nov/05 09:17 AM
Thanks guys, I will try to get a fix for this in CVS today.

Dan Diephouse - 12/Nov/05 03:16 PM
parent contexts are now searched for beans.

Dan Diephouse - 12/Nov/05 03:18 PM
sorry, that previous comment was for another issue. Anyway, I check for abstract beans now. Give it a whirl and let me know if you still have problems.

Jara Cesnek - 29/Nov/05 04:56 AM
applicationContext.xml
<bean id="midasSOAPInterface" class="cz.marbes.daisy.sysmodules.jconnection.MergedMidas" abstract="true">
<property name="bliMidas"><ref bean="midas"/></property>
<property name="bliCommon"><ref bean="common"/></property>
<property name="bliKernel3"><ref bean="kernel3"/></property>
</bean>

sap-servlet.xml
<bean parent="midasSOAPInterface">
<property name="fsRegister"><ref local="fsRegister"/></property>
</bean>

2005-11-29 11:45:21,213 ERROR [org.springframework.web.servlet.DispatcherServlet] - <Context initialization failed>
org.springframework.beans.factory.BeanIsAbstractException: Error creating bean with name 'midasSOAPInterface': Bean definition is abstract
at org.springframework.beans.factory.support.AbstractBeanFactory.checkMergedBeanDefinition(AbstractBeanFactory.java:759)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:213)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:555)
at org.codehaus.xfire.spring.remoting.Jsr181HandlerMapping.processBeans(Jsr181HandlerMapping.java:91)
at org.codehaus.xfire.spring.remoting.Jsr181HandlerMapping.initApplicationContext(Jsr181HandlerMapping.java:54)


Jara Cesnek - 29/Nov/05 05:10 AM
One more comment:

Abstract bean in applicationContext HAS annotations,
but is realy used in ???-servlet.xml with customizing
property depends on child context.

Maybe this help.


Dan Diephouse - 01/Dec/05 03:03 PM
OK, this should be better now. If you could test that would be great! Looking to do a release tomorrow morning, so hopefully you're around before then...

Jara Cesnek - 02/Dec/05 02:54 AM
Cant test.
When all working I simply update the last xfire-all-1.0-SNAPSHOT.jar.
(I do not use commons-attributes bean in my beans definition.)

2005-12-02 09:24:56,768 DEBUG [org.codehaus.xfire.spring.remoting.Jsr181HandlerMapping] - <Rejected bean 'xfire.messageServiceFactory' since it has no WebService annotation>
2005-12-02 09:24:56,768 DEBUG [org.codehaus.xfire.spring.remoting.Jsr181HandlerMapping] - <Rejected bean 'xfire.messageBindingProvider' since it has no WebService annotation>
2005-12-02 09:24:56,768 DEBUG [org.codehaus.xfire.spring.remoting.Jsr181HandlerMapping] - <Rejected bean 'customEditorConfigurer' since it has no WebService annotation>
2005-12-02 09:24:56,768 ERROR [org.springframework.web.servlet.DispatcherServlet] - <Context initialization failed>
org.springframework.beans.factory.FactoryBeanNotInitializedException: Error creating bean with name 'commons-attributes': FactoryBean returned null object: probably not fully initialized (maybe due to circular bean reference)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForSharedInstance(AbstractBeanFactory.java:819)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:191)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:555)
at org.codehaus.xfire.spring.remoting.Jsr181HandlerMapping.processBeans(Jsr181HandlerMapping.java:72)
at org.codehaus.xfire.spring.remoting.Jsr181HandlerMapping.initApplicationContext(Jsr181HandlerMapping.java:54)
at org.springframework.context.support.ApplicationObjectSupport.setApplicationContext(ApplicationObjectSupport.java:79)
at org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:84)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:248)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:362)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:275)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:320)
at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:134)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:305)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:250)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:219)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:112)
at javax.servlet.GenericServlet.init(GenericServlet.java:211)

Simply put getBean(name) in try - catch and skip it all.

String[] names = applicationContext.getBeanDefinitionNames();
for(String name : names) {
try {
Object obj = applicationContext.getBean(name);
FsService anno = obj.getClass().getAnnotation(FsService.class);
if (anno==null) { logger.debug("Rejected bean '"+name+"' since it has no FsService annotation"); }else{
logger.info("Registering '"anno.name()"' from "+obj.getClass().getName());
if (anno.alias().length()>0) { logger.info("Registering '"+anno.alias()+"' from "+obj.getClass().getName()); }
registerMethodInFellowhip(obj,anno.name(),anno.alias());
}
}catch(Exception e){ logger.debug("Skip bean "+name+" reason "+e.getMessage()); }
}


Dan Diephouse - 02/Dec/05 01:17 PM
The getBean() is already in a try/catch. Are you sure you got the latest jar? Try the M6 release. I added a unit test for this and it works fine.

Jara Cesnek - 06/Dec/05 03:07 AM
Work fine.