On 18 Apr 2013, at 10:37, Marek Slama wrote:

So after some experimentation I found following crucial line in log when I enabled tracing using:
config.setConfigurationProperty(FeatureKeys.TRACE_EXTERNAL_FUNCTIONS, true);

2013-04-18 11:16:17,546 ERROR [stderr] (Thread-78) Calls to extension functions are not permitted without a Saxon license

It is bad that this fatal error is logged only when tracing is enabled and otherwise it is hidden by some other confusing error....

One of the reasons we introduced the stricter rules on namespace URIs for external functions was that with a java:com.package.class URI, we can clearly see that you are trying to load an external function and can give you a clearer message of what's wrong if it can't be loaded. The trouble about the use of a generic URI is that it might never have been intended to be a call on an external Java method (it might for example be a misspelled name for a stylesheet function or a constructor function for a schema type that wasn't in your schema); this means that the only way we can explain why a function wasn't found is to list all the places that we looked for it, which is what the TRACE_EXTERNAL_FUNCTIONS enables.

So problem is again that Saxon is not able to load license on classpath in JBoss.

Yes.

So I have to use:
config.setConfigurationProperty(FeatureKeys.LICENSE_FILE_LOCATION, "/home/mslama/saxon-license.lic");

but this is bad because when I have web app deployed on app server I do not want to depend on any file located on local filesystem.
I want to depend only on resource inside war. So it would be good to support URI like classpath:/saxon-license.lic or support input stream
or reader which will contain license file.

Sounds like a good idea.

This time I get class loader problem:
013-04-18 11:26:17,142 ERROR [stderr] (Thread-78) Trying net.sf.saxon.functions.SystemFunctionLibrary
2013-04-18 11:26:17,334 ERROR [stderr] (Thread-78) Exception in thread "Thread-78" java.lang.NoClassDefFoundError: com/saxonica/bytecode/map/CompiledContextMappingFunction
2013-04-18 11:26:17,334 ERROR [stderr] (Thread-78)     at java.lang.ClassLoader.defineClass1(Native Method)
2013-04-18 11:26:17,335 ERROR [stderr] (Thread-78)     at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
2013-04-18 11:26:17,335 ERROR [stderr] (Thread-78)     at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
2013-04-18 11:26:17,335 ERROR [stderr] (Thread-78)     at net.sf.saxon.java.JavaPlatform$1.findClass(JavaPlatform.java:247)
2013-04-18 11:26:17,335 ERROR [stderr] (Thread-78)     at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
2013-04-18 11:26:17,335 ERROR [stderr] (Thread-78)     at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
2013-04-18 11:26:17,336 ERROR [stderr] (Thread-78)     at com.saxonica.bytecode.util.CompilerService.makeClass(CompilerService.java:859)

Yes, it seems that the byte code generator is creating byte code which it then can't successfully load. (It's creating a class that implements the interface ComplexContextMappingFunction, and the loader fails to load this interface.)

The class loading problem is almost certainly the same one that prevents the license file being loaded.

Class loading in JBoss seems to be a pretty complex subject, and I'm afraid it's one where we have no detailed knowledge to help you.

Michael Kay
Saxonica



