Project

Profile

Help

Saxon .NET throws NoClassDefFoundError

Added by Jakub Maly over 12 years ago

I want to run Saxon from .NET application using following code:

Processor processor = new Processor(); XsltCompiler xsltCompiler = processor.NewXsltCompiler(); using (StringReader sr = new StringReader(xslt)) { XsltExecutable xsltExecutable = xsltCompiler.Compile(sr);

The last line throws NoClassDefFoundError, the stack trace of the error is as follows:

at IKVM.NativeCode.java.lang.ClassLoader.defineClass1(ClassLoader thisClassLoader, String name, Byte[] b, Int32 off, Int32 len, Object pd, String source) at java.lang.ClassLoader.defineClass1(String , Byte[] , Int32 , Int32 , ProtectionDomain , String ) at java.lang.ClassLoader.defineClass(String name, Byte[] b, Int32 off, Int32 len, ProtectionDomain protectionDomain) at java.lang.ClassLoader.defineClass(String name, Byte[] b, Int32 off, Int32 len) at com.saxonica.bytecode.util.CompilerService$1.findClass(String ) at java.lang.ClassLoader.loadClass(String name, Boolean resolve) at java.lang.ClassLoader.loadClass(String name) at com.saxonica.bytecode.util.CompilerService.makeClass(ClassWriter writer, String className) at com.saxonica.bytecode.BlockCompiler.generateBlockIterator(CompilerService , Expression , Expression[] ) at com.saxonica.bytecode.BlockCompiler.compileToIterator(CompilerService compiler, Expression expression) at com.saxonica.bytecode.util.CompilerService.compileToIterator(Expression expr) at com.saxonica.bytecode.util.CompilerService.compileToByteCode(Expression expr, String objectName, Int32 evaluationModes) at com.saxonica.bytecode.LetExpressionCompiler.compileCommonExpr(CompilerService compiler, Expression exp, Int32 evaluationMode, Int32 refCount) at com.saxonica.bytecode.ApplyTemplatesCompiler.compileParameterSet(CompilerService compiler, ExpressionCompiler ec, WithParam[] params) at com.saxonica.bytecode.CallTemplateCompiler.compileToPush(CompilerService compiler, Expression expression) at com.saxonica.bytecode.util.CompilerService.compileToPush(Expression expr) at com.saxonica.bytecode.ElementCreatorCompiler.compileToPush(CompilerService compiler, Expression expression) at com.saxonica.bytecode.util.CompilerService.compileToPush(Expression expr) at com.saxonica.bytecode.util.CompilerService.compileToByteCode(Expression expr, String objectName, Int32 evaluationModes) at com.saxonica.expr.ee.OptimizerEE.compileToByteCode(Expression expr, String objectName, Int32 evaluationMethods) at net.sf.saxon.style.XSLTemplate.optimize(Declaration declaration) at net.sf.saxon.style.PrincipalStylesheetModule.compileStylesheet() at net.sf.saxon.PreparedStylesheet.setStylesheetDocument(DocumentImpl doc) at net.sf.saxon.PreparedStylesheet.prepare(Source styleSource) at net.sf.saxon.TransformerFactoryImpl.newTemplates(Source source, CompilerInfo info) at Saxon.Api.XsltCompiler.Compile(TextReader input) at Exolutio.Revalidation.XSLT.XsltProcessing.TransformSAXON(String document, String xslt, String tmpDir) in D:\Programování\EvoXSVN\Revalidation\XSLT\XsltProcessing.cs:line 37 at Exolutio.Revalidation.XSLT.XsltProcessing.Transform(String document, String xslt, String tmpDir) in D:\Programování\EvoXSVN\Revalidation\XSLT\XsltProcessing.cs:line 19 at Exolutio.View.Commands.XsltTestWindow.Transform() in D:\Programování\EvoXSVN\View\Commands\Versioning\XsltTestWindow.xaml.cs:line 229 at Exolutio.View.Commands.XsltTestWindow.Button_Click_1(Object sender, RoutedEventArgs e) in D:\Programování\EvoXSVN\View\Commands\Versioning\XsltTestWindow.xaml.cs:line 219 at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e) at System.Windows.Controls.Primitives.ButtonBase.OnClick() at System.Windows.Controls.Button.OnClick() at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e) at System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e) at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget) at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent) at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e) at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget) at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args) at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted) at System.Windows.Input.InputManager.ProcessStagingArea() at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input) at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport) at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel) at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

