Project

Profile

Help

Saxon servlet throws exception with Saxon 11.4

Added by Michael Brazier about 2 years ago

If I add any parameter to the URL beyond source and style the servlet fails with the following root cause exception:

java.lang.NoSuchMethodError: 'void net.sf.saxon.value.StringValue.<init>(java.lang.CharSequence)'
	SaxonServlet.apply(SaxonServlet.java:102)
	SaxonServlet.service(SaxonServlet.java:54)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

I notice that the internal Saxon string class changed in 11, but it's surprising that the new class can't be constructed from a CharSequence. How do you construct a StringValue now?


Replies (3)

Please register to reply

RE: Saxon servlet throws exception with Saxon 11.4 - Added by Michael Kay about 2 years ago

I had quite forgotten that the Saxon sample servlet is still included in the distribution, and I suspect that it is no longer tested in new releases. It is only intended to be illustrative code, not a production-quality piece of software, but we should make sure it works.

I'm wondering what version of the code you're looking at? I can't find a version that uses a CharSequence on line 102. It's true, however, that the sample code is using interfaces below the s9api/JAXP level which are always at risk of changing between releases. Unfortunately JAXP interfaces are very weakly typed so this is difficult to avoid.

StringValue has a static factory method makeStringValue that accepts a CharSequence. I think the change in the constructor was probably unintended; the CharSequence class gave us a lot of hassle in transpiling the code to C#.

RE: Saxon servlet throws exception with Saxon 11.4 - Added by Michael Brazier about 2 years ago

I believe the code I was using was from the Saxon 9 resources, which may tell you how long it's been since I last compiled it. The code in the Saxon 11 resources uses a String to construct the parameter value, and that version works when compiled.

Thanks for your help.

    (1-3/3)

    Please register to reply