2013-04-18 11:26:17,336 ERROR [stderr] (Thread-78)     at com.saxonica.bytecode.SlashExpressionCompiler.generateMappingFunction(SlashExpressionCompiler.java:122)
2013-04-18 11:26:17,336 ERROR [stderr] (Thread-78)     at com.saxonica.bytecode.SlashExpressionCompiler.compileToIterator(SlashExpressionCompiler.java:56)
2013-04-18 11:26:17,336 ERROR [stderr] (Thread-78)     at com.saxonica.bytecode.util.CompilerService.compileToIterator(CompilerService.java:677)
2013-04-18 11:26:17,337 ERROR [stderr] (Thread-78)     at com.saxonica.bytecode.SlashExpressionCompiler.compileToPush(SlashExpressionCompiler.java:146)
2013-04-18 11:26:17,337 ERROR [stderr] (Thread-78)     at com.saxonica.bytecode.util.CompilerService.compileToPush(CompilerService.java:690)
2013-04-18 11:26:17,337 ERROR [stderr] (Thread-78)     at com.saxonica.bytecode.util.CompilerService.compileToByteCode(CompilerService.java:582)
2013-04-18 11:26:17,337 ERROR [stderr] (Thread-78)     at com.saxonica.expr.ee.OptimizerEE.compileToByteCode(OptimizerEE.java:1337)
2013-04-18 11:26:17,338 ERROR [stderr] (Thread-78)     at net.sf.saxon.style.XSLTemplate.optimize(XSLTemplate.java:454)
2013-04-18 11:26:17,338 ERROR [stderr] (Thread-78)     at net.sf.saxon.style.PrincipalStylesheetModule.compileStylesheet(PrincipalStylesheetModule.java:807)
2013-04-18 11:26:17,338 ERROR [stderr] (Thread-78)     at net.sf.saxon.PreparedStylesheet.setStylesheetDocument(PreparedStylesheet.java:360)
2013-04-18 11:26:17,338 ERROR [stderr] (Thread-78)     at net.sf.saxon.PreparedStylesheet.prepare(PreparedStylesheet.java:207)
2013-04-18 11:26:17,338 ERROR [stderr] (Thread-78)     at net.sf.saxon.PreparedStylesheet.compile(PreparedStylesheet.java:106)
2013-04-18 11:26:17,339 ERROR [stderr] (Thread-78)     at net.sf.saxon.s9api.XsltCompiler.compile(XsltCompiler.java:249)
2013-04-18 11:26:17,339 ERROR [stderr] (Thread-78)     at com.idc.publishing.commons.transformations.SaxonParserUtility.compileXslt(SaxonParserUtility.java:84)
2013-04-18 11:26:17,339 ERROR [stderr] (Thread-78)     at com.idc.publishing.commons.transformations.SaxonParserUtility.xsltTransformationToString(SaxonParserUtility.java:60)
2013-04-18 11:26:17,339 ERROR [stderr] (Thread-78)     at com.idc.publishing.commons.transformations.CreateFragment.extractData(CreateFragment.java:188)
2013-04-18 11:26:17,340 ERROR [stderr] (Thread-78)     at com.idc.publishing.commons.transformations.CreateFragment.manipulateDocXmlStream(CreateFragment.java:176)
2013-04-18 11:26:17,340 ERROR [stderr] (Thread-78)     at com.idc.publishing.commons.transformations.CreateFragment.run(CreateFragment.java:142)
2013-04-18 11:26:17,340 ERROR [stderr] (Thread-78)     at com.idc.publishing.commons.transformations.CreateFragment.createFactsheetFeeds(CreateFragment.java:65)
2013-04-18 11:26:17,340 ERROR [stderr] (Thread-78)     at com.idc.publishing.fact_sheet.events.PdfAddedListener$1.run(PdfAddedListener.java:75)
2013-04-18 11:26:17,341 ERROR [stderr] (Thread-78)     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
2013-04-18 11:26:17,341 ERROR [stderr] (Thread-78)     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
2013-04-18 11:26:17,341 ERROR [stderr] (Thread-78)     at java.lang.Thread.run(Thread.java:722)
2013-04-18 11:26:17,341 ERROR [stderr] (Thread-78) Caused by: java.lang.ClassNotFoundException: com.saxonica.bytecode.map.CompiledContextMappingFunction
2013-04-18 11:26:17,342 ERROR [stderr] (Thread-78)     at java.lang.ClassLoader.findClass(ClassLoader.java:522)
2013-04-18 11:26:17,342 ERROR [stderr] (Thread-78)     at net.sf.saxon.java.JavaPlatform$1.findClass(JavaPlatform.java:249)
2013-04-18 11:26:17,342 ERROR [stderr] (Thread-78)     at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
2013-04-18 11:26:17,342 ERROR [stderr] (Thread-78)     at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
2013-04-18 11:26:17,342 ERROR [stderr] (Thread-78)     ... 30 more

So it looks like Saxon had problem with loading classes at runtime on JBoss. I again must say it works correctly outside of JBoss in unit test.

Of course this class reported as missing is in saxon9ee-9.4.0.7.jar which is in WEB-INF/lib (if not nothing would work at all).

Thanks

Marek


On 17 Apr 2013, at 12:06, Marek Slama wrote:

This is method signature:
public class MediaHandler {

    private static final Logger logger = LoggerFactory.getLogger(MediaHandler.class);

    public static String processMediaFile(String inputDocxPath, String imagePath, String docNumber,
        String relationshipId, String counter) throws Exception {

In Jboss7 I get following error:

2013-04-17 12:51:57,141 ERROR [com.idc.publishing.commons.transformations.SaxonParserUtility] (Thread-78) SaxonParserUtilityErrorListener FATAL:: net.sf.saxon.trans.XPathException: Cannot find a matching 5-argument function named {com.idc.publishing.commons.transformations.mediahandler.MediaHandler}processMediaFile(). The namespace URI and local name are recognized, but the number of arguments is wrong

This looks to me like a version mismatch problem of some kind. If Saxon has found a method with the right name but the wrong number of arguments, then presumably it has found a different version than the one you are showing us.

The -TJ trace might be useful.

Michael Kay
Saxonica

------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help