The stylesheet is XSLT 3.0 and runs fine when executed from the command line. Maybe I did something wrong setting up assemblies references? I reference these assemblies in the project

saxon9ee saxon9ee-api + IKVM.Runtime

I also added the rest of the IKVM assemblies that come with Saxon:

IVKM.OpenJDK.Core IVKM.OpenJDK.Charsets IVKM.OpenJDK.Security IVKM.OpenJDK.Text IVKM.OpenJDK.Util IVKM.OpenJDK.XML.API

But no change. Any suggestions?


Replies (11)

Please register to reply

RE: Saxon .NET throws NoClassDefFoundError - Added by Jakub Maly over 12 years ago

The exact same code works when I use home edition assemblies saxon9he, saxon9he-api (and use 3.0 stylesheet).

RE: Saxon .NET throws NoClassDefFoundError - Added by Jakub Maly over 12 years ago

Sorry, I meant to write The exact same code works when I use home edition assemblies saxon9he, saxon9he-api (and use 2.0 stylesheet).

RE: Saxon .NET throws NoClassDefFoundError - Added by Michael Kay over 12 years ago

It's a failure connected with byte code generation, so it's not surprising that it works OK with Saxon HE. As a workaround you could also make it work by disabling byte code generation (FeatureKey GENERATE_BYTE_CODE = false).

Please confirm that you are using the latest maintenance relese (9.4.0.3). This is built using an updated version of IKVM that fixes a bug in byte code verification (we were generating legal but somewhat unusual byte code, and IKVM was rejecting it during the verification phase of loading the generated class).

If you are using the latest version, it would be helpful if you can let us have a copy of the stylesheet so that we can attempt to reproduce the error.

RE: Saxon .NET throws NoClassDefFoundError - Added by Jakub Maly over 12 years ago

Thanks for the workaround, with xsltCompiler.Processor.SetProperty(FeatureKeys.GENERATE_BYTE_CODE, "false"); the stylesheet runs successfully.

I am using 9.4.0.3, downloaded from http://www.saxonica.com/download/download_page.xml.

Attached you can find a stylesheet demonstrating the problem.

RE: Saxon .NET throws NoClassDefFoundError - Added by O'Neil Delpratt over 12 years ago

Hi Jakub,

We have been unable to reproduce the error you are getting on Saxon 9.4.03. Would you be able to add the following to your stylesheet and confirm the version you are running: <xsl:value-of select="system-property('xsl:product-version')"/>

RE: Saxon .NET throws NoClassDefFoundError - Added by Jakub Maly over 12 years ago

xsl:product-version says 'EE 9.4.0.3' I do receive the error for the sample file I uploaded earlier.

RE: Saxon .NET throws NoClassDefFoundError - Added by O'Neil Delpratt over 12 years ago

We will need to better understand your setup and how you are running the stylesheet. Would you be able to supply me with the cs file you are using (maybe offline: ) which builds the xslt processor.

RE: Saxon .NET throws NoClassDefFoundError - Added by O'Neil Delpratt over 12 years ago

Hi Jakub, Thanks for sending me your sample solution. Unfortunately I am still not able to reproduce the error using Saxon 9.4.0.3. We would definitely like to assist you to get to the bottom of this problem. Incidentally, I reinstalled Saxon 9.4.0.2 and ran your stylesheet which reproduced the NoClassDefFoundError exception. I conjecture that an old installation of Saxon 9.4.0.2 is in the gac cache and is actually in use.

I have experienced this kind of problem before of having the latest assembly within the project solution, but that which is executed is an older version. Therefore I suggest that you clear any existing Saxon assembly cached in the gac, I used the gacview application to do this. Then reinstall Saxon 9.4.0.3 version again (you might be inclined to go for the latest maintenance release Saxon 9.4.0.4 instead).

Please confirm if this is the case, also does any other stylesheet work?

Alternatively you could try another machine to all of the above.

RE: Saxon .NET throws NoClassDefFoundError - Added by O'Neil Delpratt over 12 years ago

Hi Jakub,

I have managed to reproduce the error after installing Visual Studio 2010 and doing some updates. There is a bug when bytecode generation is enabled on SaxonEE .Net platform I have created a bug issue with the details, please see: http://dev.saxonica.com/community/issues/1593

RE: Saxon .NET throws NoClassDefFoundError - Added by Jakub Maly over 12 years ago

I am glad you were able to reproduce and fix the error after all (and I was not just imagining things).

    (1-11/11)

    Please register to reply