Project

Profile

Help

Bug #3814

"Class not found" attempting to load generated bytecode

Added by Michael Kay over 2 years ago. Updated almost 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Byte code generation
Sprint/Milestone:
-
Start date:
2018-06-11
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.9
Fix Committed on Branch:
9.9
Fixed in Maintenance Release:

Description

Reported by direct support email.

We are using the Apache Karaf 4.1.2 OSGi container to host a Java8 project with Apache Camel. We can install the dependency using Maven, wrapping the Saxon EE as OSGi. It installs successfully and we can make some other bundles call Saxon. But sometimes, when a bundle needs some specific feature of Saxon EE a “Class Not Found” exception occurs.

Stack trace:

org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[ID-EISA-NB0130-64148-1528491347292-38-1]
	at org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1790) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.impl.DefaultExchange.setException(DefaultExchange.java:350) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:64) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:173) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:436) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:168) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:198) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:120) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:83) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.processor.TryProcessor.process(TryProcessor.java:113) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.processor.TryProcessor.process(TryProcessor.java:84) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:198) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:120) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:83) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:198) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.component.directvm.DirectVmProcessor.process(DirectVmProcessor.java:57) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.component.directvm.DirectVmProducer.process(DirectVmProducer.java:68) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.processor.Enricher.process(Enricher.java:187) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:541) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:198) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:120) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:83) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:198) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.component.directvm.DirectVmProcessor.process(DirectVmProcessor.java:57) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.component.directvm.DirectVmProducer.process(DirectVmProducer.java:68) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:145) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:541) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:198) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:120) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:83) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:198) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:62) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:145) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:541) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:198) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:120) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:83) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:198) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:62) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:145) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:541) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:198) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:198) [128:org.apache.camel.camel-core:2.19.2]
	at org.apache.camel.component.jetty.CamelContinuationServlet.doService(CamelContinuationServlet.java:206) [133:org.apache.camel.camel-jetty-common:2.19.2]
	at org.apache.camel.http.common.CamelServlet.service(CamelServlet.java:74) [131:org.apache.camel.camel-http-common:2.19.2]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) [113:javax.servlet-api:3.1.0]
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:845) [220:org.eclipse.jetty.servlet:9.3.14.v20161028]
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:584) [220:org.eclipse.jetty.servlet:9.3.14.v20161028]
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1180) [219:org.eclipse.jetty.server:9.3.14.v20161028]
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:512) [220:org.eclipse.jetty.servlet:9.3.14.v20161028]
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1112) [219:org.eclipse.jetty.server:9.3.14.v20161028]
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [219:org.eclipse.jetty.server:9.3.14.v20161028]
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134) [219:org.eclipse.jetty.server:9.3.14.v20161028]
	at org.eclipse.jetty.server.Server.handle(Server.java:534) [219:org.eclipse.jetty.server:9.3.14.v20161028]
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:320) [219:org.eclipse.jetty.server:9.3.14.v20161028]
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251) [219:org.eclipse.jetty.server:9.3.14.v20161028]
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:273) [211:org.eclipse.jetty.io:9.3.14.v20161028]
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95) [211:org.eclipse.jetty.io:9.3.14.v20161028]
	at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:93) [211:org.eclipse.jetty.io:9.3.14.v20161028]
	at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executeProduceConsume(ExecuteProduceConsume.java:303) [222:org.eclipse.jetty.util:9.3.14.v20161028]
	at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:148) [222:org.eclipse.jetty.util:9.3.14.v20161028]
	at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.execute(ExecuteProduceConsume.java:100) [222:org.eclipse.jetty.util:9.3.14.v20161028]
	at org.eclipse.jetty.io.ManagedSelector.run(ManagedSelector.java:147) [211:org.eclipse.jetty.io:9.3.14.v20161028]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
	at java.lang.Thread.run(Thread.java:748) [?:?]
