Java Saxon9命名空间LRUCache中的NullPointerException
我们的生产系统(Java7运行时)中的XSLT转换有时会失败,下面提供了NullPointerException。 据我从Saxon9源代码中了解,LRUCache类是AnyURIValue类中的静态类成员。 我对此做了一些研究,并了解到这可能是由于 潜在的LinkedHashMap,这将解释问题似乎出现在我们随机的时间点Java Saxon9命名空间LRUCache中的NullPointerException,java,xslt,saxon,Java,Xslt,Saxon,我们的生产系统(Java7运行时)中的XSLT转换有时会失败,下面提供了NullPointerException。 据我从Saxon9源代码中了解,LRUCache类是AnyURIValue类中的静态类成员。 我对此做了一些研究,并了解到这可能是由于 潜在的LinkedHashMap,这将解释问题似乎出现在我们随机的时间点 The [java.lang.NullPointerException] occurred during XSLT transformation: java.lang.Nu
The [java.lang.NullPointerException] occurred during XSLT transformation: java.lang.NullPointerException
at com.tibco.plugin.xml.XMLTransformActivity.eval(Unknown Source)
at com.tibco.pe.plugin.Activity.eval(Unknown Source)
at com.tibco.pe.core.TaskImpl.eval(Unknown Source)
at com.tibco.pe.core.Job.a(Unknown Source)
at com.tibco.pe.core.Job.k(Unknown Source)
at com.tibco.pe.core.JobDispatcher$JobCourier.a(Unknown Source)
at com.tibco.pe.core.JobDispatcher$JobCourier.run(Unknown Source)
caused by: java.lang.NullPointerException at java.util.LinkedHashMap$Entry.remove(Unknown Source)
at java.util.LinkedHashMap$Entry.recordRemoval(Unknown Source)
at java.util.HashMap.removeEntryForKey(Unknown Source)
at java.util.LinkedHashMap.addEntry(Unknown Source)
at java.util.HashMap.put(Unknown Source)
at net.sf.saxon.sort.LRUCache.put(LRUCache.java:47)
at net.sf.saxon.value.AnyURIValue.isValidURI(AnyURIValue.java:103)
at net.sf.saxon.instruct.Namespace.checkPrefixAndUri(Namespace.java:184)
at net.sf.saxon.instruct.Namespace.processLeavingTail(Namespace.java:144)
at net.sf.saxon.instruct.Block.processLeavingTail(Block.java:399)
at net.sf.saxon.instruct.Instruction.process(Instruction.java:94)
at net.sf.saxon.instruct.ElementCreator.processLeavingTail(ElementCreator.java:298)
at net.sf.saxon.instruct.Template.applyLeavingTail(Template.java:175)
at net.sf.saxon.instruct.ApplyTemplates.applyTemplates(ApplyTemplates.java:343)
at net.sf.saxon.instruct.ApplyTemplates.defaultAction(ApplyTemplates.java:376)
at net.sf.saxon.instruct.ApplyTemplates.applyTemplates(ApplyTemplates.java:331)
at net.sf.saxon.Controller.transformDocument(Controller.java:1735)
at net.sf.saxon.Controller.transform(Controller.java:1559)
at com.tibco.plugin.xml.XMLTransformActivity.new(Unknown Source)
at com.tibco.plugin.xml.XMLTransformActivity.eval(Unknown Source)
at com.tibco.pe.plugin.Activity.eval(Unknown Source)
at com.tibco.pe.core.TaskImpl.eval(Unknown Source)
at com.tibco.pe.core.Job.a(Unknown Source)
at com.tibco.pe.core.Job.k(Unknown Source)
at com.tibco.pe.core.JobDispatcher$JobCourier.a(Unknown Source)
at com.tibco.pe.core.JobDispatcher$JobCourier.run(Unknown Source)
- 有没有人在Saxon9上遇到过同样的问题
- 在eclipse中重现问题的最佳方法是什么
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
public class Main {
private static final int NTHREDS = 100;
private static final int EXECUTION_COUNT = 10000;
public static void main(String[] args) throws InterruptedException {
ExecutorService executor = Executors.newFixedThreadPool(NTHREDS);
for (int i = 0; i < EXECUTION_COUNT; i++) {
Runnable worker = new TestRunnable(i);
executor.execute(worker);
}
executor.shutdown();
executor.awaitTermination(10, TimeUnit.SECONDS);
}
}
import net.sf.saxon.sort.LRUCache;
public class TestRunnable implements Runnable {
private static LRUCache cache = new LRUCache(20); // The LRUCache is a static member in Saxon's AnyURIValue.class!
private int number;
public TestRunnable(int number){
this.number = number;
}
@Override
public void run() {
/**
* Access elements in ascending order to trigger the call to LinkedHashMap$Entry.remove;
*/
for(int i = 0; i < number; i++){
cache.get(new Integer(i));
}
/**
* Add the new element to the cache.
* As soon as the cacheSize exceeds 20, the cache is starting to remove the last accessed element.
*/
cache.put(new Integer(number), new Integer(number));
}
}
导入java.util.concurrent.ExecutorService;
导入java.util.concurrent.Executors;
导入java.util.concurrent.TimeUnit;
公共班机{
专用静态最终整数=100;
私有静态最终整数执行计数=10000;
公共静态void main(字符串[]args)引发InterruptedException{
ExecutorService executor=Executors.newFixedThreadPool(n个红色);
for(int i=0;i
Saxon9不是一个版本,而是一个由6个主要版本(9.0到9.5)组成的序列,在大约7年的时间内发布了更多的维护版本。你需要更精确地知道你使用的是哪个版本
例如,多年来,对于涉及LRUCache的问题,已经有了一些解决方案
尽管这两种情况都没有将NullPointerException描述为观察到的症状,但它们可能反映了相同的根本原因
Saxon 9.5代码在需要的情况下使用ConcurrentHashMap,AnyURIValue类不再使用LRUCache。非常感谢您的回复!从net.sf.saxon.Version类中,我可以看到以下Saxon9版本信息:Version=“9.0.0.2”BUILD=“113012”RELEASE\u DATE=“2007-11-30”此版本的Saxon9随公司使用的产品一起提供。出于法律原因,我们可能无法自行升级Saxon版本,但我会向供应商提出要求。作为中间解决方案,我将用XSLT1.0元素替换XSLT2.0元素,并使用内置XSLT1.0引擎的产品;如果不详细了解Tibco是否依赖于Saxon“内部”接口,并且无法访问全面的测试套件,那么更改Tibco使用的Saxon版本将是非常不明智的。推动他们前进!