【问题标题】:Basic web application using Saxon API and IKVM throws exception使用 Saxon API 和 IKVM 的基本 Web 应用程序抛出异常
【发布时间】:2012-09-12 15:44:36
【问题描述】:

我创建了一个基本的 .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 页面中:

公共类_默认 继承 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 的权限问题,但我不确定。运行此应用程序的应用程序池是由机器管理员设置的。

【问题讨论】:

  • 您使用哪个 IKVM 版本?
  • 你有更多关于异常的细节,比如内部类的堆栈跟踪吗?
  • 更新了我们从 IIS 机器获得的异常的完整堆栈跟踪
  • KVM运行时版本为0.36.0.11。请记住,我们在其他 IIS 机器上使用的相同版本运行良好。这个问题似乎与配置有关。

标签: saxon ikvm


【解决方案1】:

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

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

【讨论】:

  • 我们只需要 IKVM.Runtime.dll 和 IKVM.OpenJDK.ClassLibrary.dll。两者都存在。相同的 dll 在其他 IIS 机器上有效,并且无一例外地运行。
【解决方案2】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-09-19
    • 2011-09-23
    • 2014-12-18
    • 2013-01-02
    • 2017-05-03
    • 1970-01-01
    • 2015-04-15
    相关资源
    最近更新 更多