Caused by: java.lang.NoClassDefFoundError: com/saxonica/ee/bytecode/iter/CompiledBlockIterator
	at java.lang.ClassLoader.defineClass1(Native Method) ~[?:?]
	at java.lang.ClassLoader.defineClass(ClassLoader.java:763) ~[?:?]
	at java.lang.ClassLoader.defineClass(ClassLoader.java:642) ~[?:?]
	at net.sf.saxon.java.JavaPlatform$MyClassLoader.registerClass(JavaPlatform.java:441) ~[?:?]
	at com.saxonica.ee.bytecode.util.CompilerService.makeClass(CompilerService.java:1067) ~[?:?]
	at com.saxonica.ee.bytecode.BlockCompiler.generateBlockIterator(BlockCompiler.java:128) ~[?:?]
	at com.saxonica.ee.bytecode.BlockCompiler.compileToIterator(BlockCompiler.java:84) ~[?:?]
	at com.saxonica.ee.bytecode.util.CompilerService.compileToIterator(CompilerService.java:804) ~[?:?]
	at com.saxonica.ee.bytecode.ChooseCompiler.compileToIterator(ChooseCompiler.java:42) ~[?:?]
	at com.saxonica.ee.bytecode.util.CompilerService.compileToIterator(CompilerService.java:804) ~[?:?]
	at com.saxonica.ee.bytecode.SlashExpressionCompiler.generateMappingFunction(SlashExpressionCompiler.java:116) ~[?:?]
	at com.saxonica.ee.bytecode.SlashExpressionCompiler.compileToIterator(SlashExpressionCompiler.java:56) ~[?:?]
	at com.saxonica.ee.bytecode.util.CompilerService.compileToIterator(CompilerService.java:804) ~[?:?]
	at com.saxonica.ee.bytecode.BlockCompiler$1.generateCase(BlockCompiler.java:221) ~[?:?]
	at com.saxonica.objectweb.asm.commons.GeneratorAdapter.tableSwitch(Unknown Source) ~[?:?]
	at com.saxonica.objectweb.asm.commons.GeneratorAdapter.tableSwitch(Unknown Source) ~[?:?]
	at com.saxonica.ee.bytecode.BlockCompiler.makeNextMethod(BlockCompiler.java:276) ~[?:?]
	at com.saxonica.ee.bytecode.BlockCompiler.generateBlockIterator(BlockCompiler.java:123) ~[?:?]
	at com.saxonica.ee.bytecode.BlockCompiler.compileToIterator(BlockCompiler.java:84) ~[?:?]
	at com.saxonica.ee.bytecode.util.CompilerService.compileToIterator(CompilerService.java:804) ~[?:?]
	at com.saxonica.ee.bytecode.util.CompilerService.compileToByteCode(CompilerService.java:575) ~[?:?]
	at com.saxonica.ee.optim.OptimizerEE.compileToByteCode(OptimizerEE.java:1479) ~[?:?]
	at com.saxonica.ee.bytecode.ByteCodeCandidate.targetExpression(ByteCodeCandidate.java:197) ~[?:?]
	at com.saxonica.ee.bytecode.ByteCodeCandidate.process(ByteCodeCandidate.java:132) ~[?:?]
	at net.sf.saxon.expr.instruct.NamedTemplate.expand(NamedTemplate.java:265) ~[?:?]
	at net.sf.saxon.expr.instruct.CallTemplate.process(CallTemplate.java:353) ~[?:?]
	at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:337) ~[?:?]
	at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:284) ~[?:?]
	at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:151) ~[?:?]
	at net.sf.saxon.expr.instruct.ForEach.processLeavingTail(ForEach.java:472) ~[?:?]
	at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:687) ~[?:?]
	at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:151) ~[?:?]
	at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:337) ~[?:?]
	at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:284) ~[?:?]
	at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:151) ~[?:?]
	at net.sf.saxon.expr.instruct.ForEach.processLeavingTail(ForEach.java:472) ~[?:?]
	at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:687) ~[?:?]
	at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:151) ~[?:?]
	at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:337) ~[?:?]
	at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:284) ~[?:?]
	at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:151) ~[?:?]
	at net.sf.saxon.expr.instruct.ForEach.processLeavingTail(ForEach.java:472) ~[?:?]
	at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:687) ~[?:?]
	at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:151) ~[?:?]
	at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:337) ~[?:?]
	at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:284) ~[?:?]
	at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:151) ~[?:?]
	at net.sf.saxon.expr.instruct.ForEach.processLeavingTail(ForEach.java:472) ~[?:?]
	at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:687) ~[?:?]
	at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:151) ~[?:?]
	at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:337) ~[?:?]
	at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:284) ~[?:?]
	at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:151) ~[?:?]
	at net.sf.saxon.expr.instruct.ForEach.processLeavingTail(ForEach.java:472) ~[?:?]
	at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:151) ~[?:?]
	at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:337) ~[?:?]
	at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:284) ~[?:?]
	at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:347) ~[?:?]
	at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:505) ~[?:?]
	at net.sf.saxon.Controller.transformDocument(Controller.java:2402) ~[?:?]
	at net.sf.saxon.Controller.transform(Controller.java:1970) ~[?:?]
	at net.sf.saxon.s9api.XsltTransformer.transform(XsltTransformer.java:596) ~[?:?]
	at net.sf.saxon.jaxp.TransformerImpl.transform(TransformerImpl.java:73) ~[?:?]
	at com.ericsson.bss.si.apilayer.veon.ukraine.core.transformation.transformer.APILTransformerImpl.transform(APILTransformerImpl.java:149) ~[94:apil-core-transformation:1.6.1.SNAPSHOT]
	at com.ericsson.bss.si.apilayer.veon.ukraine.core.transformation.transformer.APILTransformerImpl.transformExchangeInputByXSLT(APILTransformerImpl.java:102) ~[94:apil-core-transformation:1.6.1.SNAPSHOT]
	at com.ericsson.bss.si.apilayer.veon.ukraine.core.transformation.camel.components.xslt.APILTransformInputByXSLTProcessor.process(APILTransformInputByXSLTProcessor.java:48) ~[94:apil-core-transformation:1.6.1.SNAPSHOT]
	at org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:103) ~[?:?]
	at org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:71) ~[?:?]
	at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61) ~[?:?]
	... 69 more
