2 Replies Latest reply: Apr 12, 2012 3:55 PM by Jonathan Tougas RSS

Can't deserialize Weld proxy to SLSB

Jonathan Tougas Newbie

Using JBoss 7.1.1, Weld 1.1.5, I'm getting java.lang.ClassNotFoundException: org.jboss.msc.service.ServiceName from [Module "deployment.wicket-ex1.war:main" from Service Module Loader] when deserializing references to SLSB injected by Weld.

 

I've created a simple test to illustrate:

 

@Stateless
public class FooStateless {
}

@Singleton
@Startup
public class StartupSingleton {


          @Inject
          private FooStateless foo;

          @PostConstruct
          public void postConstruct() {
                    deserialize( serialize( foo ) );
          }


          public byte[] serialize(Object object) {
                    try {
                              ByteArrayOutputStream out = new ByteArrayOutputStream();
                              ObjectOutputStream oos = new ObjectOutputStream(out); 
                              oos.writeObject(object);
                              oos.flush();
                              oos.close();
                              return out.toByteArray();
                    } catch( Exception e ) {
                              throw new RuntimeException( e );
                    }
          }

          public Object deserialize(byte[] data) {
                    try {
                              ByteArrayInputStream in = new ByteArrayInputStream(data);
                              ObjectInputStream ois = new ObjectInputStream(in);
                              return ois.readObject();
                    } catch (Exception e) {
                              throw new RuntimeException( e );
                    } 
          }
}

 

 

The full stacktrace is attached. In reality this is causing me trouble in a Wicket application where SLSB are injected into Pages, but the problem is the same.