Hi there
I develop a custom feature which registers an OutInterceptor which invokes
another webservice within the handleMessage method. The idea is to use
injection and configure the jaxws:client bean in the spring configuration.
There are two options:
1) set/get Method in Feature class
2) Java Resource annotation in Feature class
Both doesn't work for me.
option 1:
---------
public class MyFeature...
....
public EncryptionInterfaceV10 getEncryptionProxy() {
return encryptionProxy;
}
public void setEncryptionProxy(EncryptionInterfaceV10 encryptionProxy) {
this.encryptionProxy = encryptionProxy;
}
...
Here the configuration on the client side:
<cxf:bus>
<cxf:features>
<ref bean="MyFeature"/>
</cxf:features>
</cxf:bus>
<jaxws:client id="encryptionProxyId"
xmlns:ns1="...."
serviceClass="..."
wsdlLocation="...."
serviceName="..."
endpointName="...."
address="..." />
<bean id="MyFeature" class="MyFeature">
<property name="encryptionProxy">
<ref bean="encryptionProxyId" />
</property>
</bean>
When I run the cxf client, I get the following exception:
05.09.2008 13:48:06 org.apache.cxf.bus.spring.SpringBusFactory createBus
WARNUNG: Failed to create application context.
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'cxf': Cannot resolve reference to bean 'PMPFeature' while setting
bean property 'features' with key [0]; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'PMPFeature' defined in class path resource [client.xml]: Cannot
resolve reference to bean 'encryptionProxyId' while setting bean property
'encryptionProxy'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'encryptionProxyId': Instantiation of bean failed; nested exception
is org.springframework.beans.factory.BeanDefinitionStoreException: Factory
method [public java.lang.Object
org.apache.cxf.frontend.ClientProxyFactoryBean.create()] threw exception;
nested exception is java.lang.NullPointerException
Caused by: org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'PMPFeature' defined in class path resource
[client.xml]: Cannot resolve reference to bean 'encryptionProxyId' while
setting bean property 'encryptionProxy'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'encryptionProxyId': Instantiation of bean failed; nested exception
is org.springframework.beans.factory.BeanDefinitionStoreException: Factory
method [public java.lang.Object
org.apache.cxf.frontend.ClientProxyFactoryBean.create()] threw exception;
nested exception is java.lang.NullPointerException
Caused by: org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'encryptionProxyId': Instantiation of bean failed;
nested exception is
org.springframework.beans.factory.BeanDefinitionStoreException: Factory method
[public java.lang.Object
org.apache.cxf.frontend.ClientProxyFactoryBean.create()] threw exception;
nested exception is java.lang.NullPointerException
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException:
Factory method [public java.lang.Object
org.apache.cxf.frontend.ClientProxyFactoryBean.create()] threw exception;
nested exception is java.lang.NullPointerException
Caused by: java.lang.NullPointerException
Option 2:
---------
public class MyFeature...
...
@Resource(name = "encryptionProxyId")
private EncryptionInterfaceV10 encryptionProxy;
...
The proxy instance is null. It looks like that CXF doesn't try to initialize it
at all.
I don't understand why injection doesn't work in this situation whereas it
works fine for a jaxws:endpoint bean.
Any ideas?
Thanks
Oliver