Caused by: java.lang.ClassNotFoundException: com.saxonica.ee.bytecode.iter.CompiledBlockIterator
	at java.lang.ClassLoader.findClass(ClassLoader.java:530) ~[?:?]
	at net.sf.saxon.java.JavaPlatform$MyClassLoader.findClass(JavaPlatform.java:454) ~[?:?]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:?]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:?]
	at java.lang.ClassLoader.defineClass1(Native Method) ~[?:?]
	at java.lang.ClassLoader.defineClass(ClassLoader.java:763) ~[?:?]
	at java.lang.ClassLoader.defineClass(ClassLoader.java:642) ~[?:?]
	at net.sf.saxon.java.JavaPlatform$MyClassLoader.registerClass(JavaPlatform.java:441) ~[?:?]
	at com.saxonica.ee.bytecode.util.CompilerService.makeClass(CompilerService.java:1067) ~[?:?]
	at com.saxonica.ee.bytecode.BlockCompiler.generateBlockIterator(BlockCompiler.java:128) ~[?:?]
	at com.saxonica.ee.bytecode.BlockCompiler.compileToIterator(BlockCompiler.java:84) ~[?:?]
	at com.saxonica.ee.bytecode.util.CompilerService.compileToIterator(CompilerService.java:804) ~[?:?]
	at com.saxonica.ee.bytecode.ChooseCompiler.compileToIterator(ChooseCompiler.java:42) ~[?:?]
	at com.saxonica.ee.bytecode.util.CompilerService.compileToIterator(CompilerService.java:804) ~[?:?]
	at com.saxonica.ee.bytecode.SlashExpressionCompiler.generateMappingFunction(SlashExpressionCompiler.java:116) ~[?:?]
	at com.saxonica.ee.bytecode.SlashExpressionCompiler.compileToIterator(SlashExpressionCompiler.java:56) ~[?:?]
	at com.saxonica.ee.bytecode.util.CompilerService.compileToIterator(CompilerService.java:804) ~[?:?]
	at com.saxonica.ee.bytecode.BlockCompiler$1.generateCase(BlockCompiler.java:221) ~[?:?]
	at com.saxonica.objectweb.asm.commons.GeneratorAdapter.tableSwitch(Unknown Source) ~[?:?]
	at com.saxonica.objectweb.asm.commons.GeneratorAdapter.tableSwitch(Unknown Source) ~[?:?]
	at com.saxonica.ee.bytecode.BlockCompiler.makeNextMethod(BlockCompiler.java:276) ~[?:?]
	at com.saxonica.ee.bytecode.BlockCompiler.generateBlockIterator(BlockCompiler.java:123) ~[?:?]
	at com.saxonica.ee.bytecode.BlockCompiler.compileToIterator(BlockCompiler.java:84) ~[?:?]
	at com.saxonica.ee.bytecode.util.CompilerService.compileToIterator(CompilerService.java:804) ~[?:?]
	at com.saxonica.ee.bytecode.util.CompilerService.compileToByteCode(CompilerService.java:575) ~[?:?]
	at com.saxonica.ee.optim.OptimizerEE.compileToByteCode(OptimizerEE.java:1479) ~[?:?]
	at com.saxonica.ee.bytecode.ByteCodeCandidate.targetExpression(ByteCodeCandidate.java:197) ~[?:?]
	at com.saxonica.ee.bytecode.ByteCodeCandidate.process(ByteCodeCandidate.java:132) ~[?:?]
	at net.sf.saxon.expr.instruct.NamedTemplate.expand(NamedTemplate.java:265) ~[?:?]
	at net.sf.saxon.expr.instruct.CallTemplate.process(CallTemplate.java:353) ~[?:?]
	at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:337) ~[?:?]
	at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:284) ~[?:?]
	at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:151) ~[?:?]
	at net.sf.saxon.expr.instruct.ForEach.processLeavingTail(ForEach.java:472) ~[?:?]
	at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:687) ~[?:?]
	at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:151) ~[?:?]
	at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:337) ~[?:?]
	at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:284) ~[?:?]
	at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:151) ~[?:?]
	at net.sf.saxon.expr.instruct.ForEach.processLeavingTail(ForEach.java:472) ~[?:?]
	at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:687) ~[?:?]
	at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:151) ~[?:?]
	at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:337) ~[?:?]
	at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:284) ~[?:?]
	at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:151) ~[?:?]
	at net.sf.saxon.expr.instruct.ForEach.processLeavingTail(ForEach.java:472) ~[?:?]
	at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:687) ~[?:?]
	at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:151) ~[?:?]
	at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:337) ~[?:?]
	at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:284) ~[?:?]
	at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:151) ~[?:?]
	at net.sf.saxon.expr.instruct.ForEach.processLeavingTail(ForEach.java:472) ~[?:?]
	at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:687) ~[?:?]
	at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:151) ~[?:?]
	at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:337) ~[?:?]
	at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:284) ~[?:?]
	at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:151) ~[?:?]
	at net.sf.saxon.expr.instruct.ForEach.processLeavingTail(ForEach.java:472) ~[?:?]
	at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:151) ~[?:?]
	at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:337) ~[?:?]
	at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:284) ~[?:?]
	at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:347) ~[?:?]
	at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:505) ~[?:?]
	at net.sf.saxon.Controller.transformDocument(Controller.java:2402) ~[?:?]
	at net.sf.saxon.Controller.transform(Controller.java:1970) ~[?:?]
	at net.sf.saxon.s9api.XsltTransformer.transform(XsltTransformer.java:596) ~[?:?]
	at net.sf.saxon.jaxp.TransformerImpl.transform(TransformerImpl.java:73) ~[?:?]
	at com.ericsson.bss.si.apilayer.veon.ukraine.core.transformation.transformer.APILTransformerImpl.transform(APILTransformerImpl.java:149) ~[94:apil-core-transformation:1.6.1.SNAPSHOT]
	at com.ericsson.bss.si.apilayer.veon.ukraine.core.transformation.transformer.APILTransformerImpl.transformExchangeInputByXSLT(APILTransformerImpl.java:102) ~[94:apil-core-transformation:1.6.1.SNAPSHOT]
	at com.ericsson.bss.si.apilayer.veon.ukraine.core.transformation.camel.components.xslt.APILTransformInputByXSLTProcessor.process(APILTransformInputByXSLTProcessor.java:48) ~[94:apil-core-transformation:1.6.1.SNAPSHOT]
	at org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:103) ~[?:?]
	at org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:71) ~[?:?]
	at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61) ~[?:?]
	... 69 more

