#Trying to set an object into a EJB Bean array from a remote app.
18 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @crystal elk! Please use
/closeor theClose Postbutton above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
This is the object I am trying to insert into the Bean's List, this in a module called "core"
public class IoTDeviceReadingState implements Serializable {
int capturedVehicleSpeed = 0;
String capturedTrafficLightStatus = null;
Coordinate capturedGPSCoordinates = null;
This is the Bean interface
@Remote
public interface IoTDeviceReadingStore extends Serializable {
void configureBean();
void setReading(IoTDeviceReadingState reading);
List<IoTDeviceReadingState> getReadings();
}
Bean Implementation
@Stateful
public class IoTDeviceReadingStoreBean implements IoTDeviceReadingStore {
private List<IoTDeviceReadingState> readings = new LinkedList<>();
@PostConstruct
public void configureBean(){
this.readings = new LinkedList<>();
}
public void setReading(IoTDeviceReadingState reading){
this.readings.add(reading);
}
public List<IoTDeviceReadingState> getReadings(){
return readings;
}
}
Testing it in Servlet
IoTDeviceReadingState state = new IoTDeviceReadingState();
String lightStatus = "green";
int speed = 100;
state.captureTrafficLightStatus(lightStatus);
state.captureVehicleSpeed(speed);
IoTDeviceReadingStore readingStoreBean = (IoTDeviceReadingStore) context.lookup("java:global/ear/app/IoTDeviceReadingStoreBean");
readingStoreBean.setReading(state);
No errors worked fine
Trying to do this in another app
IoTDeviceReadingState state = new IoTDeviceReadingState();
String lightStatus = IoTDataGenerator.randomStatus();
int speed = IoTDataGenerator.randomSpeed();
state.captureTrafficLightStatus(lightStatus);
state.captureVehicleSpeed(speed);
IoTDeviceReadingStore readingStoreBean = (IoTDeviceReadingStore) context.lookup("java:global/ear/app/IoTDeviceReadingStoreBean");
readingStoreBean.setReading(state);
The error I am getting is
Exception in thread "main" jakarta.ejb.EJBException: java.rmi.MarshalException: CORBA MARSHAL 1330446347 Maybe; nested exception is:
org.omg.CORBA.MARSHAL: ----------BEGIN server-side stack trace----------
org.omg.CORBA.MARSHAL: WARNING: 00810011: Exception from readValue on ValueHandler in CDRInputStream vmcid: OMG minor code: 11 completed: Maybe
at com.sun.proxy.$Proxy270.valuehandlerReadException(Unknown Source)
at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.readRMIIIOPValueType(CDRInputStream_1_0.java:804)
at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:899)
at com.sun.corba.ee.impl.encoding.CDRInputObject.read_value
This is the github repo
https://github.com/ragujan/multi_module_java_iot_app_simulation/tree/main
how to do I change the description
the description is old
going to sleep now
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use/help ping.
Warning: abusing this will result in moderative actions taken against you.