怎么样处理使用XMLBean时JVM异常问题?

怎么样处理使用XMLBean时JVM异常问题?

在程序中有需要操作XML的地方,我个人比较喜欢使用XMLBean。为此,我的Eclipse项目列表里面长期都有一个XMLBean工程,用来随时生成Schema.jar(XMLBean)。不过今天我把我的经过本地测试的XMLBean部署到一个Server上的Weblogic后,当调用该XMLBean时,居然把jvm搞挂了...

Log:

 

An unexpected exception has been detected in native code outside the VM.

Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred at PC=0x0

Function=[Unknown.]

Library=(N/A)

NOTE: We are unable to locate the function name symbol for the error

just occurred. Please refer to release documentation for possible

reason and solutions.

Current Java thread:

at java.lang.Class.getClassLoader0(Native Method)

at java.lang.Class.getClassLoader(Class.java:516)

at com.xx.xx.xx.xx.xx.ConfigitemsDocument.<clinit>(Unknown Source)

//….此处省去若干行

Dynamic libraries:

0x00400000 - 0x0040B000 C:/bea/JDK142~1/bin/java.exe

0x7C930000 - 0x7CA00000 C:/WINDOWS/system32/ntdll.dll

0x7C800000 - 0x7C92B000 C:/WINDOWS/system32/kernel32.dll

//….这里又省去若干行,全是关于dll

Heap at VM Abort:

Heap

def new generation total 36352K, used 2274K [0x10010000, 0x12780000, 0x14ed0000)

eden space 32320K, 7% used [0x10010000, 0x10248b08, 0x11fa0000)

from space 4032K, 0% used [0x12390000, 0x12390000, 0x12780000)

to space 4032K, 0% used [0x11fa0000, 0x11fa0000, 0x12390000)

tenured generation total 483968K, used 88225K [0x14ed0000, 0x32770000, 0x50010000)

the space 483968K, 18% used [0x14ed0000, 0x1a4f8468, 0x1a4f8600, 0x32770000)

compacting perm gen total 45312K, used 45258K [0x50010000, 0x52c50000, 0x60010000)

the space 45312K, 99% used [0x50010000, 0x52c42a60, 0x52c42c00, 0x52c50000)

Local Time = Tue Jan 09 14:10:28 2007

Elapsed Time = 58

#

# The exception above was detected in native code outside the VM

#

# Java VM: Java HotSpot(TM) Client VM (1.4.2_05-b04 mixed mode)

#

经推敲,发现可能是编译XMLBean时的jdk(我用的是jdk1.5)和我部署到的Weblogic版本不一的缘故。马上修改我的XMLBean工程的配置项:

1) 修改引用jdk的版本,改为和目标环境一致的。如图:

怎么样处理使用XMLBean时JVM异常问题?

2) 修改生成XMLBeanant脚本:

 

<?xml version="1.0" encoding="UTF-8" ?>

<project name="xmlbean" default="build_all_schemas" basedir="." >

<taskdef name="xmlbean" classname="org.apache.xmlbeans.impl.tool.XMLBean" />

<target name="build_all_schemas" >

<xmlbean schema="schemas" destfile="dist/SchemasWapCfg.jar" classgendir="build" srcgendir="src" javasource="1.4" />

</target>

</project>

注意:javasource="1.4",和引用jdk版本一致。

重新编译,重新部署后测试。OK!

-end-