Я пытался реализовать механизм, который будет извлекать данные (Entity) из базы данных через вызов @Remote (RMI).У меня есть следующие классы:
Entity:
@Entity
@Table(name = "routes")
@XmlRootElement
public class Routes implements Serializable {
@Id
@Basic(optional = false)
@NotNull
@Column(name = "aname")
private String aname;
@Basic(optional = false)
@NotNull
@Column(name = "is_context")
private boolean isContext;
@Basic(optional = false)
@NotNull
@Column(name = "editable")
private boolean editable;
@Basic(optional = false)
@NotNull
@Column(name = "assignable")
private boolean assignable;
@Column(name = "pattern")
private String pattern;
@Basic(optional = false)
@NotNull
@Column(name = "created")
@Temporal(TemporalType.TIMESTAMP)
private Date created;
@Basic(optional = false)
@NotNull
@Column(name = "last_modified")
@Temporal(TemporalType.TIMESTAMP)
private Date lastModified;
@OneToMany(mappedBy = "route")
private List<BoxesItems> boxesItemsList;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "targetRoute")
private List<MenusItems> menusItemsList;
@JoinColumn(name = "target_category", referencedColumnName = "id")
@ManyToOne
private Categories targetCategory;
@JoinColumn(name = "target_page", referencedColumnName = "id")
@ManyToOne
private Pages targetPage;
@JoinColumn(name = "modified_by", referencedColumnName = "id")
@ManyToOne(optional = false)
private Users modifiedBy;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "sessionTimeoutRedirect")
private List<Settings> settingsList;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "targetRoute")
private List<Menus> menusList;
@OneToMany(mappedBy = "route")
private List<SlidersItems> slidersItemsList;
..... getters and setter
Удаленный интерфейс
@Remote
public interface RoutesFacadeRemote {
int count();
Routes getRoutePattern(String routeName);
}
и сервис, который реализует удаленный интерфейс
@Stateless
public class RoutesFacadeRe extends AbstractFacade<Routes> implements RoutesFacadeRemote {
@Override
public Routes getRoutePattern(String routeName) {
return routesFacade.findByName(routeName);
}
}
К сожалениюУ меня проблема с сериализацией при отправке сущности клиенту.При выполнении метода я получаю следующее исключение:
javax.ejb.EJBException: java.rmi.MarshalException: CORBA MARSHAL 1330446347 Maybe; nested exception is:
org.omg.CORBA.MARSHAL: WARNING: 00810011: Exception from readValue on ValueHandler in CDRInputStream vmcid: OMG minor code: 11 completed: Maybe
at org.shops.facades.remote._RoutesFacadeRemote_Wrapper.getRoutePattern(org/shops/facades/remote/_RoutesFacadeRemote_Wrapper.java)
at org.shops.it.hyperlink.CmsHyperlinkListIT.shouldBeAvaiableToSetHyperlinkListPage(CmsHyperlinkListIT.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:236)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:134)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:113)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:103)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:74)
Caused by: java.rmi.MarshalException: CORBA MARSHAL 1330446347 Maybe; nested exception is:
org.omg.CORBA.MARSHAL: WARNING: 00810011: Exception from readValue on ValueHandler in CDRInputStream vmcid: OMG minor code: 11 completed: Maybe
at com.sun.corba.ee.impl.javax.rmi.CORBA.Util.mapSystemException(Util.java:267)
at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.privateInvoke(StubInvocationHandlerImpl.java:201)
at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:140)
at com.sun.corba.ee.impl.presentation.rmi.codegen.CodegenStubBase.invoke(CodegenStubBase.java:226)
at org.shops.facades.remote.__RoutesFacadeRemote_Remote_DynamicStub.getRoutePattern(org/shops/facades/remote/__RoutesFacadeRemote_Remote_DynamicStub.java)
... 33 more
Caused by: org.omg.CORBA.MARSHAL: WARNING: 00810011: Exception from readValue on ValueHandler in CDRInputStream vmcid: OMG minor code: 11 completed: Maybe
at com.sun.proxy.$Proxy23.valuehandlerReadException(Unknown Source)
at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.readRMIIIOPValueType(CDRInputStream_1_0.java:826)
at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:921)
at com.sun.corba.ee.impl.encoding.CDRInputObject.read_value(CDRInputObject.java:518)
at com.sun.corba.ee.impl.presentation.rmi.DynamicMethodMarshallerImpl$14.read(DynamicMethodMarshallerImpl.java:383)
at com.sun.corba.ee.impl.presentation.rmi.DynamicMethodMarshallerImpl.readResult(DynamicMethodMarshallerImpl.java:482)
at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.privateInvoke(StubInvocationHandlerImpl.java:191)
... 36 more
Caused by: java.io.StreamCorruptedException: WARNING: ORBIO00013: Stream corrupted
at com.sun.proxy.$Proxy77.streamCorrupted(Unknown Source)
at com.sun.corba.ee.impl.io.IIOPInputStream.inputClassFields(IIOPInputStream.java:2527)
at com.sun.corba.ee.impl.io.IIOPInputStream.inputObjectUsingFVD(IIOPInputStream.java:1627)
at com.sun.corba.ee.impl.io.IIOPInputStream.simpleReadObject(IIOPInputStream.java:348)
at com.sun.corba.ee.impl.io.ValueHandlerImpl.readValueInternal(ValueHandlerImpl.java:311)
at com.sun.corba.ee.impl.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:277)
at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.readRMIIIOPValueType(CDRInputStream_1_0.java:819)
... 41 more
Исключение не говорит о том, что может помочь мне локализовать проблему.Я также обнаружил, что когда я удаляю все связи с другими объектами в этом объекте, все работает нормально.Может у кого-то есть похожая проблема и может помочь разобраться ??Kebaby Есть что-то вроде каскадной сериализации?Или похожий.
Все обязательные поля, помеченные @NotNull в сущности. Маршруты заполнены.