History

#1 Updated by Michael Kay over 2 years ago

The critical part of the stack trace is this:

Caused by: java.lang.NoClassDefFoundError: com/saxonica/ee/bytecode/iter/CompiledBlockIterator
    at java.lang.ClassLoader.defineClass1(Native Method) ~[?:?]
    at java.lang.ClassLoader.defineClass(ClassLoader.java:763) ~[?:?]
    at java.lang.ClassLoader.defineClass(ClassLoader.java:642) ~[?:?]
    at net.sf.saxon.java.JavaPlatform$MyClassLoader.registerClass(JavaPlatform.java:441) ~[?:?]
    at com.saxonica.ee.bytecode.util.CompilerService.makeClass(CompilerService.java:1067) ~[?:?]
    at com.saxonica.ee.bytecode.BlockCompiler.generateBlockIterator(BlockCompiler.java:128) ~[?:?]

Saxon is generating a bytecode class as a subclass of CompiledBlockIterator; the CompiledBlockIterator class is in the JAR file so one would expect it to be found. I suspect the reason it isn't found is that it was loaded using a different ClassLoader.

I have suggested a couple of experiments:

(1) try calling

configuration.getDynamicLoader().setClassLoader(Configuration.class.getClassLoader());

where configuration is the Saxon Configuration object (obtainable from the s9api Processor or the JAXP TransformerFactory, for example)

(2) try calling

