2016-04-13 80 views
2

我試圖添加項目使用JSP頁面也有幾個圖像。我聲明變量來檢索圖像作爲字符串,所以我可以得到的URL和存儲在數據庫中的網址。爲什麼我得到一個EJB java.rmi.MarshalException:CORBA MARSHAL異常?

我使用EJB和JPA來實現數據庫目的。

我對servlet代碼

ItemDetails id; 
ItemBeanRemote ib; 
@Override 
protected void doPost(HttpServletRequest request, HttpServletResponse response) 
     throws ServletException, IOException { 

    String id = request.getParameter("id"); 
    String name = request.getParameter("name"); 
    double price = Double.valueOf(request.getParameter("price")); 
    String imgurl = request.getParameter("imgurl"); 
    String imgurl2 = request.getParameter("imgurl2"); 
    String location = request.getParameter("loc"); 

    id = new ItemDetails(id, name, price, imgurl, imgurl2, location); 

    ib.addItem(id); 
     response.sendRedirect("View.jsp"); 

} 

@Override 
public void init() { 
    try { 
     Context initial = new InitialContext(); 
     ib = (ItemBeanRemote) initial.lookup("itembean"); 
    } catch (Exception ex) { 
     System.err.println("Caught an exception:"); 
     ex.printStackTrace(); 
    } 

// EJB類具有代碼AddItem方法

@Override 
public void addEvent(ItemDetails details) { 
    try { 
     tblItem utt = new tblItem(details.getItemID(),details.getItemName(), 
       details.getPrice(),details.getImgUrl(),details.getImgUrl2(),details.getLocation()); 
     em.persist(utt); 
    } catch (Exception ex) { 
     throw new EJBException(ex); 
    } 

//項目的細節是一類是具有getter和setter

一個POJO

// tblItem是使用從JPA自動生成代碼的實體管理器創建的java類。

和異常

javax.ejb.EJBException異常:java.rmi.MarshalException:CORBA MARSHAL 1330446343號;嵌套的異常是: org.omg.CORBA.MARSHAL:---------- BEGIN服務器端堆棧跟蹤---------- org.omg.CORBA.MARSHAL:FINE: 00810007:在消息vmcid:OMG次要代碼:7已完成:沒有 at com.sun.proxy。$ Proxy154.endOfStream(未知源) at com.sun.corba.ee.impl.encoding後,在BufferManagerReadStream中下溢。 BufferManagerReadStream.underflow(BufferManagerReadStream.java:122) at com.sun.corba.ee.impl.encoding.CDRInputStream_1_1.grow(CDRInputStream_1_1.java:111) at com.sun.corba.ee.impl.encoding.CDRInputStream_1_2。 alignAndCheck(CDRInputStream_1_2.java:126) at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_long(CDRInputStream_1_0.java:433) at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.readValueTag (CDRInputStream_1_0.java:1672) at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:918) 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。 readArguments(DynamicMethodMarshallerImpl.java:450) at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:171) at com.sun.corba.ee.impl.protocol.ServerRequestDispatcherImpl。 dispatchToServant(ServerRequestDispatcherImpl.java:528) at com.sun.corba.ee.impl.protocol.ServerRequestDispatcherImpl.dispatch(ServerRequestDispatcherImpl.java:199) 在com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequestRequest(MessageMediatorImpl.java:1549) 在com.sun.corba.ee.impl.protocol.SharedCDRClientRequestDispatcherImpl.marshalingComplete(SharedCDRClientRequestDispatcherImpl.java:119) 在com.sun.corba.ee.impl.protocol.ClientDelegateImpl.invoke(ClientDelegateImpl.java:258) at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.privateInvoke(StubInvocationHandlerImpl.java:198) at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:150) at com.sun.corba.ee.impl.presentation.rmi.codegen.CodegenStubBase.invoke(CodegenStubBase.java: 226) at com.olympics2016.beans .__ EventBeanRemote_Remote_DynamicStub.addEvent(com/olympics2016/beans/__ EventBeanRemote_Rem ote_DynamicStub.java) at com.olympics2016.beans._EventBeanRemote_Wrapper.addEvent(com/olympics2016/beans/_EventBeanRemote_Wrapper。JAVA) 在com.olympics2016.servlets.AddEventServlet.doPost(AddEventServlet.java:42) 在javax.servlet.http.HttpServlet.service(HttpServlet.java:707) 在javax.servlet.http.HttpServlet.service( (StandardWrapperValve.java:318) at org。 apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734) at org.apache.catalina.core.StandardPipeline.invoke( StandardPipeline.java:673) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99) 在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174) 在org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:415) 在org.apache.catalina.connector。 CoyoteAdapter.service(CoyoteAdapter.java:282) at com.sun.enterprise.v3.services.impl.ContainerMapper $ HttpHandlerCallable.call(ContainerMapper.java:459) at com.sun.enterprise.v3.services.impl。 ContainerMapper.service(ContainerMapper.java:167) at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201) at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler。 java:175) at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235) at org.glassfish.grizzly.f ilterchain.ExecutorResolver $ 9.execute(ExecutorResolver.java:119) 在org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284) 在org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java :201) 在org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133) 在org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112) 在org.glassfish.grizzly .ProcessorExecutor.execute(ProcessorExecutor.java:77) at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561) at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java :112) at org.glassfish。 grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117) 在org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access $ 100(WorkerThreadIOStrategy.java:56) 在org.glassfish.grizzly.strategies.WorkerThreadIOStrategy $ WorkerThreadRunnable.run (WorkerThreadIOStrategy.java:137) at org.glassfish.grizzly.threadpool.AbstractThreadPool $ Worker.doWork(AbstractThreadPool.java:565) at org.glassfish.grizzly.threadpool.AbstractThreadPool $ Worker.run(AbstractThreadPool.java:545 ) at java.lang.Thread.run(Thread.java:745)

---------- END服務器端堆棧跟蹤---------- vmcid:OMG次要代碼:7已完成:否

+2

您呈現的堆棧跟蹤似乎描述了在Web端(而不是EJB端)拋出的異常,但是它在EJB的web端addEvent()存根執行期間確實發生。也許別人會認識到細節,但我傾向於認爲我們沒有足夠的信息來回答。考慮減少有問題的組件,足以將它們呈現爲[mcve]。 –

+0

好的非常感謝@JohnBollinger – dav191

+0

這看起來像一個或兩個'ItemBeanRemote'和'ItemDetails'不匹配EJB服務器端的版本。 –

回答

0

由於以下其中一個原因可能會導致數組異常: 1)當遠程方法調用完成且未對Java對象進行封送處理並因此參數或返回值不會到達遠程方法或服務器時。

2)如果我們在RMI中使用的協議在發送方和接收方都是不同的版本。

相關問題