无法运行Java命令

时间:2013-07-23 15:06:48

标签: java

我们正在使用Webmethods 8.2,我们正在尝试从Linux机器上在SQL服务器上设置初始数据库。命令格式为

  

./dbConfigurator.sh -a create -d sqlserver -c storage -v latest -l jdbc:wm:sqlserver://<sqlserverip>:1433;databaseName=DBNAME" -u DBUSER -p Passwd -au ADMIN -ap Passwd

我们收到以下错误。有人可以破译我们的错误。我们感谢您提供的任何帮助。谢谢!

Exception in thread "main" java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    at org.apache.xerces.parsers.AbstractDOMParser.startDocument(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator.startDocument(Unknown Source)
    at org.apache.xerces.impl.dtd.XMLDTDValidator.startDocument(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentScannerImpl.startEntity(Unknown Source)
    at org.apache.xerces.impl.XMLVersionDetector.startDocumentParsing(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
    at com.webmethods.common.cdbc.engine.definition.ComponentStore.initialize(ComponentStore.java:128)
    at com.webmethods.common.cdbc.engine.definition.ComponentStore.instance(ComponentStore.java:98)
    at com.webmethods.common.cdbc.engine.definition.DatabaseDefinitionManager.<init>(DatabaseDefinitionManager.java:42)
    at com.webmethods.common.cdbc.engine.definition.DatabaseDefinitionManager.instance(DatabaseDefinitionManager.java:49)
    at com.webmethods.common.cdbc.install.DatabaseComponentInstaller.isValidComponentName(DatabaseComponentInstaller.java:258)
    at com.webmethods.common.cdbc.install.DatabaseComponentInstaller.validateDCIParams(DatabaseComponentInstaller.java:1021)
    at com.webmethods.common.cdbc.install.DatabaseComponentInstaller.checkMissingArgsAndValidate(DatabaseComponentInstaller.java:148)
    at com.webmethods.common.cdbc.install.DatabaseComponentInstaller.execute(DatabaseComponentInstaller.java:341)
    at com.webmethods.common.cdbc.client.CommandLineClient.main(CommandLineClient.java:19)
Caused by: java.lang.ClassNotFoundException: org.w3c.dom.ElementTraversal
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    ... 31 more[/code]

这是我的dbConfigurator.sh

#!/bin/sh
# set env for CDC

ENV_PATH=/opt/softwareag/DB/common/db/bin/setEnv.sh
export ENV_PATH
source=$ENV_PATH
. ./setEnv.sh

if [ -z "$JAVA_HOME" ]; then
echo "The environment variable JAVA_HOME must be set"
    echo "Can't run the database component installer."
    exit
fi

if [ -z "$CDBS_HOME" ]; then
    echo "The environment variable CDBS_HOME must be set."
    echo "Can't run the database component installer."
    exit
fi

if [ -z "$DCI_HOME" ]; then
    echo "The environment variable DCI_HOME must be set."
    echo "Can't run the database component installer."
    exit
fi

#runJava

RUN="$JAVA_HOME/bin/java"

$RUN $JAVA_OPTS com.webmethods.common.cdbc.client.CommandLineClient "$@"

此文件调用的setEnv.sh,

    #!/bin/sh
# set env for CDC

JAVA_HOME=/opt/softwareag/DB/jvm/jvm160
DCI_HOME=/opt/softwareag/DB/common/db
CDBS_HOME=/opt/softwareag/DB/common/db

#exportStartHeap


DCI_START_HEAP="${DCI_START_HEAP:-10}";export DCI_START_HEAP

DCI_MAX_HEAP="${DCI_MAX_HEAP:-512}";export DCI_MAX_HEAP

#exportJavaOpts

JAVA_OPTS="$JAVA_OPTS -DCDBS.home.path=$CDBS_HOME"
JAVA_OPTS="$JAVA_OPTS -DDCI.home.path=$DCI_HOME"
JAVA_OPTS="$JAVA_OPTS -Dlog.dir=$DCI_HOME/logs"
JAVA_OPTS="$JAVA_OPTS  -DtermOutOn=true"
JAVA_OPTS="$JAVA_OPTS  -DspoolOn=true"

##==================To enable debug, change this property to 'DEBUG'==========
JAVA_OPTS="$JAVA_OPTS  -DlogLevel=INFO"
##============================================================================

JAVA_OPTS="$JAVA_OPTS  -Xms${DCI_START_HEAP}m"
JAVA_OPTS="$JAVA_OPTS  -Xmx${DCI_MAX_HEAP}m"
JAVA_OPTS="$JAVA_OPTS  -Xss256k"

export JAVA_OPTS

##exportClassPath
CLASSPATH="$CLASSPATH:$DCI_HOME"
CLASSPATH="$CLASSPATH:$DCI_HOME/lib/wm-cdc-client.jar"
for file in $DCI_HOME%/lib/wm-cdc-client_*
do
  CLASSPATH=${CLASSPATH}:$file
done
CLASSPATH="$CLASSPATH:$DCI_HOME/lib/CDC_PELP_ja_Messages-ALL-Any.jar"
CLASSPATH="$CLASSPATH:$DCI_HOME/lib/CDC_PELP_ar_Messages-ALL-Any.jar"
CLASSPATH="$CLASSPATH:$DCI_HOME/../lib/wm-cdc-core.jar"
CLASSPATH="$CLASSPATH:$DCI_HOME/../lib/ext/jargs.jar"
CLASSPATH="$CLASSPATH:$DCI_HOME/../lib/wm-g11nutils.jar"
CLASSPATH="$CLASSPATH:$DCI_HOME/../lib/ext/log4j.jar"
CLASSPATH="$CLASSPATH:$DCI_HOME/../lib/ext/derby.jar"
CLASSPATH="$CLASSPATH:$DCI_HOME/../lib/wm-caf-common.jar"
for file in $DCI_HOME/../lib/ext/sl53*
do
  CLASSPATH=${CLASSPATH}:$file
done
CLASSPATH="$CLASSPATH:$DCI_HOME/../lib/ext/xercesImpl.jar"
CLASSPATH="$CLASSPATH:$JAVA_HOME/lib/tools.jar"
CLASSPATH="$CLASSPATH:$JAVA_HOME/jre/lib/charsets.jar"
export CLASSPATH

4 个答案:

答案 0 :(得分:2)

当Java虚拟机无法在运行时找到编译时可用的特定类时,Java中出现

NoClassDefFoundError

在你的特殊情况下,JAVA找不到xml-apis.jar,像这样添加到setEnv.sh(找到路径并编辑)

CLASSPATH="$CLASSPATH:$DCI_HOME/../lib/xml-apis.jar"

答案 1 :(得分:0)

java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal

大概你的类路径错过了一些库org/w3c/dom/ElementTraversal

答案 2 :(得分:0)

根据一篇文章,他们有这个问题:

  

当我尝试使用版本2.0.2时遇到了问题,但发现我的时候   恢复到版本1.4.01,一切都恢复了。

     

如果你正在使用Maven:

<dependency> 
    <groupId>xml-apis</groupId>
    <artifactId>xml-apis</artifactId>
    <version>1.4.01</version> 
</dependency>

如果你没有,你也可以下载必要的库:

http://www.jarfinder.com/index.php/java/info/org.w3c.dom.ElementTraversal

参考1:Eclipse java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal

参考2:http://www.coderanch.com/t/534171/XML/org-dom-ElementTraversal

答案 3 :(得分:0)

首先,您需要确定您是在处理缺少的课程,还是某个课程缺失的课程:

http://javarevisited.blogspot.com/2011/06/noclassdeffounderror-exception-in.html

你有一个java.lang.ClassNotFoundException: org.w3c.dom.ElementTraversal,所以你正在处理一个缺失的类(一个更简单的场景)。您需要查看JAR通常包含的内容org.w3c.dom.ElementTraversal。我喜欢使用http://search.maven.org/,即使你没有使用Maven,也只是因为它是常用Java库的综合索引。要搜索课程,请使用fc:org.w3c.dom.ElementTraversal

http://search.maven.org/#search%7Cga%7C1%7Cfc%3Aorg.w3c.dom.ElementTraversal

你会发现xml-apis的1.401版本。看起来搜索结果中的任何常见JAR都不在您的CLASSPATH中,除非它们位于$DCI_HOME/../lib/ext/sl53内部。您可以通过在#runJava echo $CLASSPATH之后添加一行来查看此问题,并查找上述搜索结果中列出的任何JAR。

如果它们不存在,您需要将JAR放在框中的某个位置并编辑setEnv.sh以包含它(除非您可以将它放在$DCI_HOME/../lib/ext/sl53中自动拾取它。)