javax.ejb.EJBException: ошибка при отправке запроса [вызвано: java.io.OptionalDataException] - PullRequest
0 голосов
/ 26 февраля 2019

У меня есть EJB-вызов со стороны клиента, например:

Portfolio[] ptfTab = ServicesMgr.getInstance().getPortfolioService().getPortfolios();

getPortfolioService () возвращает экземпляр PortfolioFinderDelegate (клиентский интерфейс EJB).Служба EJB на стороне клиента имеет следующую подпись:

public interface PortfolioFinder extends IBasic {
   Portfolio[] getPortfolios();
}

Для EJB на стороне сервера реализация метода:

public Portfolio[] getPortfolios() {
    List<Portfolio> portfolioList = getPortfoliosAsList();
    return portfolioList.toArray(new Portfolio[portfolioList.size()]);
}

Метод getPortfolioAsList () является закрытымметод:

 private List<Portfolio> getPortfoliosAsList() {
     List<Portfolio> portfolioList = new ArrayList<Portfolio>();
     LOCK.readLock().lock();
     try {
          List<String> keys = portfolioCache.getKeys();
          for (Iterator<String> iterator = keys.iterator(); iterator.hasNext();) 
              {
               String codeport = iterator.next();
               Set<Portfolio> s =(Set<Portfolio>) portfolioCache.get(codeport) .getValue();
               portfolioList.addAll(s);
              }
         } catch (Throwable e) {
                LOGGER.error(e.getMessage(), e);
         } finally {
                LOCK.readLock().unlock();
         }

         return portfolioList;
   }

Вчера я получил странную трассировку стека, подобную этой, я никогда не сталкивался с ней раньше, и я уверен, что кэш портфеля на стороне сервера не пуст.Кроме того, на стороне сервера нет журнала ошибок.Когда первый клиент сталкивается с этой ошибкой, тогда все клиенты имеют ее.Эта проблема связана с размером возвращаемого объекта?(поскольку размер кэша увеличивается с каждым днем) Есть ли предел размера объекта при сериализации и десериализации данных через EJB?

2019-02-26 14:51:35 ERROR [StartupMgr][EJBPortfolioMgr.java:57] : Error while sending a request
javax.ejb.EJBException: Error while sending a request
                at org.ow2.easybeans.proxy.client.ClientRPCInvocationHandler.invoke(ClientRPCInvocationHandler.java:205)
                at org.ow2.easybeans.proxy.client.ClientRPCInvocationHandler.invoke(ClientRPCInvocationHandler.java:117)
                at com.sun.proxy.$Proxy33.getPortfolios(Unknown Source)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                at java.lang.reflect.Method.invoke(Method.java:606)
                at com.clam.mediaplus.client.services.ProxyRemoteObject.invoke(ProxyRemoteObject.java:87)
                at com.sun.proxy.$Proxy33.getPortfolios(Unknown Source)
                at client.delegate.common.PortfolioFinderDelegate.getPortfolios(PortfolioFinderDelegate.java:46)
                at com.casits.rambo.dao.portfolio.EJBPortfolioMgr.reload(EJBPortfolioMgr.java:42)
                at com.casits.rambo.dao.portfolio.AbstractPortfolioMgr.<init>(AbstractPortfolioMgr.java:24)
                at com.casits.rambo.dao.portfolio.EJBPortfolioMgr.<init>(EJBPortfolioMgr.java:31)
                at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
                at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
                at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
                at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
                at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)
                at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:72)
                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:948)
                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:901)
                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
                at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
                at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
                at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
                at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
                at com.casits.rambo.dao.common.CommonBeanFactory.getPortfolioMgr(CommonBeanFactory.java:54)
                at com.casits.rambo.dao.portfolio.PortfolioMgr.getAttribPortfolio(PortfolioMgr.java:82)
                at com.casits.rambo.dao.portfolio.PortfolioMgr.getAttribPortfolio(PortfolioMgr.java:151)
                at com.casits.rambo.dao.portfolio.PortfolioMgr$2.processRow(PortfolioMgr.java:217)
                at org.springframework.jdbc.core.JdbcTemplate$RowCallbackHandlerResultSetExtractor.extractData(JdbcTemplate.java:1408)
              at org.springframework.jdbc.core.JdbcTemplate$1QueryStatementCallback.doInStatement(JdbcTemplate.java:445)
                at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:395)
                at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:455)
                at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:459)
                at com.casits.rambo.dao.portfolio.PortfolioMgr.getAllAttribPortfolios(PortfolioMgr.java:207)
                at com.casits.attrib.refptf.controller.RefPortfolioMgr.getAllAttribCodeports(RefPortfolioMgr.java:257)
                at com.casits.attrib.refptf.controller.RefPortfolioMgr.refreshAttribCodeports(RefPortfolioMgr.java:243)
                at com.casits.attrib.refptf.controller.RefPortfolioMgr.init(RefPortfolioMgr.java:221)
                at com.casits.attrib.refptf.controller.RefPortfolioMgr.<init>(RefPortfolioMgr.java:239)
                at com.casits.attrib.refptf.controller.RefPortfolioMgr.<clinit>(RefPortfolioMgr.java:191)
                at com.casits.attrib.refptf.RefPtfModule.init(RefPtfModule.java:80)
                at com.casits.attrib.attribcommon.AbstractModule.load(AbstractModule.java:70)
                at com.casits.attrib.main.MainJFrame.executeEnableModule(MainJFrame.java:418)
                at com.casits.attrib.main.MainJFrame.addModule(MainJFrame.java:336)
                at com.casits.attrib.main.MainGUI.createAndShowGUI(MainGUI.java:80)
                at com.casits.attrib.main.StartupMgr.init(StartupMgr.java:82)
                at com.casits.attrib.attribcommon.manager.AttribUserMgr$1.run(AttribUserMgr.java:390)
                at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: Error while handling answer on the remote side 
                at org.ow2.easybeans.rpc.rmi.client.RMIClientRPC.sendEJBRequest(RMIClientRPC.java:116)
                at org.ow2.easybeans.proxy.client.ClientRPCInvocationHandler.invoke(ClientRPCInvocationHandler.java:202)
                ... 49 more
