6
import org.jasypt.util.password.*;
public class encrypt 
{
private static BasicPasswordEncryptor passenc; 
public encrypt()
{
    passenc=new BasicPasswordEncryptor();
}
public static void useradd()
{
      System.out.println("IN Useradd");
}

当我从 jsf 文件调用 useradd() 时,出现以下错误

java.lang.NoClassDefFoundError: Lorg/jasypt/util/password/BasicPasswordEncryptor;
    at java.lang.Class.getDeclaredFields0(Native Method)
    at java.lang.Class.privateGetDeclaredFields(Unknown Source)
    at java.lang.Class.getDeclaredFields(Unknown Source)
    at com.sun.faces.mgbean.BeanBuilder.scanForAnnotations(BeanBuilder.java:476)
    at com.sun.faces.mgbean.BeanBuilder.loadBeanClass(BeanBuilder.java:449)
    at com.sun.faces.mgbean.BeanBuilder.bake(BeanBuilder.java:379)
    at com.sun.faces.mgbean.ManagedBeanBuilder.bake(ManagedBeanBuilder.java:86)
    at com.sun.faces.mgbean.BeanManager.preProcessBean(BeanManager.java:349)
    at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:258)
    at com.sun.faces.el.ManagedBeanELResolver.resolveBean(ManagedBeanELResolver.java:191)
    at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:73)
    at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
    at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:71)
    at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:69)
    at org.apache.el.parser.AstValue.getTarget(AstValue.java:68)
    at org.apache.el.parser.AstValue.invoke(AstValue.java:187)
    at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
    at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:102)
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:84)
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:98)
    at javax.faces.component.UICommand.broadcast(UICommand.java:311)
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:781)
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1246)
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:77)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:308)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.jasypt.util.password.BasicPasswordEncryptor
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
    ... 39 more

请告诉我为什么会这样。

4

1 回答 1

6

这看起来像是一个部署问题——你可能只需要你的 webapp 的 lib 目录中的 jasypt jar 文件。

于 2011-07-05T12:31:56.590 回答