使用Saxon API和IKVM的基本Web应用程序抛出异常

时间:2012-09-12 15:44:37

标签: saxon ikvm

我创建了一个基本的.NET 4.0应用程序并引用了Saxon程序集。这是我在项目中引用的dll列表。

saxon9.dll saxon9api.dll IKVM.OpenJDK.ClassLibrary.dll IKVM.Runtime.dll

该应用程序的代码如下:

Sub Main()

    Console.WriteLine("Trying to instantiate SaxonProcessor...")
    Try
        Dim SaxonProcessor As Saxon.Api.Processor = New Saxon.Api.Processor()
    Catch ex As Exception
        Console.WriteLine("Error: " & ex.Message & ex.StackTrace)
        Console.Read()
    End Try

    Console.WriteLine("Saxon instantiated successfully!")
    Console.Read()

End Sub

当我在IIS计算机上运行此应用程序时,我得到以下输出:

尝试实例化SaxonProcessor ...... 撒克逊成功地实例化了!

然后,我创建了一个基本的Web应用程序项目,并引用了与Windows应用程序相同的文件。我将Web应用程序部署到包含所有引用程序集的虚拟目录。我将以下代码放在Default.aspx页面中:

Public Class _Default     继承System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    Response.Write("Trying to instantiate SaxonProcessor...")

    Try
        Dim SaxonProcessor As Saxon.Api.Processor = New Saxon.Api.Processor()
        Response.Write("Saxon instantiated successfully!")
    Catch ex As Exception
        Response.Write("Error: " & ex.Message & ex.StackTrace)
    End Try

End Sub

结束班

当我加载页面时,它给了我这个例外:

尝试实例化SaxonProcessor ...错误:'IKVM.NativeCode.java.lang.Thread'的类型初始值设定项引发了异常。位于java.lang.Class.forName(String className)at的java.lang.Class.forName0(String,Boolean,ClassLoader)的IKVM.NativeCode.java.lang.Class.forName0(String name,Boolean initialize,Object loader) net.sf.saxon.dotnet.DotNetExtensionFunctionFactory.class $(String x0)at net.sf.saxon.dotnet.DotNetExtensionFunctionFactory..ctor(Configuration config)at net.sf.saxon.dotnet.DotNetPlatform.initialize(Configuration config)at at位于C的BealSaxxon._Default.Page_Load(Object sender,EventArgs e)的Saxon.Api.Processor..ctor()的net.sf.saxon.Configuration.init()位于net.sf.saxon.Configuration..ctor() :\ Users \ u0147101 \ Desktop \ BealSaxxon \ BealSaxxon \ Default.aspx.vb:第9行

IIS Machine的完整堆栈:

System.TypeInitializationException: The type initializer for 'IKVM.NativeCode.java.lang.Thread' threw an exception. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'java.io.BufferedInputStream' threw an exception. ---> java.lang.RuntimeException: java.lang.IllegalAccessException: Class java.util.concurrent.atomic.AtomicReferenceFieldUpdater can not access a member of class java.io.BufferedInputStream with modifiers "volatile" ---> java.lang.IllegalAccessException: Class java.util.concurrent.atomic.AtomicReferenceFieldUpdater can not access a member of class java.io.BufferedInputStream with modifiers "volatile"
   at sun.reflect.misc.ReflectUtil.ensureMemberAccess(Class currentClass, Class memberClass, Object target, Int32 modifiers)
   at java.util.concurrent.atomic.AtomicReferenceFieldUpdater.AtomicReferenceFieldUpdaterImpl..ctor(Class , Class , String )
   --- End of inner exception stack trace ---
   at java.util.concurrent.atomic.AtomicReferenceFieldUpdater.AtomicReferenceFieldUpdaterImpl..ctor(Class , Class , String )
   at java.util.concurrent.atomic.AtomicReferenceFieldUpdater.newUpdater(Class tclass, Class vclass, String fieldName)
   at java.io.BufferedInputStream..cctor()
   --- End of inner exception stack trace ---
   at java.io.BufferedInputStream.__<clinit>()
   at java.lang.System.initializeSystemClass()
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
   at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at IKVM.NativeCode.java.lang.Thread..cctor()
   --- End of inner exception stack trace ---
   at IKVM.NativeCode.java.lang.Class.forName0(String name, Boolean initialize, Object loader)
   at java.lang.Class.forName(String className)
   at net.sf.saxon.dotnet.DotNetExtensionFunctionFactory.class$(String x0)
   at net.sf.saxon.dotnet.DotNetExtensionFunctionFactory..ctor(Configuration config)
   at net.sf.saxon.dotnet.DotNetPlatform.initialize(Configuration config)
   at net.sf.saxon.Configuration.init()
   at net.sf.saxon.Configuration..ctor()
   at Saxon.Api.Processor..ctor()
   at EDG.Transforms..ctor()
   at EDG.Main..ctor(NameValueCollection applicationSettings, List`1 exceptionList)
   at EDG.EGallery..ctor(NameValueCollection ConfigurationSettings, List`1 ExceptionList)

之前有没有人见过这个例外?我在Google上进行了广泛搜索,但似乎没有人有这个特殊的例外。我认为这是IIS的权限问题,但我不确定。此应用程序运行的应用程序池是由计算机管理员设置的。

2 个答案:

答案 0 :(得分:0)

我认为这可能是两种类型的原因。

  • 缺少一个IKVM dll。添加所有IKVM dll来测试是否能解决问题。
  • IKVM是针对.NET 2而不是版本4编译的。您需要为app.config添加版本映射。

答案 1 :(得分:0)

在这种情况下,它是一种名为OpNET的产品,它干扰了使用JVM的应用程序。一旦其服务和流程停止,撒克逊人的装配工作正常。