You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Zarar Siddiqi <za...@gmail.com> on 2010/12/03 19:47:08 UTC
Glassfish keeps using default provider, ignores META-INF/services/javax.xml.ws.spi.Provider
Hi,
Got two apps serving as a client to an external web service, one is on
Tomcat and one is on Glassfish. The Tomcat one works like a charm, but
Glassfish keeps throwing the classic ClassCastException:
com.sun.xml.ws.client.sei.SEIStub cannot be cast to
org.apache.cxf.frontend.ClientProxy
Funny part is that I have cxf-bundle already in the classpath of the war
inside the ear and it contains the javax.xml.ws.spi.Provider file which
contains the line org.apache.cxf.jaxws.spi.ProviderImpl. So I dont' see why
it's using the provider that comes bundled with the JDK in rt.jar. I even
tried putting the cxf-bundle jar at the root of the EAR but that doesn't do
it either. I even tried setting it using System.setProperty() and also
attempted to create a file manually under WEB-INF/classes/... but nothing.
Any ideas on what might be missing?
Thanks,
Zarar
Re: Glassfish keeps using default provider, ignores META-INF/services/javax.xml.ws.spi.Provider
Posted by Zarar Siddiqi <za...@gmail.com>.
Thanks for your responses.
Peter - that did the trick. Thanks. For anyone encountering the same
problem, here's what the sun-web.xml looks like. It needs to be in the
WEB-INF directory of the WAR.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-web-app PUBLIC '-//Sun Microsystems, Inc.//DTD
Application Server 9.0 Servlet 2.5//EN'
'http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd'>
<sun-web-app>
<class-loader delegate="false"/>
</sun-web-app>
Thanks again. Now it's on to figuring out Xalan issues when doing logging
using the in/out interceptors:
org.apache.xml.serializer.ToXMLSAXHandler cannot be cast to
org.apache.xml.serializer.SerializationHandler
But that's a story for another forum.
As a sidenote, I really think that the system properly should take
precedence over META-INF/services.
On Thu, Dec 9, 2010 at 2:34 AM, Peter Mihalik <pe...@gmail.com> wrote:
> I think the system property does not work, because the META-INF/services
> definition has precedence.
> Zarar, try to change the war classloader to delegate=false (in
> sun-web.xml),
> this worked for me.
>
> --
> Peter
>
> On Thu, Dec 9, 2010 at 3:14 AM, Daniel Kulp <dk...@apache.org> wrote:
>
> > On Wednesday 08 December 2010 5:27:19 pm Zarar Siddiqi wrote:
> > > Thanks for the reply, but no luck.
> > >
> > > The resource when loaded using the context classloader points to:
> > >
> > >
> >
> jar:file:/C:/glassfish/lib/webservices-rt.jar!/META-INF/services/javax.xml.
> > > ws.spi.Provider
> > >
> > > Which is obviously wrong. Even starting Glassfish with the system
> > property
> > > doesn't work.
> > >
> > > The code you provided does not compile as factory.create(Object) is not
> a
> > > method. The only create() method does not takes no parameters.
> >
> > Sorry. The create(Class) method was added recently. It would work
> with
> > 2.3.1. :-)
> >
> > Call:
> > factory.setServiceClass(HelloWorld.class);
> > HelloWorld proxy = (HelloWorld)factory.create();
> >
> > The create(Class) method in the newer versions of CXF really just does
> the
> > above. It's a convienience method to avoid an extra method call and an
> > extra
> > cast.
> >
> > Dan
> >
> >
> > >
> > > Still looking into it.
> > >
> > > On Fri, Dec 3, 2010 at 5:46 PM, Daniel Kulp <dk...@apache.org> wrote:
> > > > On Friday 03 December 2010 1:47:08 pm Zarar Siddiqi wrote:
> > > > > Hi,
> > > > >
> > > > > Got two apps serving as a client to an external web service, one is
> > on
> > > > > Tomcat and one is on Glassfish. The Tomcat one works like a charm,
> > but
> > > > > Glassfish keeps throwing the classic ClassCastException:
> > > > >
> > > > > com.sun.xml.ws.client.sei.SEIStub cannot be cast to
> > > > > org.apache.cxf.frontend.ClientProxy
> > > > >
> > > > > Funny part is that I have cxf-bundle already in the classpath of
> the
> > > > > war inside the ear and it contains the javax.xml.ws.spi.Provider
> file
> > > > > which contains the line org.apache.cxf.jaxws.spi.ProviderImpl. So
> I
> > > > > dont' see why it's using the provider that comes bundled with the
> JDK
> > > > > in rt.jar. I even tried putting the cxf-bundle jar at the root of
> > the
> > > > > EAR but that doesn't do it either. I even tried setting it using
> > > > > System.setProperty() and also attempted to create a file manually
> > > > > under WEB-INF/classes/...
> > > >
> > > > but
> > > >
> > > > > nothing.
> > > > >
> > > > > Any ideas on what might be missing?
> > > >
> > > > I'm definitely surprised the system property didn't work. I wonder
> if
> > a
> > > > combination of setting the system property and then making sure the
> > the
> > > > contextClassLoader().getResource("META-INF/...") call grabs the file
> > > > would work.
> > > >
> > > > You could just do use the JaxWsProxyFactoryBean in CXF directly to
> > create
> > > > the
> > > > client proxy. That would bypass the SPI stuff.
> > > >
> > > > JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
> > > > factory.setAddress("http://localhost:9000/helloWorld");
> > > > HelloWorld client = factory.create(HelloWorld.class);
> > > >
> > > >
> > > > --
> > > > Daniel Kulp
> > > > dkulp@apache.org
> > > > http://dankulp.com/blog
> >
> > --
> > Daniel Kulp
> > dkulp@apache.org
> > http://dankulp.com/blog
> >
>
--
Zarar Siddiqi
416-737-9024
Re: Glassfish keeps using default provider, ignores META-INF/services/javax.xml.ws.spi.Provider
Posted by Peter Mihalik <pe...@gmail.com>.
I think the system property does not work, because the META-INF/services
definition has precedence.
Zarar, try to change the war classloader to delegate=false (in sun-web.xml),
this worked for me.
--
Peter
On Thu, Dec 9, 2010 at 3:14 AM, Daniel Kulp <dk...@apache.org> wrote:
> On Wednesday 08 December 2010 5:27:19 pm Zarar Siddiqi wrote:
> > Thanks for the reply, but no luck.
> >
> > The resource when loaded using the context classloader points to:
> >
> >
> jar:file:/C:/glassfish/lib/webservices-rt.jar!/META-INF/services/javax.xml.
> > ws.spi.Provider
> >
> > Which is obviously wrong. Even starting Glassfish with the system
> property
> > doesn't work.
> >
> > The code you provided does not compile as factory.create(Object) is not a
> > method. The only create() method does not takes no parameters.
>
> Sorry. The create(Class) method was added recently. It would work with
> 2.3.1. :-)
>
> Call:
> factory.setServiceClass(HelloWorld.class);
> HelloWorld proxy = (HelloWorld)factory.create();
>
> The create(Class) method in the newer versions of CXF really just does the
> above. It's a convienience method to avoid an extra method call and an
> extra
> cast.
>
> Dan
>
>
> >
> > Still looking into it.
> >
> > On Fri, Dec 3, 2010 at 5:46 PM, Daniel Kulp <dk...@apache.org> wrote:
> > > On Friday 03 December 2010 1:47:08 pm Zarar Siddiqi wrote:
> > > > Hi,
> > > >
> > > > Got two apps serving as a client to an external web service, one is
> on
> > > > Tomcat and one is on Glassfish. The Tomcat one works like a charm,
> but
> > > > Glassfish keeps throwing the classic ClassCastException:
> > > >
> > > > com.sun.xml.ws.client.sei.SEIStub cannot be cast to
> > > > org.apache.cxf.frontend.ClientProxy
> > > >
> > > > Funny part is that I have cxf-bundle already in the classpath of the
> > > > war inside the ear and it contains the javax.xml.ws.spi.Provider file
> > > > which contains the line org.apache.cxf.jaxws.spi.ProviderImpl. So I
> > > > dont' see why it's using the provider that comes bundled with the JDK
> > > > in rt.jar. I even tried putting the cxf-bundle jar at the root of
> the
> > > > EAR but that doesn't do it either. I even tried setting it using
> > > > System.setProperty() and also attempted to create a file manually
> > > > under WEB-INF/classes/...
> > >
> > > but
> > >
> > > > nothing.
> > > >
> > > > Any ideas on what might be missing?
> > >
> > > I'm definitely surprised the system property didn't work. I wonder if
> a
> > > combination of setting the system property and then making sure the
> the
> > > contextClassLoader().getResource("META-INF/...") call grabs the file
> > > would work.
> > >
> > > You could just do use the JaxWsProxyFactoryBean in CXF directly to
> create
> > > the
> > > client proxy. That would bypass the SPI stuff.
> > >
> > > JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
> > > factory.setAddress("http://localhost:9000/helloWorld");
> > > HelloWorld client = factory.create(HelloWorld.class);
> > >
> > >
> > > --
> > > Daniel Kulp
> > > dkulp@apache.org
> > > http://dankulp.com/blog
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://dankulp.com/blog
>
Re: Glassfish keeps using default provider, ignores META-INF/services/javax.xml.ws.spi.Provider
Posted by Daniel Kulp <dk...@apache.org>.
On Wednesday 08 December 2010 5:27:19 pm Zarar Siddiqi wrote:
> Thanks for the reply, but no luck.
>
> The resource when loaded using the context classloader points to:
>
> jar:file:/C:/glassfish/lib/webservices-rt.jar!/META-INF/services/javax.xml.
> ws.spi.Provider
>
> Which is obviously wrong. Even starting Glassfish with the system property
> doesn't work.
>
> The code you provided does not compile as factory.create(Object) is not a
> method. The only create() method does not takes no parameters.
Sorry. The create(Class) method was added recently. It would work with
2.3.1. :-)
Call:
factory.setServiceClass(HelloWorld.class);
HelloWorld proxy = (HelloWorld)factory.create();
The create(Class) method in the newer versions of CXF really just does the
above. It's a convienience method to avoid an extra method call and an extra
cast.
Dan
>
> Still looking into it.
>
> On Fri, Dec 3, 2010 at 5:46 PM, Daniel Kulp <dk...@apache.org> wrote:
> > On Friday 03 December 2010 1:47:08 pm Zarar Siddiqi wrote:
> > > Hi,
> > >
> > > Got two apps serving as a client to an external web service, one is on
> > > Tomcat and one is on Glassfish. The Tomcat one works like a charm, but
> > > Glassfish keeps throwing the classic ClassCastException:
> > >
> > > com.sun.xml.ws.client.sei.SEIStub cannot be cast to
> > > org.apache.cxf.frontend.ClientProxy
> > >
> > > Funny part is that I have cxf-bundle already in the classpath of the
> > > war inside the ear and it contains the javax.xml.ws.spi.Provider file
> > > which contains the line org.apache.cxf.jaxws.spi.ProviderImpl. So I
> > > dont' see why it's using the provider that comes bundled with the JDK
> > > in rt.jar. I even tried putting the cxf-bundle jar at the root of the
> > > EAR but that doesn't do it either. I even tried setting it using
> > > System.setProperty() and also attempted to create a file manually
> > > under WEB-INF/classes/...
> >
> > but
> >
> > > nothing.
> > >
> > > Any ideas on what might be missing?
> >
> > I'm definitely surprised the system property didn't work. I wonder if a
> > combination of setting the system property and then making sure the the
> > contextClassLoader().getResource("META-INF/...") call grabs the file
> > would work.
> >
> > You could just do use the JaxWsProxyFactoryBean in CXF directly to create
> > the
> > client proxy. That would bypass the SPI stuff.
> >
> > JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
> > factory.setAddress("http://localhost:9000/helloWorld");
> > HelloWorld client = factory.create(HelloWorld.class);
> >
> >
> > --
> > Daniel Kulp
> > dkulp@apache.org
> > http://dankulp.com/blog
--
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
Re: Glassfish keeps using default provider, ignores META-INF/services/javax.xml.ws.spi.Provider
Posted by Zarar Siddiqi <za...@gmail.com>.
Thanks for the reply, but no luck.
The resource when loaded using the context classloader points to:
jar:file:/C:/glassfish/lib/webservices-rt.jar!/META-INF/services/javax.xml.ws.spi.Provider
Which is obviously wrong. Even starting Glassfish with the system property
doesn't work.
The code you provided does not compile as factory.create(Object) is not a
method. The only create() method does not takes no parameters.
Still looking into it.
On Fri, Dec 3, 2010 at 5:46 PM, Daniel Kulp <dk...@apache.org> wrote:
> On Friday 03 December 2010 1:47:08 pm Zarar Siddiqi wrote:
> > Hi,
> >
> > Got two apps serving as a client to an external web service, one is on
> > Tomcat and one is on Glassfish. The Tomcat one works like a charm, but
> > Glassfish keeps throwing the classic ClassCastException:
> >
> > com.sun.xml.ws.client.sei.SEIStub cannot be cast to
> > org.apache.cxf.frontend.ClientProxy
> >
> > Funny part is that I have cxf-bundle already in the classpath of the war
> > inside the ear and it contains the javax.xml.ws.spi.Provider file which
> > contains the line org.apache.cxf.jaxws.spi.ProviderImpl. So I dont' see
> > why it's using the provider that comes bundled with the JDK in rt.jar. I
> > even tried putting the cxf-bundle jar at the root of the EAR but that
> > doesn't do it either. I even tried setting it using System.setProperty()
> > and also attempted to create a file manually under WEB-INF/classes/...
> but
> > nothing.
> >
> > Any ideas on what might be missing?
>
> I'm definitely surprised the system property didn't work. I wonder if a
> combination of setting the system property and then making sure the the
> contextClassLoader().getResource("META-INF/...") call grabs the file would
> work.
>
> You could just do use the JaxWsProxyFactoryBean in CXF directly to create
> the
> client proxy. That would bypass the SPI stuff.
>
> JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
> factory.setAddress("http://localhost:9000/helloWorld");
> HelloWorld client = factory.create(HelloWorld.class);
>
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://dankulp.com/blog
>
--
Zarar Siddiqi
416-737-9024
Re: Glassfish keeps using default provider, ignores META-INF/services/javax.xml.ws.spi.Provider
Posted by Daniel Kulp <dk...@apache.org>.
On Friday 03 December 2010 1:47:08 pm Zarar Siddiqi wrote:
> Hi,
>
> Got two apps serving as a client to an external web service, one is on
> Tomcat and one is on Glassfish. The Tomcat one works like a charm, but
> Glassfish keeps throwing the classic ClassCastException:
>
> com.sun.xml.ws.client.sei.SEIStub cannot be cast to
> org.apache.cxf.frontend.ClientProxy
>
> Funny part is that I have cxf-bundle already in the classpath of the war
> inside the ear and it contains the javax.xml.ws.spi.Provider file which
> contains the line org.apache.cxf.jaxws.spi.ProviderImpl. So I dont' see
> why it's using the provider that comes bundled with the JDK in rt.jar. I
> even tried putting the cxf-bundle jar at the root of the EAR but that
> doesn't do it either. I even tried setting it using System.setProperty()
> and also attempted to create a file manually under WEB-INF/classes/... but
> nothing.
>
> Any ideas on what might be missing?
I'm definitely surprised the system property didn't work. I wonder if a
combination of setting the system property and then making sure the the
contextClassLoader().getResource("META-INF/...") call grabs the file would
work.
You could just do use the JaxWsProxyFactoryBean in CXF directly to create the
client proxy. That would bypass the SPI stuff.
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setAddress("http://localhost:9000/helloWorld");
HelloWorld client = factory.create(HelloWorld.class);
--
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog