You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "Urciolo, Kevin" <Ke...@ngc.com> on 2008/05/04 20:51:41 UTC
RE: Using CXF In Existing Spring Context
Is this the correct way to do it? I have the Spring context loader servlet defined, spring mvc servlet, and the cxf servlet. The CXF servlet and the context loader server reference the contextConfigLocation.
Currently I get this when trying to create a client:
java.lang.NullPointerException
at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpointInfo(AbstractWSDLBasedEndpointFactory.java:160)
at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:102)
at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:51)
at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:97)
I get "No service was found" when pointing a web browser to the CXF servlet.
Here is the web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<servlet>
<servlet-name>context</servlet-name>
<servlet-class>
org.springframework.web.context.ContextLoaderServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>centraldispatcher</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<servlet>
<servlet-name>CXFServlet</servlet-name>
<servlet-class>
org.apache.cxf.transport.servlet.CXFServlet
</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
________________________________
From: Glen Mazza [mailto:glen.mazza@verizon.net]
Sent: Tue 4/22/2008 9:48 PM
To: cxf-user@incubator.apache.org
Subject: Re: Using CXF In Existing Spring Context
Steps #7 and #8 here (look at the web.xml and ws-beans.xml file):
http://www.jroller.com/gmazza/date/20080417#WFstep7
Also, you can configure multiple config files separated by commas,
similar to here to keep your web service stuff separate:
http://www.jroller.com/gmazza/date/20061128
HTH,
Glen
2008-04-22 Urciolo, Kevin wrote:
> I would like to use CXF in an existing spring context. The examples
> appear to have a CXF Servlet read a spring configuration file and create
> a separate context. I want to inject beans I have defined in an
> existing context in to my CXF services. What is the best way to
> accomplish this?
>
> Thanks
RE: Using CXF In Existing Spring Context
Posted by Glen Mazza <gl...@verizon.net>.
Can you access its WSDL from a browser? http://whatever/myservice?wsdl
That is a good first step in diagnosing SOAP client problems.
Glen
2008-05-04 Urciolo, Kevin wrote:
> Thanks, that seemed to help. The only problem I have now is when attempting to get a client, I get the following error:
>
> java.lang.NullPointerException at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpointInfo(AbstractWSDLBased
> EndpointFactory.java:160) at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndp
> ointFactory.java:102) at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:51)
> at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:97) at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:89)
>
> This works fine when running the CXF client stand alone.
>
> I see this nabble entry talking about the need to configure the CXF Bus. Is this what I need to do in my
> case?
> http://www.nabble.com/java.lang.NullPointerException-td14201919.html#a14201919
>
> ________________________________
>
> From: Ian Roberts [mailto:i.roberts@dcs.shef.ac.uk]
> Sent: Sun 5/4/2008 6:19 PM
> To: users@cxf.apache.org
> Subject: Re: Using CXF In Existing Spring Context
>
>
>
> Urciolo, Kevin wrote:
> > <servlet>
> > <servlet-name>context</servlet-name>
> > <servlet-class>
> > org.springframework.web.context.ContextLoaderServlet
> > </servlet-class>
> > <load-on-startup>1</load-on-startup>
> > </servlet>
> [...]
> > <listener>
> > <listener-class>
> > org.springframework.web.context.ContextLoaderListener
> > </listener-class>
> > </listener>
>
> ContextLoaderServlet and ContextLoaderListener do the same job - you
> only want one or the other, not both, and the Spring docs prefer the
> listener. I wouldn't be surprised if you get problems when you use
> both, with the context being initialized twice or something...
>
> http://static.springframework.org/spring/docs/2.0.x/reference/beans.html#context-create
>
> Also, do you have the required imports in your Spring context file?
>
> <import resource="classpath:META-INF/cxf/cxf.xml" />
> <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
> <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
>
> Ian
>
> --
> Ian Roberts | Department of Computer Science
> i.roberts@dcs.shef.ac.uk | University of Sheffield, UK
>
>
Re: Using CXF In Existing Spring Context
Posted by Willem Jiang <wi...@gmail.com>.
Hi Kevin,
Where did you put codes of creating the CXF Client ?
Can you send me the whole war file (or the a test case can reproduce it
problem) ?
Willem
Urciolo, Kevin wrote:
> I added that in, but still get the following error:
>
> java.lang.NullPointerException
> at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpointInfo(AbstractWSDLBasedEndpointFactory.java:160)
> at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:102)
> at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:51)
> at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:97)
> at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:89)
>
> I will try defining the Bus in my XML.
>
> ________________________________
>
> From: Willem Jiang [mailto:willem.jiang@gmail.com]
> Sent: Mon 5/5/2008 12:19 PM
> To: Urciolo, Kevin
> Cc: users@cxf.apache.org
> Subject: Re: Using CXF In Existing Spring Context
>
>
>
> I think you missed to set the bus to the factory.
> Maybe you need to add the below line just before call the factory's
> create method to set the right bus :).
>
> factory.setBus(BusFactory.getDefaultBus());
>
> Willem
>
> Urciolo, Kevin wrote:
>
>> I am using the released version of 2.1. I am currently following this approach since it works well with my needs to programmatically decide which ports to use at run time. So I do not have any client configuration in XML.
>>
>> However, I am in the same Spring context as my web services that are defined in xml. That xml is in the previous emails that are chained below.
>>
>> JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
>> factory.getInInterceptors().add(new LoggingInInterceptor());
>>
>> factory.getOutInterceptors().add(new LoggingOutInterceptor());
>> factory.setServiceClass(HelloWorld.class);
>> factory.setAddress("http://localhost:9000/helloWorld");
>> HelloWorld client = (HelloWorld) factory.create();
>>
>>
>> ________________________________
>>
>> From: Willem Jiang [mailto:willem.jiang@gmail.com]
>> Sent: Mon 5/5/2008 6:54 AM
>> To: users@cxf.apache.org
>> Subject: Re: Using CXF In Existing Spring Context
>>
>>
>>
>> Which CXF version are you using?
>> With the trunk code ( CXF 2.1 ) , it looks like the
>> DestinationFactoryManager dfm which is got from the bus is null.
>>
>> protected EndpointInfo createEndpointInfo() throws BusException {
>> if (transportId == null
>> && getAddress() != null) {
>> DestinationFactory df = getDestinationFactory();
>> if (df == null) {
>> DestinationFactoryManager dfm =
>> getBus().getExtension(DestinationFactoryManager.class);
>> df = dfm.getDestinationFactoryForUri(getAddress()); <--
>> The NPE is thrown from this line
>> }
>> ...
>>
>> So I doubt you set the right bus on the client side?
>> Can you show me the client spring configuration file ?
>>
>> Willem
>> Urciolo, Kevin wrote:
>>
>>
>>> Thanks, that seemed to help. The only problem I have now is when attempting to get a client, I get the following error:
>>>
>>> java.lang.NullPointerException at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpointInfo(AbstractWSDLBased
>>> EndpointFactory.java:160) at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndp
>>> ointFactory.java:102) at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:51)
>>> at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:97) at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:89)
>>>
>>> This works fine when running the CXF client stand alone.
>>>
>>> I see this nabble entry talking about the need to configure the CXF Bus. Is this what I need to do in my
>>> case?
>>> http://www.nabble.com/java.lang.NullPointerException-td14201919.html#a14201919
>>>
>>> ________________________________
>>>
>>> From: Ian Roberts [mailto:i.roberts@dcs.shef.ac.uk]
>>> Sent: Sun 5/4/2008 6:19 PM
>>> To: users@cxf.apache.org
>>> Subject: Re: Using CXF In Existing Spring Context
>>>
>>>
>>>
>>> Urciolo, Kevin wrote:
>>>
>>>
>>>
>>>> <servlet>
>>>> <servlet-name>context</servlet-name>
>>>> <servlet-class>
>>>> org.springframework.web.context.ContextLoaderServlet
>>>> </servlet-class>
>>>> <load-on-startup>1</load-on-startup>
>>>> </servlet>
>>>>
>>>>
>>>>
>>> [...]
>>>
>>>
>>>
>>>> <listener>
>>>> <listener-class>
>>>> org.springframework.web.context.ContextLoaderListener
>>>> </listener-class>
>>>> </listener>
>>>>
>>>>
>>>>
>>> ContextLoaderServlet and ContextLoaderListener do the same job - you
>>> only want one or the other, not both, and the Spring docs prefer the
>>> listener. I wouldn't be surprised if you get problems when you use
>>> both, with the context being initialized twice or something...
>>>
>>> http://static.springframework.org/spring/docs/2.0.x/reference/beans.html#context-create
>>>
>>> Also, do you have the required imports in your Spring context file?
>>>
>>> <import resource="classpath:META-INF/cxf/cxf.xml" />
>>> <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
>>> <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
>>>
>>> Ian
>>>
>>> --
>>> Ian Roberts | Department of Computer Science
>>> i.roberts@dcs.shef.ac.uk | University of Sheffield, UK
>>>
>>>
>>>
>>>
>>>
>>>
>>
>>
>>
>>
>
>
>
>
>
RE: Using CXF In Existing Spring Context
Posted by "Urciolo, Kevin" <Ke...@ngc.com>.
I added that in, but still get the following error:
java.lang.NullPointerException
at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpointInfo(AbstractWSDLBasedEndpointFactory.java:160)
at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:102)
at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:51)
at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:97)
at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:89)
I will try defining the Bus in my XML.
________________________________
From: Willem Jiang [mailto:willem.jiang@gmail.com]
Sent: Mon 5/5/2008 12:19 PM
To: Urciolo, Kevin
Cc: users@cxf.apache.org
Subject: Re: Using CXF In Existing Spring Context
I think you missed to set the bus to the factory.
Maybe you need to add the below line just before call the factory's
create method to set the right bus :).
factory.setBus(BusFactory.getDefaultBus());
Willem
Urciolo, Kevin wrote:
> I am using the released version of 2.1. I am currently following this approach since it works well with my needs to programmatically decide which ports to use at run time. So I do not have any client configuration in XML.
>
> However, I am in the same Spring context as my web services that are defined in xml. That xml is in the previous emails that are chained below.
>
> JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
> factory.getInInterceptors().add(new LoggingInInterceptor());
>
> factory.getOutInterceptors().add(new LoggingOutInterceptor());
> factory.setServiceClass(HelloWorld.class);
> factory.setAddress("http://localhost:9000/helloWorld");
> HelloWorld client = (HelloWorld) factory.create();
>
>
> ________________________________
>
> From: Willem Jiang [mailto:willem.jiang@gmail.com]
> Sent: Mon 5/5/2008 6:54 AM
> To: users@cxf.apache.org
> Subject: Re: Using CXF In Existing Spring Context
>
>
>
> Which CXF version are you using?
> With the trunk code ( CXF 2.1 ) , it looks like the
> DestinationFactoryManager dfm which is got from the bus is null.
>
> protected EndpointInfo createEndpointInfo() throws BusException {
> if (transportId == null
> && getAddress() != null) {
> DestinationFactory df = getDestinationFactory();
> if (df == null) {
> DestinationFactoryManager dfm =
> getBus().getExtension(DestinationFactoryManager.class);
> df = dfm.getDestinationFactoryForUri(getAddress()); <--
> The NPE is thrown from this line
> }
> ...
>
> So I doubt you set the right bus on the client side?
> Can you show me the client spring configuration file ?
>
> Willem
> Urciolo, Kevin wrote:
>
>> Thanks, that seemed to help. The only problem I have now is when attempting to get a client, I get the following error:
>>
>> java.lang.NullPointerException at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpointInfo(AbstractWSDLBased
>> EndpointFactory.java:160) at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndp
>> ointFactory.java:102) at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:51)
>> at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:97) at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:89)
>>
>> This works fine when running the CXF client stand alone.
>>
>> I see this nabble entry talking about the need to configure the CXF Bus. Is this what I need to do in my
>> case?
>> http://www.nabble.com/java.lang.NullPointerException-td14201919.html#a14201919
>>
>> ________________________________
>>
>> From: Ian Roberts [mailto:i.roberts@dcs.shef.ac.uk]
>> Sent: Sun 5/4/2008 6:19 PM
>> To: users@cxf.apache.org
>> Subject: Re: Using CXF In Existing Spring Context
>>
>>
>>
>> Urciolo, Kevin wrote:
>>
>>
>>> <servlet>
>>> <servlet-name>context</servlet-name>
>>> <servlet-class>
>>> org.springframework.web.context.ContextLoaderServlet
>>> </servlet-class>
>>> <load-on-startup>1</load-on-startup>
>>> </servlet>
>>>
>>>
>> [...]
>>
>>
>>> <listener>
>>> <listener-class>
>>> org.springframework.web.context.ContextLoaderListener
>>> </listener-class>
>>> </listener>
>>>
>>>
>> ContextLoaderServlet and ContextLoaderListener do the same job - you
>> only want one or the other, not both, and the Spring docs prefer the
>> listener. I wouldn't be surprised if you get problems when you use
>> both, with the context being initialized twice or something...
>>
>> http://static.springframework.org/spring/docs/2.0.x/reference/beans.html#context-create
>>
>> Also, do you have the required imports in your Spring context file?
>>
>> <import resource="classpath:META-INF/cxf/cxf.xml" />
>> <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
>> <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
>>
>> Ian
>>
>> --
>> Ian Roberts | Department of Computer Science
>> i.roberts@dcs.shef.ac.uk | University of Sheffield, UK
>>
>>
>>
>>
>>
>
>
>
>
>
Re: Using CXF In Existing Spring Context
Posted by Willem Jiang <wi...@gmail.com>.
I think you missed to set the bus to the factory.
Maybe you need to add the below line just before call the factory's
create method to set the right bus :).
factory.setBus(BusFactory.getDefaultBus());
Willem
Urciolo, Kevin wrote:
> I am using the released version of 2.1. I am currently following this approach since it works well with my needs to programmatically decide which ports to use at run time. So I do not have any client configuration in XML.
>
> However, I am in the same Spring context as my web services that are defined in xml. That xml is in the previous emails that are chained below.
>
> JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
> factory.getInInterceptors().add(new LoggingInInterceptor());
>
> factory.getOutInterceptors().add(new LoggingOutInterceptor());
> factory.setServiceClass(HelloWorld.class);
> factory.setAddress("http://localhost:9000/helloWorld");
> HelloWorld client = (HelloWorld) factory.create();
>
>
> ________________________________
>
> From: Willem Jiang [mailto:willem.jiang@gmail.com]
> Sent: Mon 5/5/2008 6:54 AM
> To: users@cxf.apache.org
> Subject: Re: Using CXF In Existing Spring Context
>
>
>
> Which CXF version are you using?
> With the trunk code ( CXF 2.1 ) , it looks like the
> DestinationFactoryManager dfm which is got from the bus is null.
>
> protected EndpointInfo createEndpointInfo() throws BusException {
> if (transportId == null
> && getAddress() != null) {
> DestinationFactory df = getDestinationFactory();
> if (df == null) {
> DestinationFactoryManager dfm =
> getBus().getExtension(DestinationFactoryManager.class);
> df = dfm.getDestinationFactoryForUri(getAddress()); <--
> The NPE is thrown from this line
> }
> ...
>
> So I doubt you set the right bus on the client side?
> Can you show me the client spring configuration file ?
>
> Willem
> Urciolo, Kevin wrote:
>
>> Thanks, that seemed to help. The only problem I have now is when attempting to get a client, I get the following error:
>>
>> java.lang.NullPointerException at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpointInfo(AbstractWSDLBased
>> EndpointFactory.java:160) at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndp
>> ointFactory.java:102) at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:51)
>> at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:97) at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:89)
>>
>> This works fine when running the CXF client stand alone.
>>
>> I see this nabble entry talking about the need to configure the CXF Bus. Is this what I need to do in my
>> case?
>> http://www.nabble.com/java.lang.NullPointerException-td14201919.html#a14201919
>>
>> ________________________________
>>
>> From: Ian Roberts [mailto:i.roberts@dcs.shef.ac.uk]
>> Sent: Sun 5/4/2008 6:19 PM
>> To: users@cxf.apache.org
>> Subject: Re: Using CXF In Existing Spring Context
>>
>>
>>
>> Urciolo, Kevin wrote:
>>
>>
>>> <servlet>
>>> <servlet-name>context</servlet-name>
>>> <servlet-class>
>>> org.springframework.web.context.ContextLoaderServlet
>>> </servlet-class>
>>> <load-on-startup>1</load-on-startup>
>>> </servlet>
>>>
>>>
>> [...]
>>
>>
>>> <listener>
>>> <listener-class>
>>> org.springframework.web.context.ContextLoaderListener
>>> </listener-class>
>>> </listener>
>>>
>>>
>> ContextLoaderServlet and ContextLoaderListener do the same job - you
>> only want one or the other, not both, and the Spring docs prefer the
>> listener. I wouldn't be surprised if you get problems when you use
>> both, with the context being initialized twice or something...
>>
>> http://static.springframework.org/spring/docs/2.0.x/reference/beans.html#context-create
>>
>> Also, do you have the required imports in your Spring context file?
>>
>> <import resource="classpath:META-INF/cxf/cxf.xml" />
>> <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
>> <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
>>
>> Ian
>>
>> --
>> Ian Roberts | Department of Computer Science
>> i.roberts@dcs.shef.ac.uk | University of Sheffield, UK
>>
>>
>>
>>
>>
>
>
>
>
>
Re: Using CXF In Existing Spring Context
Posted by Benson Margulies <bi...@gmail.com>.
I think I recommend explicitly creating a bus.
RE: Using CXF In Existing Spring Context
Posted by "Urciolo, Kevin" <Ke...@ngc.com>.
I am using the released version of 2.1. I am currently following this approach since it works well with my needs to programmatically decide which ports to use at run time. So I do not have any client configuration in XML.
However, I am in the same Spring context as my web services that are defined in xml. That xml is in the previous emails that are chained below.
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.getInInterceptors().add(new LoggingInInterceptor());
factory.getOutInterceptors().add(new LoggingOutInterceptor());
factory.setServiceClass(HelloWorld.class);
factory.setAddress("http://localhost:9000/helloWorld");
HelloWorld client = (HelloWorld) factory.create();
________________________________
From: Willem Jiang [mailto:willem.jiang@gmail.com]
Sent: Mon 5/5/2008 6:54 AM
To: users@cxf.apache.org
Subject: Re: Using CXF In Existing Spring Context
Which CXF version are you using?
With the trunk code ( CXF 2.1 ) , it looks like the
DestinationFactoryManager dfm which is got from the bus is null.
protected EndpointInfo createEndpointInfo() throws BusException {
if (transportId == null
&& getAddress() != null) {
DestinationFactory df = getDestinationFactory();
if (df == null) {
DestinationFactoryManager dfm =
getBus().getExtension(DestinationFactoryManager.class);
df = dfm.getDestinationFactoryForUri(getAddress()); <--
The NPE is thrown from this line
}
...
So I doubt you set the right bus on the client side?
Can you show me the client spring configuration file ?
Willem
Urciolo, Kevin wrote:
> Thanks, that seemed to help. The only problem I have now is when attempting to get a client, I get the following error:
>
> java.lang.NullPointerException at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpointInfo(AbstractWSDLBased
> EndpointFactory.java:160) at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndp
> ointFactory.java:102) at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:51)
> at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:97) at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:89)
>
> This works fine when running the CXF client stand alone.
>
> I see this nabble entry talking about the need to configure the CXF Bus. Is this what I need to do in my
> case?
> http://www.nabble.com/java.lang.NullPointerException-td14201919.html#a14201919
>
> ________________________________
>
> From: Ian Roberts [mailto:i.roberts@dcs.shef.ac.uk]
> Sent: Sun 5/4/2008 6:19 PM
> To: users@cxf.apache.org
> Subject: Re: Using CXF In Existing Spring Context
>
>
>
> Urciolo, Kevin wrote:
>
>> <servlet>
>> <servlet-name>context</servlet-name>
>> <servlet-class>
>> org.springframework.web.context.ContextLoaderServlet
>> </servlet-class>
>> <load-on-startup>1</load-on-startup>
>> </servlet>
>>
> [...]
>
>> <listener>
>> <listener-class>
>> org.springframework.web.context.ContextLoaderListener
>> </listener-class>
>> </listener>
>>
>
> ContextLoaderServlet and ContextLoaderListener do the same job - you
> only want one or the other, not both, and the Spring docs prefer the
> listener. I wouldn't be surprised if you get problems when you use
> both, with the context being initialized twice or something...
>
> http://static.springframework.org/spring/docs/2.0.x/reference/beans.html#context-create
>
> Also, do you have the required imports in your Spring context file?
>
> <import resource="classpath:META-INF/cxf/cxf.xml" />
> <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
> <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
>
> Ian
>
> --
> Ian Roberts | Department of Computer Science
> i.roberts@dcs.shef.ac.uk | University of Sheffield, UK
>
>
>
>
Re: Using CXF In Existing Spring Context
Posted by Willem Jiang <wi...@gmail.com>.
Which CXF version are you using?
With the trunk code ( CXF 2.1 ) , it looks like the
DestinationFactoryManager dfm which is got from the bus is null.
protected EndpointInfo createEndpointInfo() throws BusException {
if (transportId == null
&& getAddress() != null) {
DestinationFactory df = getDestinationFactory();
if (df == null) {
DestinationFactoryManager dfm =
getBus().getExtension(DestinationFactoryManager.class);
df = dfm.getDestinationFactoryForUri(getAddress()); <--
The NPE is thrown from this line
}
...
So I doubt you set the right bus on the client side?
Can you show me the client spring configuration file ?
Willem
Urciolo, Kevin wrote:
> Thanks, that seemed to help. The only problem I have now is when attempting to get a client, I get the following error:
>
> java.lang.NullPointerException at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpointInfo(AbstractWSDLBased
> EndpointFactory.java:160) at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndp
> ointFactory.java:102) at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:51)
> at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:97) at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:89)
>
> This works fine when running the CXF client stand alone.
>
> I see this nabble entry talking about the need to configure the CXF Bus. Is this what I need to do in my
> case?
> http://www.nabble.com/java.lang.NullPointerException-td14201919.html#a14201919
>
> ________________________________
>
> From: Ian Roberts [mailto:i.roberts@dcs.shef.ac.uk]
> Sent: Sun 5/4/2008 6:19 PM
> To: users@cxf.apache.org
> Subject: Re: Using CXF In Existing Spring Context
>
>
>
> Urciolo, Kevin wrote:
>
>> <servlet>
>> <servlet-name>context</servlet-name>
>> <servlet-class>
>> org.springframework.web.context.ContextLoaderServlet
>> </servlet-class>
>> <load-on-startup>1</load-on-startup>
>> </servlet>
>>
> [...]
>
>> <listener>
>> <listener-class>
>> org.springframework.web.context.ContextLoaderListener
>> </listener-class>
>> </listener>
>>
>
> ContextLoaderServlet and ContextLoaderListener do the same job - you
> only want one or the other, not both, and the Spring docs prefer the
> listener. I wouldn't be surprised if you get problems when you use
> both, with the context being initialized twice or something...
>
> http://static.springframework.org/spring/docs/2.0.x/reference/beans.html#context-create
>
> Also, do you have the required imports in your Spring context file?
>
> <import resource="classpath:META-INF/cxf/cxf.xml" />
> <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
> <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
>
> Ian
>
> --
> Ian Roberts | Department of Computer Science
> i.roberts@dcs.shef.ac.uk | University of Sheffield, UK
>
>
>
>
RE: Using CXF In Existing Spring Context
Posted by "Urciolo, Kevin" <Ke...@ngc.com>.
Thanks, that seemed to help. The only problem I have now is when attempting to get a client, I get the following error:
java.lang.NullPointerException at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpointInfo(AbstractWSDLBased
EndpointFactory.java:160) at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndp
ointFactory.java:102) at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:51)
at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:97) at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:89)
This works fine when running the CXF client stand alone.
I see this nabble entry talking about the need to configure the CXF Bus. Is this what I need to do in my
case?
http://www.nabble.com/java.lang.NullPointerException-td14201919.html#a14201919
________________________________
From: Ian Roberts [mailto:i.roberts@dcs.shef.ac.uk]
Sent: Sun 5/4/2008 6:19 PM
To: users@cxf.apache.org
Subject: Re: Using CXF In Existing Spring Context
Urciolo, Kevin wrote:
> <servlet>
> <servlet-name>context</servlet-name>
> <servlet-class>
> org.springframework.web.context.ContextLoaderServlet
> </servlet-class>
> <load-on-startup>1</load-on-startup>
> </servlet>
[...]
> <listener>
> <listener-class>
> org.springframework.web.context.ContextLoaderListener
> </listener-class>
> </listener>
ContextLoaderServlet and ContextLoaderListener do the same job - you
only want one or the other, not both, and the Spring docs prefer the
listener. I wouldn't be surprised if you get problems when you use
both, with the context being initialized twice or something...
http://static.springframework.org/spring/docs/2.0.x/reference/beans.html#context-create
Also, do you have the required imports in your Spring context file?
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
Ian
--
Ian Roberts | Department of Computer Science
i.roberts@dcs.shef.ac.uk | University of Sheffield, UK
Re: Using CXF In Existing Spring Context
Posted by Ian Roberts <i....@dcs.shef.ac.uk>.
Urciolo, Kevin wrote:
> <servlet>
> <servlet-name>context</servlet-name>
> <servlet-class>
> org.springframework.web.context.ContextLoaderServlet
> </servlet-class>
> <load-on-startup>1</load-on-startup>
> </servlet>
[...]
> <listener>
> <listener-class>
> org.springframework.web.context.ContextLoaderListener
> </listener-class>
> </listener>
ContextLoaderServlet and ContextLoaderListener do the same job - you
only want one or the other, not both, and the Spring docs prefer the
listener. I wouldn't be surprised if you get problems when you use
both, with the context being initialized twice or something...
http://static.springframework.org/spring/docs/2.0.x/reference/beans.html#context-create
Also, do you have the required imports in your Spring context file?
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
Ian
--
Ian Roberts | Department of Computer Science
i.roberts@dcs.shef.ac.uk | University of Sheffield, UK
Re: Using CXF In Existing Spring Context
Posted by Benson Margulies <bi...@gmail.com>.
Reading the code, I see that the problem is as follows:
the URL that is received has a path that CXF cannot match up to a service.
Loath to give up, it tries to make it work as a REST-ful URL, and that
doesn't work, either.
In the past, this sort of thing has happened to people who forget to
change the address in their endpoint to be relative instead of
absolute when they move their endpoint into a webapp.
RE: Using CXF In Existing Spring Context
Posted by "Urciolo, Kevin" <Ke...@ngc.com>.
That did not seem to make a difference. When I point a web browser to the cxf servlet, I see the following in the log file:
2008-05-04 19:25:03,706 ERROR [STDERR] (http-0.0.0.0-8080-1) May 4, 2008 7:25:03 PM org.apache.cxf.transport.servlet.ServletController invoke
WARNING: Can't find the the request for http://host:8080/mywar/CXFServlet's Observer
I am not sure what is wrong at the moment. I can run CXF as a stand along app just fine. I am only having problems when trying to integrate it in to my existing Spring context.
________________________________
From: Glen Mazza [mailto:glen.mazza@verizon.net]
Sent: Sun 5/4/2008 2:59 PM
To: users@cxf.apache.org
Subject: RE: Using CXF In Existing Spring Context
I don't know if it matters, but I would try removing the leading "/"
from "/WEB-INF/..." below.
HTH,
Glen
<context-param>
> <param-name>contextConfigLocation</param-name>
> <param-value>/WEB-INF/applicationContext.xml</param-value>
> </context-param>
>
2008-05-04 Urciolo, Kevin wrote:
> Is this the correct way to do it? I have the Spring context loader servlet defined, spring mvc servlet, and the cxf servlet. The CXF servlet and the context loader server reference the contextConfigLocation.
>
> Currently I get this when trying to create a client:
>
> java.lang.NullPointerException
> at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpointInfo(AbstractWSDLBasedEndpointFactory.java:160)
> at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:102)
> at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:51)
> at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:97)
>
> I get "No service was found" when pointing a web browser to the CXF servlet.
>
>
> Here is the web.xml:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
> version="2.4">
> <context-param>
> <param-name>contextConfigLocation</param-name>
> <param-value>/WEB-INF/applicationContext.xml</param-value>
> </context-param>
> <servlet>
> <servlet-name>context</servlet-name>
> <servlet-class>
> org.springframework.web.context.ContextLoaderServlet
> </servlet-class>
> <load-on-startup>1</load-on-startup>
> </servlet>
> <servlet>
> <servlet-name>centraldispatcher</servlet-name>
> <servlet-class>
> org.springframework.web.servlet.DispatcherServlet
> </servlet-class>
> <load-on-startup>2</load-on-startup>
> </servlet>
> <servlet-mapping>
> <servlet-name>dispatcher</servlet-name>
> <url-pattern>*.jsp</url-pattern>
> </servlet-mapping>
> <listener>
> <listener-class>
> org.springframework.web.context.ContextLoaderListener
> </listener-class>
> </listener>
> <servlet>
> <servlet-name>CXFServlet</servlet-name>
> <servlet-class>
> org.apache.cxf.transport.servlet.CXFServlet
> </servlet-class>
> <load-on-startup>2</load-on-startup>
> </servlet>
> <servlet-mapping>
> <servlet-name>CXFServlet</servlet-name>
> <url-pattern>/*</url-pattern>
> </servlet-mapping>
> </web-app>
>
>
> ________________________________
>
> From: Glen Mazza [mailto:glen.mazza@verizon.net]
> Sent: Tue 4/22/2008 9:48 PM
> To: cxf-user@incubator.apache.org
> Subject: Re: Using CXF In Existing Spring Context
>
>
>
> Steps #7 and #8 here (look at the web.xml and ws-beans.xml file):
> http://www.jroller.com/gmazza/date/20080417#WFstep7
>
> Also, you can configure multiple config files separated by commas,
> similar to here to keep your web service stuff separate:
> http://www.jroller.com/gmazza/date/20061128
>
> HTH,
> Glen
>
> 2008-04-22 Urciolo, Kevin wrote:
> > I would like to use CXF in an existing spring context. The examples
> > appear to have a CXF Servlet read a spring configuration file and create
> > a separate context. I want to inject beans I have defined in an
> > existing context in to my CXF services. What is the best way to
> > accomplish this?
> >
> > Thanks
>
>
>
RE: Using CXF In Existing Spring Context
Posted by Glen Mazza <gl...@verizon.net>.
I don't know if it matters, but I would try removing the leading "/"
from "/WEB-INF/..." below.
HTH,
Glen
<context-param>
> <param-name>contextConfigLocation</param-name>
> <param-value>/WEB-INF/applicationContext.xml</param-value>
> </context-param>
>
2008-05-04 Urciolo, Kevin wrote:
> Is this the correct way to do it? I have the Spring context loader servlet defined, spring mvc servlet, and the cxf servlet. The CXF servlet and the context loader server reference the contextConfigLocation.
>
> Currently I get this when trying to create a client:
>
> java.lang.NullPointerException
> at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpointInfo(AbstractWSDLBasedEndpointFactory.java:160)
> at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:102)
> at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:51)
> at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:97)
>
> I get "No service was found" when pointing a web browser to the CXF servlet.
>
>
> Here is the web.xml:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
> version="2.4">
> <context-param>
> <param-name>contextConfigLocation</param-name>
> <param-value>/WEB-INF/applicationContext.xml</param-value>
> </context-param>
> <servlet>
> <servlet-name>context</servlet-name>
> <servlet-class>
> org.springframework.web.context.ContextLoaderServlet
> </servlet-class>
> <load-on-startup>1</load-on-startup>
> </servlet>
> <servlet>
> <servlet-name>centraldispatcher</servlet-name>
> <servlet-class>
> org.springframework.web.servlet.DispatcherServlet
> </servlet-class>
> <load-on-startup>2</load-on-startup>
> </servlet>
> <servlet-mapping>
> <servlet-name>dispatcher</servlet-name>
> <url-pattern>*.jsp</url-pattern>
> </servlet-mapping>
> <listener>
> <listener-class>
> org.springframework.web.context.ContextLoaderListener
> </listener-class>
> </listener>
> <servlet>
> <servlet-name>CXFServlet</servlet-name>
> <servlet-class>
> org.apache.cxf.transport.servlet.CXFServlet
> </servlet-class>
> <load-on-startup>2</load-on-startup>
> </servlet>
> <servlet-mapping>
> <servlet-name>CXFServlet</servlet-name>
> <url-pattern>/*</url-pattern>
> </servlet-mapping>
> </web-app>
>
>
> ________________________________
>
> From: Glen Mazza [mailto:glen.mazza@verizon.net]
> Sent: Tue 4/22/2008 9:48 PM
> To: cxf-user@incubator.apache.org
> Subject: Re: Using CXF In Existing Spring Context
>
>
>
> Steps #7 and #8 here (look at the web.xml and ws-beans.xml file):
> http://www.jroller.com/gmazza/date/20080417#WFstep7
>
> Also, you can configure multiple config files separated by commas,
> similar to here to keep your web service stuff separate:
> http://www.jroller.com/gmazza/date/20061128
>
> HTH,
> Glen
>
> 2008-04-22 Urciolo, Kevin wrote:
> > I would like to use CXF in an existing spring context. The examples
> > appear to have a CXF Servlet read a spring configuration file and create
> > a separate context. I want to inject beans I have defined in an
> > existing context in to my CXF services. What is the best way to
> > accomplish this?
> >
> > Thanks
>
>
>