7 Replies Latest reply: Sep 10, 2011 11:06 AM by Mike Brock RSS

Deserialisation

koekj Newbie

I'm trying to get errai up and running on an jboss as 7 environment with use of CDI,EJB's and JPA.

My dependency list

 

 

I'm able to inject the EJB into the CDI component that is used as service for the errai client;

 

@Service

public class HelloWorldService implements MessageCallback {

 

      private RequestDispatcher requestDispatcher;

 

 

  @Inject

  ArticleDAOBean bean;

 

 

  public void callback(Message message) {

  try {

  LOGGER.info("Bean is {}", (bean == null ? "null" : "set!"));

  List articleList = bean.find(0, 50);

  MessageBuilder.createConversation(message).subjectProvided()

  .with("Records",

  list

  ).noErrorHandling()

  .reply();

  LOGGER.info( "Message has been sent, attached:{}", articleList.size() );

  } catch ( Throwable e ) {

  e.printStackTrace();

  LOGGER.info( "Bug?:" + e.getMessage() );

  }

  }

 

 

  @Inject

  public void setRequestDispatcher(RequestDispatcher requestDispatcher) {

  this.requestDispatcher = requestDispatcher;

  }

 

 

  public RequestDispatcher getRequestDispatcher() {

  return requestDispatcher;

  }

}

 

 

 

As you can see I'm using the example code coming with the maven archetype.

 

I have annotated the entity with @ExposedEntity and this results in a generated marshaller en demarshaller (stored in the folder .generated\org\jboss\errai\bus\client\ext).

 

I can stated that the marshaller is working because if I look into firefox firebug I'm seeing the data being sent as json string to the client.

 

However the client (GWT) is not receiving the message. I added an Window.alert to the code to ensure that the message is processed.

If I'm sending a regular String the client is responding.

 

So which pointers can you give to debug and to find the problem. I'm expecting that the problem lies in the demarshalling of the objects.

In the generated code the following statements are generated;

 

  catch (Exception e) {

                e.printStackTrace();

                throw new RuntimeException("could not demarshall type: Article; value=" + o, e);

            }

 

 

Does that work for GWT?

 

I have tried to startup the monitor but that doesn't start within the jboss as 7. In the war under WEB-INF/lib the errai-tools.jar is available.

And in the standalone.conf.bat the set "JAVA_OPTS=%JAVA_OPTS% -Derrai.tools.bus_monitor_attach=true" is added.

The exception that is returned:

java.lang.RuntimeException: could not initialize ErraiService instance

          at org.jboss.errai.cdi.server.Util.lookupErraiService(Util.java:142)

          at org.jboss.errai.cdi.server.CDIExtensionPoints.afterBeanDiscovery(CDIExtensionPoints.java:264)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

          at java.lang.reflect.Method.invoke(Method.java:597)

          at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:305)

          at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54)

          at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:163)

          at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:299)

          at org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:188)

          at org.jboss.weld.introspector.ForwardingWeldMethod.invokeOnInstance(ForwardingWeldMethod.java:59)

          at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:198)

          at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:282)

          at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:265)

          at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:234)

          at org.jboss.weld.bootstrap.events.AbstractContainerEvent.fire(AbstractContainerEvent.java:88)

          at org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(AbstractDefinitionContainerEvent.java:52)

          at org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.fire(AfterBeanDiscoveryImpl.java:43)

          at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:380)

          at org.jboss.as.weld.WeldContainer.start(WeldContainer.java:81)

          at org.jboss.as.weld.services.WeldService.start(WeldService.java:89)

          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1765)

          at org.jboss.msc.service.ServiceControllerImpl$ClearTCCLTask.run(ServiceControllerImpl.java:2291)

          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

          at java.lang.Thread.run(Thread.java:619)

Caused by: com.google.inject.ProvisionException: Guice provision errors:

 

 

1) Error injecting constructor, java.lang.RuntimeException: Server bootstrap failed

  at org.jboss.errai.bus.server.service.ErraiServiceImpl.(ActivityProcessor.java:34)

          at org.jboss.errai.tools.monitoring.MonitorExtension.configure(MonitorExtension.java:44)

          at org.jboss.errai.bus.server.service.bootstrap.LoadExtensions$2.run(LoadExtensions.java:105)

          at org.jboss.errai.bus.server.service.bootstrap.LoadExtensions.execute(LoadExtensions.java:112)

          ... 46 more

 

 

 

Hope you can help, so that I can help getting this great framework working.

  • 1. Re: Deserialisation
    Mike Brock Master

    Can you try this with the latest 1.3.0-SNAPSHOT? We have fixed a few bugs related to serialization. If that doesn't work, we'll go bug hunting =)

  • 2. Re: Deserialisation
    koekj Newbie

    I made some progress.

    I found the bug at least that's what I think

     

    In the Entity a string field contains the character '\'. The generated marshaller/demarshaller should follow the json structure rules by escaping this character  (http://www.json.org/).

    If I change the content of the field by putting a extra '\' in front of the data the message is received and processed by the client.

     

    Can you verify I'm correct and that this really is the bug?

     

    Thanks in advance.

  • 3. Re: Deserialisation
    Mike Brock Master

    yes, it should be doing this. We will investigate.

  • 4. Re: Deserialisation
    Mike Brock Master

    I have found, reproduced, and fixed the bug. I am currently publishing a new 1.3.0-SNAPSHOT with the fix.

  • 5. Re: Deserialisation
    koekj Newbie

    I'm not sure if it's fixed. I still need to use the function JSONObject.escape to get the object correctly deserialised. I'm using the snapshot version.

    Also I found maybe another bug;

    I'm using the MessageBuilder... command with an enum then the service is not published on the server side.

    If I change the enum into the string representing the enum then the service is published, very strange.

    Because the MessageBuilder is defined within the service call.

  • 6. Re: Deserialisation
    Mike Brock Master

    Actually, I'm sorry. The fix is in 2.0-SNAPSHOT. I need to backport the fix! Will do very soon!

  • 7. Re: Deserialisation
    Mike Brock Master

    1.3.0-SNAPSHOT has been pushed.