为什么我得到EJB java.rmi.MarshalException:CORBA MARSHAL异常?

时间:2016-04-13 16:54:27

标签: java jsp jpa java-ee

我尝试使用JSP页面添加项目,该页面也有几个图像。我声明了变量以将图像检索为字符串,因此我可以获取URL并将URL存储在数据库中。

我将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();
    }

//具有addItem方法代码的ejb类

@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是使用实体管理器创建的java类,该实体管理器具有来自JPA的自动生成代码。

异常

  

javax.ejb.EJBException:java.rmi.MarshalException:CORBA MARSHAL 1330446343否;嵌套异常是:       org.omg.CORBA.MARSHAL:---------- BEGIN服务器端堆栈跟踪----------   org.omg.CORBA.MARSHAL:FINE:00810007:在消息vmcid中的最后一个片段之后BufferManagerReadStream中的下溢:OMG次要代码:7完成:否       在com.sun.proxy。$ Proxy154.endOfStream(未知来源)       at com.sun.corba.ee.impl.encoding.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)       at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequestRequest(MessageMediatorImpl.java:1549)       at com.sun.corba.ee.impl.protocol.SharedCDRClientRequestDispatcherImpl.marshalingComplete(SharedCDRClientRequestDispatcherImpl.java:119)       at 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)       在com.sun.corba.ee.impl.presentation.rmi.codegen.CodegenStubBase.invoke(CodegenStubBase.java:226)       在com.olympics2016.beans .__ EventBeanRemote_Remote_DynamicStub.addEvent(com / olympics2016 / beans / __ EventBeanRemote_Remote_DynamicStub.java)       在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(HttpServlet.java:790)       在org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)       在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)       在org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)       在org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)       在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)       在org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201)       在org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175)       在org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)       在org.glassfish.grizzly.filterchain.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)       在org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561)       在org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)       在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)       在org.glassfish.grizzly.threadpool.AbstractThreadPool $ Worker.doWork(AbstractThreadPool.java:565)       在org.glassfish.grizzly.threadpool.AbstractThreadPool $ Worker.run(AbstractThreadPool.java:545)       在java.lang.Thread.run(Thread.java:745)

     

---------- END服务器端堆栈跟踪---------- vmcid:OMG次要代码:7完成:否

1 个答案:

答案 0 :(得分:0)

Marshal Exception可能由于以下原因之一而发生: 1)当完成远程方法调用并且没有完成Java对象的编组时,参数或返回值将不会到达远程方法或服务器。

2)如果我们在RMI中使用的协议在发送方和接收方都有不同的版本。