2

我正在尝试通过以下命令使用 RealmBase 将 server.xml 的密码加密到 Tomcat7 中:

java -cp bin\tomcat-juli.jar;lib\catalina.jar;lib\tomcat-util.jar; org.apache.catalina.realm.RealmBase -a SHA passwd

我在执行命令时遇到以下错误:

C:\Program Files\Apache Software Foundation\Tomcat 7.0>java -cp bin\tomcat-juli.jar;lib\catalina.jar;lib\tomcat-util.jar; org.apache.catalina.realm.RealmBase -a  MD5 passwd
Exception in thread "main" java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$100(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
        at java.lang.Class.getMethod0(Unknown Source)
        at java.lang.Class.getMethod(Unknown Source)
        at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
        at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: javax.servlet.http.HttpServletRequest
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 18 more

C:\Program Files\Apache Software Foundation\Tomcat 7.0>
4

1 回答 1

2

尝试包括servlet-api.jar

java -cp bin\tomcat-juli.jar;lib\catalina.jar;lib\tomcat-util.jar;lib\servlet-api.jar org.apache.catalina.realm.RealmBase -a SHA passwd

编辑

在尝试自己运行它之后,又缺少另一个类。与其手动将每个 JAR 包含在类路径中,我决定将它们全部包含在lib\*. 试试这个……它对我有用!

java -cp bin\tomcat-juli.jar;lib\* org.apache.catalina.realm.RealmBase -a SHA passwd
于 2013-01-28T19:33:17.797 回答