I have a problem with a 'slightly' more complex type than based Java types in 
my exposed web service that doesn't seem to work.

Here's the setup:

I have a simple server that has as a return type a 'custom' type that wraps a 
string for this example.

The server bundles deploy fine, and the web service works great from the 
Eclipse Web Services Explorer.

When I try to bring up the Client in different instance of felix things start 
falling apart. If I don't use a custom type... use String for instance 
everything works fine.

However, when I use my custom type I get this error on the actual call to the 
server, not at Binding/Wiring time.

Dec 14, 2009 10:01:34 AM org.apache.cxf.phase.PhaseInterceptorChain doIntercept
INFO: Interceptor has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Couldn't instantiate class. 
example.wstype.WsType. Nested exception is java.lang.InstantiationException: 
example.wstype.WsType
      at 
org.apache.cxf.aegis.databinding.XMLStreamDataReader.read(XMLStreamDataReader.java:63)...

So, I figured I'd cheat and placed the package that contains the type into the 
felix org.osgi.framework.system.packages.extra property. I get the same error.

The following is the source if anyone else wants to give it a try. Yes, I'm 
using iPOJO.

Oh yeah, here's the an important line from the example.wsserver bundle: 
Export-Package: example.wsserver.*, example.wstype.*

I can't imagine that I'm the first person to deal with this, so my assumption 
is that I'm doing something wrong. Based on my reading, I may have to add some 
mapping info to the AegisContext... but I can't figure out how to do that in an 
OSGi/Felix way.

Any help would be greatly appreciated. I would maybe suggest expanding the 
iPOJO w/ DOSGi example here 
(http://felix.apache.org/site/apache-felix-ipojo-dosgi.html) to include a 
complex type as an in/out parameter.

Interface bundle: example.wsserver

package example.wsserver;

import example.wstype.WsType;

public interface Server {

      WsType getSomething( String string);

}

package example.wstype;

import java.io.Serializable;

public class WsType implements Serializable {

      private static final long serialVersionUID = 1L;

      private String astring;

      public String getAstring() {
            return astring;
      }

      public void setAstring(String astring) {
            this.astring = astring;
      }

      public WsType( String astring) {
            this.astring = astring;
      }

}

Server Implementation bundle: example.wsserverimpl

package example.wsserverimpl;

import org.apache.felix.ipojo.annotations.Component;
import org.apache.felix.ipojo.annotations.Provides;

import example.wsserver.Server;
import example.wstype.WsType;

@Component( propagation=true)
@Provides
public class ServerImpl implements Server {

      @Override
      public WsType getSomething(String string) {
            return new WsType( "echo: " + string);
      }

}

Client Implementation bundle: example.wsclient

package example.wsclient;

import org.apache.felix.ipojo.annotations.Component;
import org.apache.felix.ipojo.annotations.Invalidate;
import org.apache.felix.ipojo.annotations.Requires;
import org.apache.felix.ipojo.annotations.Validate;
import org.osgi.service.log.LogService;

import example.wsserver.Server;
import example.wstype.WsType;

@Component
public class Client {

      private volatile boolean running = false;

      @Requires
      private Server server;

      @Requires
      private LogService log;

      @Validate
      public void start() {

            log.log( LogService.LOG_INFO, "Client start()");

            new Thread( new Runnable() {

                  @Override
                  public void run() {

                        log.log( LogService.LOG_INFO, "Client run()");

                        running = true;

                        while( running) {

                              log.log( LogService.LOG_INFO, "Client running()");

                              WsType wsType = server.getSomething( "Hello");
                              log.log( LogService.LOG_INFO, 
wsType.getAstring());
                              try {
                                    Thread.sleep( 5000);
                              } catch (InterruptedException e) {
                                    log.log( LogService.LOG_ERROR, "Bad Sleep", 
e);
                              }
                        }

                        log.log( LogService.LOG_INFO, "Client exit()");

                  }
            }).start();
      }

      @Invalidate
      public void stop() {
            running = false;
      }

}


Reply via email to