You can put your saxon-license.lic under WEB-INF/ directory.
J2EE specification does not allow resources under WEB-INF/ to be downloaded, so no risk to share your license.
Then, you can get the absolute path of your file with ServletContext.getRealPath(getContext()+"/WEB-INF/saxon-license.lic").

So, you can initialize your Configuration with a ContextListener...


Le 18/04/2013 11:37, Marek Slama a écrit :
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....

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

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.

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(
2013-04-18 11:26:17,335 ERROR [stderr] (Thread-78)     at java.lang.ClassLoader.defineClass(
2013-04-18 11:26:17,335 ERROR [stderr] (Thread-78)     at$1.findClass(
2013-04-18 11:26:17,335 ERROR [stderr] (Thread-78)     at java.lang.ClassLoader.loadClass(
2013-04-18 11:26:17,335 ERROR [stderr] (Thread-78)     at java.lang.ClassLoader.loadClass(
2013-04-18 11:26:17,336 ERROR [stderr] (Thread-78)     at com.saxonica.bytecode.util.CompilerService.makeClass(
2013-04-18 11:26:17,336 ERROR [stderr] (Thread-78)     at com.saxonica.bytecode.SlashExpressionCompiler.generateMappingFunction(
2013-04-18 11:26:17,336 ERROR [stderr] (Thread-78)     at com.saxonica.bytecode.SlashExpressionCompiler.compileToIterator(
2013-04-18 11:26:17,336 ERROR [stderr] (Thread-78)     at com.saxonica.bytecode.util.CompilerService.compileToIterator(
2013-04-18 11:26:17,337 ERROR [stderr] (Thread-78)     at com.saxonica.bytecode.SlashExpressionCompiler.compileToPush(
2013-04-18 11:26:17,337 ERROR [stderr] (Thread-78)     at com.saxonica.bytecode.util.CompilerService.compileToPush(
2013-04-18 11:26:17,337 ERROR [stderr] (Thread-78)     at com.saxonica.bytecode.util.CompilerService.compileToByteCode(
2013-04-18 11:26:17,337 ERROR [stderr] (Thread-78)     at
2013-04-18 11:26:17,338 ERROR [stderr] (Thread-78)     at
2013-04-18 11:26:17,338 ERROR [stderr] (Thread-78)     at
2013-04-18 11:26:17,338 ERROR [stderr] (Thread-78)     at net.sf.saxon.PreparedStylesheet.setStylesheetDocument(
2013-04-18 11:26:17,338 ERROR [stderr] (Thread-78)     at net.sf.saxon.PreparedStylesheet.prepare(
2013-04-18 11:26:17,338 ERROR [stderr] (Thread-78)     at net.sf.saxon.PreparedStylesheet.compile(
2013-04-18 11:26:17,339 ERROR [stderr] (Thread-78)     at net.sf.saxon.s9api.XsltCompiler.compile(
2013-04-18 11:26:17,339 ERROR [stderr] (Thread-78)     at com.idc.publishing.commons.transformations.SaxonParserUtility.compileXslt(
2013-04-18 11:26:17,339 ERROR [stderr] (Thread-78)     at com.idc.publishing.commons.transformations.SaxonParserUtility.xsltTransformationToString(
2013-04-18 11:26:17,339 ERROR [stderr] (Thread-78)     at com.idc.publishing.commons.transformations.CreateFragment.extractData(
2013-04-18 11:26:17,340 ERROR [stderr] (Thread-78)     at com.idc.publishing.commons.transformations.CreateFragment.manipulateDocXmlStream(
2013-04-18 11:26:17,340 ERROR [stderr] (Thread-78)     at
2013-04-18 11:26:17,340 ERROR [stderr] (Thread-78)     at com.idc.publishing.commons.transformations.CreateFragment.createFactsheetFeeds(
2013-04-18 11:26:17,340 ERROR [stderr] (Thread-78)     at$
2013-04-18 11:26:17,341 ERROR [stderr] (Thread-78)     at java.util.concurrent.ThreadPoolExecutor.runWorker(
2013-04-18 11:26:17,341 ERROR [stderr] (Thread-78)     at java.util.concurrent.ThreadPoolExecutor$
2013-04-18 11:26:17,341 ERROR [stderr] (Thread-78)     at
2013-04-18 11:26:17,341 ERROR [stderr] (Thread-78) Caused by: java.lang.ClassNotFoundException:
2013-04-18 11:26:17,342 ERROR [stderr] (Thread-78)     at java.lang.ClassLoader.findClass(
2013-04-18 11:26:17,342 ERROR [stderr] (Thread-78)     at$1.findClass(
2013-04-18 11:26:17,342 ERROR [stderr] (Thread-78)     at java.lang.ClassLoader.loadClass(
2013-04-18 11:26:17,342 ERROR [stderr] (Thread-78)     at java.lang.ClassLoader.loadClass(
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- which is in WEB-INF/lib (if not nothing would work at all).



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

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!

saxon-help mailing list archived at