Caused by: java.rmi.UnmarshalException: IOException unmarshalling returnjava.io.OptionalDataException; nested exception is: 
                java.io.OptionalDataException
                at org.ow2.carol.rmi.jrmp.server.JUnicastRef.performRemoteCall(JUnicastRef.java:212)
                at org.ow2.carol.rmi.jrmp.server.JUnicastRef.invoke(JUnicastRef.java:161)
                at org.ow2.easybeans.rpc.rmi.server.RMIServerRPCImpl_Stub.getEJBResponse(RMIServerRPCImpl_Stub.java:60)
                at org.ow2.easybeans.rpc.rmi.client.RMIClientRPC.sendEJBRequest(RMIClientRPC.java:114)
                ... 50 more
Caused by: java.io.OptionalDataException
                at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1370)
                at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370)
                at java.util.HashMap.readObject(HashMap.java:1179)
                at sun.reflect.GeneratedMethodAccessor32.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                at java.lang.reflect.Method.invoke(Method.java:606)
                at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1017)
                at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1893)
                at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1798)
                at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350)
                at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1990)
                at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1915)
                at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1798)
                at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350)
                at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370)
                at java.util.HashMap.readObject(HashMap.java:1180)
                at sun.reflect.GeneratedMethodAccessor32.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                at java.lang.reflect.Method.invoke(Method.java:606)
                at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1017)
                at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1893)
                at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1798)
                at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350)
                at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1990)
                at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1915)
                at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1798)
                at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350)
                at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370)
                at java.util.HashMap.readObject(HashMap.java:1180)
                at sun.reflect.GeneratedMethodAccessor32.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                at java.lang.reflect.Method.invoke(Method.java:606)
                at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1017)
                at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1893)
                at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1798)
                at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350)
                at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1990)
                at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1915)
                at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1798)
                at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350)
                at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370)
                at java.util.HashMap.readObject(HashMap.java:1180)
                at sun.reflect.GeneratedMethodAccessor32.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                at java.lang.reflect.Method.invoke(Method.java:606)
                at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1017)
                at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1893)
                at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1798)
                at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350)
                at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1990)
                at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1915)
                at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1798)
                at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350)
                at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370)
                at java.util.HashMap.readObject(HashMap.java:1180)
                at sun.reflect.GeneratedMethodAccessor32.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                at java.lang.reflect.Method.invoke(Method.java:606)
                at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1017)
                at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1893)
                at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1798)
                at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350)
                at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1990)
                at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1915)
                at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1798)
                at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350)
                at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1706)
                at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1344)
                at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1990)
                at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1915)
                at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1798)
                at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350)
                at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370)
                at sun.rmi.server.UnicastRef.unmarshalValue(UnicastRef.java:325)
                at org.ow2.carol.rmi.jrmp.server.JUnicastRef.performRemoteCall(JUnicastRef.java:205)
                ... 53 more

1 Ответ

0 голосов
/ 11 июля 2019

Короче говоря, в нашем коде приложения объект со сложным значением (используемый в качестве возвращаемого значения для удаленных вызовов методов) имел структуру данных HashMap в качестве внутреннего поля.После изменения типа этого поля на ConcurrentHashMap перестали возникать исключения OptionalDataException.Кажется, что где-то в унаследованном коде эта карта обрабатывается не потокобезопасным способом.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...