0

我创建了一个基本的 .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... Saxon 实例化成功!

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

公共类 _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”的类型初始化程序引发异常。在 IKVM.NativeCode.java.lang.Class.forName0(String name, Boolean initialize, Object loader) at java.lang.Class.forName0(String , Boolean , ClassLoader) 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 BealSaxxon._Default.Page_Load(Object sender, EventArgs e) in C :\Users\u0147101\Desktop\BealSaxxon\BealSaxxon\Default.aspx.vb:第 9 行

来自 IIS 机器的完整堆栈跟踪:

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)

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

4

2 回答 2

0

在这种情况下,是一个名为 OpNET 的产品干扰了使用 JVM 的应用程序。一旦停止其服务和进程,撒克逊程序集就可以正常工作。

于 2012-09-19T13:43:09.793 回答
0

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

  • 缺少 IKVM dll 之一。添加 IKVM 的所有 dll 以测试是否可以解决问题。
  • IKVM 是为 .NET 2 而不是版本 4 编译的。您需要将版本映射添加到您的 app.config。
于 2012-09-12T20:44:22.683 回答