You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Marek Kasztelnik <ym...@cyf-kr.edu.pl> on 2009/05/14 20:42:53 UTC

CXF web service client in eclipse rpc application

Hi,

I use CXF 2.2 for implementing web services and WS clients. Some of
WS clients are used in Eclipse RPC plugins.  Every plugin
has set of cxf client jars included (and it works perfectly)at the
moment. But why should jars be duplicated? To solve this problem I have
created simple plugin, that has all required jars and export all jars
packages (so other plugins can use them). However, this solution creates
some problems. When I tried to create web service
client like this::

JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setAddress("wsdlURL");
factory.setServiceClass(WSInterface.class);
AegisDatabinding aDB = new AegisDatabinding();
aDB.setMtomEnabled(true);
factory.getServiceFactory().setDataBinding(aDB);

WSInterface ws = (WSInterface)factory.create();

the following exception is thrown:

java.lang.IllegalArgumentException: interface
javax.xml.ws.BindingProvider is not visible from class loader
     at java.lang.reflect.Proxy.getProxyClass(Proxy.java:353)
     at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:581)
     at
org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:118)
     at
org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:115)
     at test.actions.SampleAction.run(SampleAction.java:83)
     at 
org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:251)
     at
...

After some digging I found the place where exception is thrown and I
have tried to reproduce this exception:

Object obj = Proxy.newProxyInstance(
        factory.getServiceClass().getClassLoader(),
        new Class[] {factory.getServiceClass(), BindingProvider.class},
        new InvocationHandler()
           @Override
           public Object invoke(
                   Object proxy, Method method,
           Object[] args) throws Throwable {
             System.out.println("invoking method: " + method);
             return null;
        }
});

Surprisingly,SPRAWDZ CZY TAK SIE PISZE) it works. Could anyone suggest
me where I make a mistake and why the second snippet works and the first
one doesn't?

thank you for any help

-- 
Marek Kasztelnik

   Academic Computer Centre CYFRONET AGH
   Cracow, Poland