Oracle ADF意外的空指针异常在单独的线程中访问视图对象时

时间:2018-03-09 17:22:08

标签: multithreading nullpointerexception oracle-adf

我在adf中有一个处理请求的web服务,我使用运行在视图对象迭代器中的jar中的方法等等。

在处理请求时,我从所述jar调用一个方法,该方法初始化一个单独的线程,该线程操作并比较该单独线程中视图对象的行,

我收到如下随机异常:

## Detail 0 ##
  

显示java.lang.NullPointerException       at oracle.jbo.server.ViewRowSetIteratorImpl.initViewRowSetIteratorImpl(ViewRowSetIteratorImpl.java:227)       在oracle.jbo.server.ViewRowSetIteratorImpl。(ViewRowSetIteratorImpl.java:176)       在oracle.jbo.server.ViewRowSetImpl.createNewRowSetIterator(ViewRowSetImpl.java:1434)       at oracle.jbo.server.ViewRowSetImpl.createViewRowSetIterator(ViewRowSetImpl.java:1485)       at oracle.jbo.server.ViewRowSetImpl.getDefaultRowSetIterator(ViewRowSetImpl.java:1704)       at oracle.jbo.server.ViewRowSetImpl.setRangeSize(ViewRowSetImpl.java:2936)       at oracle.jbo.server.ViewObjectImpl.doCreateViewLinkAccessorRS(ViewObjectImpl.java:16080)       at oracle.jbo.server.ViewObjectImpl.createViewLinkAccessorRS(ViewObjectImpl.java:16171)       at oracle.jbo.server.AssociationDefImpl.get(AssociationDefImpl.java:472)       at oracle.jbo.server.ViewAttributeDefImpl.get(ViewAttributeDefImpl.java:949)       at oracle.jbo.server.ViewRowStorage.getViewLinkAccessorResult(ViewRowStorage.java:1528)       at oracle.jbo.server.ViewRowStorage.getAttributeInternal(ViewRowStorage.java:1827)       at oracle.jbo.server.ViewRowImpl.getAttributeValue(ViewRowImpl.java:1923)       在oracle.jbo.server.ViewRowImpl.getAttributeInternal(ViewRowImpl.java:866)

## Detail 0 ##
  

显示java.lang.NullPointerException       at oracle.jbo.server.ViewRowImpl.getUseViewLogicGroupDef(ViewRowImpl.java:6078)       at oracle.jbo.server.ViewRowStorage.getViewAttributeDef(ViewRowStorage.java:1432)       at oracle.jbo.server.ViewRowStorage.getAttributeInternal(ViewRowStorage.java:1778)       at oracle.jbo.server.ViewRowImpl.getAttributeValue(ViewRowImpl.java:1923)       在oracle.jbo.server.ViewRowImpl.getAttributeInternal(ViewRowImpl.java:866)

  

引起:java.lang.NullPointerException       at oracle.jbo.server.ViewRowSetIteratorImpl.initViewRowSetIteratorImpl(ViewRowSetIteratorImpl.java:227)       在oracle.jbo.server.ViewRowSetIteratorImpl。(ViewRowSetIteratorImpl.java:176)       在oracle.jbo.server.ViewRowSetImpl.createNewRowSetIterator(ViewRowSetImpl.java:1434)       at oracle.jbo.server.ViewRowSetImpl.createViewRowSetIterator(ViewRowSetImpl.java:1485)       at oracle.jbo.server.ViewRowSetImpl.getDefaultRowSetIterator(ViewRowSetImpl.java:1704)       at oracle.jbo.server.ViewRowSetImpl.setRangeSize(ViewRowSetImpl.java:2936)       at oracle.jbo.server.ViewObjectImpl.doCreateViewLinkAccessorRS(ViewObjectImpl.java:16080)       at oracle.jbo.server.ViewObjectImpl.createViewLinkAccessorRS(ViewObjectImpl.java:16171)       at oracle.jbo.server.AssociationDefImpl.get(AssociationDefImpl.java:472)       at oracle.jbo.server.ViewAttributeDefImpl.get(ViewAttributeDefImpl.java:949)       at oracle.jbo.server.ViewRowStorage.getViewLinkAccessorResult(ViewRowStorage.java:1528)       at oracle.jbo.server.ViewRowStorage.getAttributeInternal(ViewRowStorage.java:1827)       at oracle.jbo.server.ViewRowImpl.getAttributeValue(ViewRowImpl.java:1923)       在oracle.jbo.server.ViewRowImpl.getAttributeInternal(ViewRowImpl.java:866)

当它在没有jar的情况下运行时相同的方法(类似于jar中的代码但是作为同一项目的一部分),它执行得非常好。

你能告诉我为什么会引发NullPointerException吗? 感谢

1 个答案:

答案 0 :(得分:1)

您不能在线程中使用业务组件(ViewObject,Entities ...等)。

没有上下文(FacesContext无法初始化)。因此,您必须将ApplicationModule作为参数传递给您的方法。但是处理需要花费大量时间

因此,访问数据的最佳方法是使用带有Java数据源连接的CallableStatments PreparedStatments。