Why is apache Camel TypeConverter needed for pojo that passes another pojo?

33 Views Asked by At

We have a GWT application were everything has to be serializable in order to pass back and forth between client and server. Everything was working fine with ActiveMQ 5.8.0 and Apache Camel 2.10.3. With the recent exploit exposed in ActiveMQ I am trying to upgrade to ActiveMQ 5.16.7 (we are still on java 8). In trying to upgrade I found I had to also upgrade Apache Camel to 2.25.4.

The problem I am having is Apache Camel is trying to perform a conversion on one of my java beans that makes no sense to me and I was hoping someone can explain.

Because it is a GWT application... I can't pass a lot of the java beans directly because a lot of them are not serializable. So I have a wrapper class that I'll call GetDataForGUI which takes in a single parameter of another java bean I call BeanWrapper. BeanWrapper contains nothing more then a string for a className and a Serializable array. When the getDataForGUI is executed on the server side it uses the BeanWrapper to instantiate the real bean needed and passes it any args that it needs. It then takes the data returned by this bean and puts it all in a map to be sent back to the GWT client.

The GetDataForGUI bean constructor looks like this

   public class GetDataForGUI implements Serializable {
       private BeanWrapper beanWrap;
       public GetDataForGUI(BeanWrapper beanWrap) {
           this.beanWrap = beanWrap;
       }      
   }

The BeanWrapper class looks like this (complete)

   public class BeanWrapper implements Serializable {
   
       private String className;
       private Serializable[] args;
   
       public BeanWrapper(String className, Serializable[] args) {
           this.className = className;
           this.args = args;
       }
   
       public BeanWrapper() {}
   
       public String getClassName() {
           return className;
       }
   
       public Serializable[] getArgs() {
           return args;
       }
   }

What I can't understand is why apache Camel 2.25.4 is trying to convert a GetDataForGUI into a BeanWrapper? There is no direct conversion for these beans!! One is simply a parameter to another and will be instantiated inside that bean. They don't convert into each other.

The error I see from Apache Came is this:

Caused by: [org.apache.camel.NoTypeConversionAvailableException - No type converter available to convert from type:
com.myapp.services.gui_selection_service.requestbeans.GetDataForGUI to the required type: 
com.myapp.services_common.data.BeanWrapper with value 
com.myapp.services.gui_selection_service.requestbeans.GetDataForGUI@e0c76e8]

now I can stop apache camel from throwing a NoTypeConversionAvailableException by creating a TypeConverter that simply returns the beanWrap from the GetDataForGUI bean. But since I don't understand why it is trying to convert one into another I don't know if this is the correct way to attempt to move forward.

Does anyone know why Apache Camel wants this conversion and the best way to resolve it?

0

There are 0 best solutions below