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

Oracle ADF Unexpected Null Pointer Exception When accessing view objects in a seperate thread

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

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

我收到如下随机异常:

## Detail 0 ##

java.lang.NullPointerException at oracle.jbo.server.ViewRowSetIteratorImpl.initViewRowSetIteratorImpl(ViewRowSetIteratorImpl.java:227) at oracle.jbo.server.ViewRowSetIteratorImpl.(ViewRowSetIteratorImpl.java:176) at 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) at 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) at oracle.jbo.server.ViewRowImpl.getAttributeInternal(ViewRowImpl.java:866)

Caused by: java.lang.NullPointerException at oracle.jbo.server.ViewRowSetIteratorImpl.initViewRowSetIteratorImpl(ViewRowSetIteratorImpl.java:227) at oracle.jbo.server.ViewRowSetIteratorImpl.(ViewRowSetIteratorImpl.java:176) at 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) at oracle.jbo.server.ViewRowImpl.getAttributeInternal(ViewRowImpl.java:866)

在没有 jar 的情况下 运行 使用相同的方法(与 jar 中的代码相同,但作为同一项目的一部分),它执行得非常好。

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

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

没有上下文(无法初始化 FacesContext)。因此您必须将 ApplicationModule 作为参数传递给您的方法。但是处理起来会花费很多时间

因此,访问数据的最佳方法是将 CallableStatments PreparedStatments 与 Java 数据源连接一起使用。