configuration.setDynamicLoader(new DynamicLoader() {

@Override

protected void registerKnownClasses() {

super.registerKnownClasses();

knownClasses.put("com/saxonica/ee/bytecode/iter/CompiledBlockIterator", com.saxonica.ee.bytecode.iter.CompiledBlockIterator.class);

}

};

My theory here is that the use of OSGi means that Saxon classes are being loaded using a different classLoader from the one that we are attempting to use to load the bytecode that we generate dynamically.

#2 Updated by Pedro Reis over 2 years ago

Thank you, Michael Kay, for your assistance.

As your suspicion,Tte issue was in a mismatch between the classloader in use by osgi and saxon. We got this working with the following snippet code:

configuration.getDynamicLoader().setClassLoader(Configuration.class.getClassLoader());

#3 Updated by Michael Kay about 2 years ago

  • Description updated (diff)
  • Status changed from New to In Progress

Some observations:

(a) JavaPlatform.MyClassLoader and DotNetPlatform.MyClassLoader appear to be identical code and could be commoned up.

(b) They are also wrong, because they use a Hashtable without synchronisation - bytecode generation can happen in multiple threads.

(c) Platform.getClassLoader() is called ONLY from CompilerService and is used ONLY for loading generated bytecode.

(d) The only difference between the Java and DotNet versions of Platform.getClassLoader() is that Java prefers to use Thread.currentThread().getContextClassLoader() while .NET prefers thisClass.getClassLoader(). I wonder if that difference is really intentional, or if it just happened by accident?

(e) In fact both platforms prefer to use config.getDynamicLoader().getClassLoader(), but this will normally be null, unless the user has set it explicitly. (There is only one call of DynamicLoader.setClassLoader(), which is in ConfigurationReader, whose own ClassLoader is normally null. All pretty weird.

What led me here was the thought that we can use the "knownClasses" mechanism in the standard DynamicLoaderEE to load the statically known instance of the superclasses from which generated code classes inherit:

knownClasses.put("com.saxonica.ee.bytecode.iter.CompiledBlockIterator", CompiledBlockIterator.class);

etc, to ensure these classes can always be found. But I'm not sure that the class loader we use for generated byte code actually looks for these known classes.

I'll explore this by tracing through the debugger.

#4 Updated by Michael Kay almost 2 years ago

Current status in 9.9.

(a) JavaPlatform.MyClassLoader and DotNetPlatform.MyClassLoader no longer exist; the code has been merged into GeneratedClassLoader which was previously an interface and is now a concrete class.

(b) GeneratedClassLoader uses a ConcurrentHashMap() so the multithreading problems are solved.

(c) Platform.getClassLoader() no longer exists.

So most of these issues have been tidied up.

There is still some nonsense because Platform.makeGeneratedClassLoader() is called only from CompilerService, therefore only in Saxon-EE, and yet it contains logic for non-EE paths.

Now back to the original problem. Tricky to do anything here because we don't have an environment that reproduces the bug. I've tried tracing exactly what happens in the IntelliJ environment, but it serves only to confuse. For example, the exercise reveals that GeneratedClassLoader.findClass() is never called. The spec says that this method is called only if the parent class loader can't find the class, but in our set-up, it seems that the parent class loader always can.

I tried interposing an artificial parent class loader like this (in JavaPlatform.makeGeneratedClassLoader():

        parentClassLoader = new ClassLoader(parentClassLoader) {
            @Override
            public Class<?> loadClass(String name, boolean b) throws ClassNotFoundException {
                return super.loadClass(name, b);
            }
        };
        return new GeneratedClassLoader(parentClassLoader);

The loadClass() method of this classloader does get invoked to load the superclasses of generated code classes such as "com.saxonica.ee.bytecode.map.ForSequenceMappingAction". So it looks as if we could interpose a parent class loader that knows about these classes at this point, for use in cases where the "default" parent class loader doesn't know about them.

#5 Updated by Michael Kay almost 2 years ago

I've tried this and it works, but I don't think it will solve the problem. The interposed parent class loader is being called not only to load these superclasses of generated code (such as com.saxonica.ee.bytecode.GeneratedCode), it is also being called to load all classes referenced from the generated code, such as net.sf.saxon.value.StringValue, and it's obviously not feasible to enumerate all such classes.

I think we're going to have to see if we can replicate the problem under OSGi and find a fix that works in the real environment.

#6 Updated by Michael Kay almost 2 years ago

  • Status changed from In Progress to Resolved
  • Applies to branch 9.9 added
  • Fix Committed on Branch 9.9 added

Marking as resolved because we've fixed a number of side-issues found while investigating; and support for OSGi is on the requirements list under a separate issue.

#7 Updated by O'Neil Delpratt almost 2 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in Maintenance Release 9.9.0.2 added

Bug fix applied to the Saxon 9.9.0.2 maintenance release.

Please register to edit this issue

Also available in: Atom PDF