2014-10-13 5 views
1

Когда я пытаюсь запустить образец кода библиотеки Omnifaces об Ajax :: update(), я получаю исключение NoClassDefFoundError;Исключение NoClassDefFoundError, когда я использую Omnifaces :: Ajax :: update() метод

Я полагаю, что это касается идентификаторов клиентов или идентификаторов компонентов, но я не знаю, как избежать этого исключения.

welcome.xhtml страница следующая

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:ui="http://java.sun.com/jsf/facelets" 
    xmlns:h="http://java.sun.com/jsf/html" 
    xmlns:f="http://java.sun.com/jsf/core"> 

    <body> 

     <h3>Update a component programmatically</h3> 
     <h:form id="form"> 
      <h:commandButton value="submit" action="#{ajaxBean.update}"> 
       <f:ajax /> 
      </h:commandButton> 
      <p> 
       It's now 
       <h:outputText id="timestamp" value="#{now.toString}" /> 
      </p> 
     </h:form> 

     <hr /> 

     <hr /> 

     <h3>Execute a callback script programmatically</h3> 
     <h:form> 
      <h:commandButton value="submit" action="#{ajaxBean.callback}"> 
       <f:ajax /> 
      </h:commandButton> 
     </h:form> 

     <hr /> 

     <h3>Add arguments to the JavaScript scope</h3> 
     <h:form> 
      <h:commandButton value="submit" onclick="$('#showData').empty()" 
       action="#{ajaxBean.argument}"> 
       <f:ajax /> 
      </h:commandButton> 
     </h:form> 
     <ul id="showData"></ul> 
     <h:outputScript> 
      function showData() { 
       var data = OmniFaces.Ajax.data; 
       var $showData = $("#showData"); 

       $.each(data, function(key, value) { 
        $("&lt;li&gt;").text(key + "=" + JSON.stringify(value)).appendTo($showData); 
       }); 
      } 
     </h:outputScript> 

</body> 
</html> 

И AjaxBean.java боб следующие

package com.tutorial; 

import java.util.Arrays; 
import java.util.Date; 
import java.util.HashMap; 
import java.util.Map; 

import javax.faces.component.UIData; 

import org.omnifaces.util.Ajax; 

public class AjaxBean { 

    public void update() { 
     Ajax.update("form:timestamp"); 
    } 

    public void callback() { 
     Ajax.oncomplete("alert('Hi, I am the oncomplete callback script!')"); 
    } 

    public void argument() { 
     Ajax.data("foo", "bar"); 
     Ajax.data("first", "one", "second", "two"); 
     Map<String, Object> data = new HashMap<>(); 
     data.put("bool", true); 
     data.put("number", 1.2F); 
     data.put("date", new Date()); 
     data.put("array", new Integer[] { 1, 2, 3, 4, 5 }); 
     data.put("list", Arrays.asList("one", "two", "three")); 
     Ajax.data(data); 
     Ajax.oncomplete("showData()"); 
    } 

} 

StackTrace является:

11:02:44,289 SEVERE [javax.enterprise.resource.webcontainer.jsf.application] java.lang.NoClassDefFoundError: org/omnifaces/util/Ajax: javax.faces.el.EvaluationException: java.lang.NoClassDefFoundError: org/omnifaces/util/Ajax 
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:98) [:2.0.3-] 
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:98) [:2.0.3-] 
    at javax.faces.component.UICommand.broadcast(UICommand.java:311) [:2.0.3-] 
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:781) [:2.0.3-] 
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1246) [:2.0.3-] 
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:77) [:2.0.3-] 
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97) [:2.0.3-] 
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114) [:2.0.3-] 
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:308) [:2.0.3-] 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:324) [:6.1.0.Final] 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.1.0.Final] 
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [:6.1.0.Final] 
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [:6.1.0.Final] 
    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181) [:6.1.0.Final] 
    at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285) [:1.1.0.Final] 
    at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261) [:1.1.0.Final] 
    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88) [:6.1.0.Final] 
    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100) [:6.1.0.Final] 
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:159) [:6.1.0.Final] 
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [:6.1.0.Final] 
    at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) [:6.1.0.Final] 
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [:6.1.0.Final] 
    at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53) [:6.1.0.Final] 
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [:6.1.0.Final] 
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [:6.1.0.Final] 
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:654) [:6.1.0.Final] 
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [:6.1.0.Final] 
    at java.lang.Thread.run(Thread.java:744) [:1.7.0_45] 
Caused by: java.lang.NoClassDefFoundError: org/omnifaces/util/Ajax 
    at com.tutorial.AjaxBean.update(AjaxBean.java:16) [:] 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.7.0_45] 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [:1.7.0_45] 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [:1.7.0_45] 
    at java.lang.reflect.Method.invoke(Method.java:606) [:1.7.0_45] 
    at org.apache.el.parser.AstValue.invoke(AstValue.java:196) [:6.1.0.Final] 
    at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276) [:6.1.0.Final] 
    at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:102) [:2.0.3-] 
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:84) [:2.0.3-] 
    ... 27 more 

11:02:44,307 WARNING [javax.enterprise.resource.webcontainer.jsf.lifecycle] #{ajaxBean.update}: java.lang.NoClassDefFoundError: org/omnifaces/util/Ajax: javax.faces.FacesException: #{ajaxBean.update}: java.lang.NoClassDefFoundError: org/omnifaces/util/Ajax 
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:114) [:2.0.3-] 
    at javax.faces.component.UICommand.broadcast(UICommand.java:311) [:2.0.3-] 
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:781) [:2.0.3-] 
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1246) [:2.0.3-] 
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:77) [:2.0.3-] 
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97) [:2.0.3-] 
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114) [:2.0.3-] 
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:308) [:2.0.3-] 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:324) [:6.1.0.Final] 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.1.0.Final] 
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [:6.1.0.Final] 
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [:6.1.0.Final] 
    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181) [:6.1.0.Final] 
    at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285) [:1.1.0.Final] 
    at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261) [:1.1.0.Final] 
    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88) [:6.1.0.Final] 
    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100) [:6.1.0.Final] 
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:159) [:6.1.0.Final] 
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [:6.1.0.Final] 
    at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) [:6.1.0.Final] 
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [:6.1.0.Final] 
    at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53) [:6.1.0.Final] 
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [:6.1.0.Final] 
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [:6.1.0.Final] 
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:654) [:6.1.0.Final] 
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [:6.1.0.Final] 
    at java.lang.Thread.run(Thread.java:744) [:1.7.0_45] 
Caused by: javax.faces.el.EvaluationException: java.lang.NoClassDefFoundError: org/omnifaces/util/Ajax 
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:98) [:2.0.3-] 
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:98) [:2.0.3-] 
    ... 26 more 
Caused by: java.lang.NoClassDefFoundError: org/omnifaces/util/Ajax 
    at com.tutorial.AjaxBean.update(AjaxBean.java:16) [:] 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.7.0_45] 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [:1.7.0_45] 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [:1.7.0_45] 
    at java.lang.reflect.Method.invoke(Method.java:606) [:1.7.0_45] 
    at org.apache.el.parser.AstValue.invoke(AstValue.java:196) [:6.1.0.Final] 
    at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276) [:6.1.0.Final] 
    at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:102) [:2.0.3-] 
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:84) [:2.0.3-] 
    ... 27 more 

11:02:44,307 ERROR [STDERR] javax.faces.FacesException: #{ajaxBean.update}: java.lang.NoClassDefFoundError: org/omnifaces/util/Ajax 

11:02:44,307 ERROR [STDERR]  at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:85) 

11:02:44,307 ERROR [STDERR]  at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97) 

11:02:44,307 ERROR [STDERR]  at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114) 

11:02:44,307 ERROR [STDERR]  at javax.faces.webapp.FacesServlet.service(FacesServlet.java:308) 

11:02:44,307 ERROR [STDERR]  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:324) 

11:02:44,307 ERROR [STDERR]  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) 

11:02:44,307 ERROR [STDERR]  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) 

11:02:44,307 ERROR [STDERR]  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) 

11:02:44,307 ERROR [STDERR]  at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181) 

11:02:44,307 ERROR [STDERR]  at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285) 

11:02:44,307 ERROR [STDERR]  at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261) 

11:02:44,307 ERROR [STDERR]  at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88) 

11:02:44,307 ERROR [STDERR]  at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100) 

11:02:44,307 ERROR [STDERR]  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:159) 

11:02:44,322 ERROR [STDERR]  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) 

11:02:44,322 ERROR [STDERR]  at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) 

11:02:44,322 ERROR [STDERR]  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) 

11:02:44,322 ERROR [STDERR]  at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53) 

11:02:44,322 ERROR [STDERR]  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) 

11:02:44,322 ERROR [STDERR]  at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) 

11:02:44,322 ERROR [STDERR]  at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:654) 

11:02:44,322 ERROR [STDERR]  at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) 

11:02:44,322 ERROR [STDERR]  at java.lang.Thread.run(Thread.java:744) 

11:02:44,322 ERROR [STDERR] Caused by: javax.faces.FacesException: #{ajaxBean.update}: java.lang.NoClassDefFoundError: org/omnifaces/util/Ajax 

11:02:44,322 ERROR [STDERR]  at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:114) 

11:02:44,322 ERROR [STDERR]  at javax.faces.component.UICommand.broadcast(UICommand.java:311) 

11:02:44,322 ERROR [STDERR]  at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:781) 

11:02:44,322 ERROR [STDERR]  at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1246) 

11:02:44,322 ERROR [STDERR]  at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:77) 

11:02:44,322 ERROR [STDERR]  ... 22 more 

11:02:44,322 ERROR [STDERR] Caused by: javax.faces.el.EvaluationException: java.lang.NoClassDefFoundError: org/omnifaces/util/Ajax 

11:02:44,322 ERROR [STDERR]  at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:98) 

11:02:44,322 ERROR [STDERR]  at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:98) 

11:02:44,322 ERROR [STDERR]  ... 26 more 

11:02:44,322 ERROR [STDERR] Caused by: java.lang.NoClassDefFoundError: org/omnifaces/util/Ajax 

11:02:44,322 ERROR [STDERR]  at com.tutorial.AjaxBean.update(AjaxBean.java:16) 

11:02:44,322 ERROR [STDERR]  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 

11:02:44,322 ERROR [STDERR]  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 

11:02:44,322 ERROR [STDERR]  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 

11:02:44,338 ERROR [STDERR]  at java.lang.reflect.Method.invoke(Method.java:606) 

11:02:44,338 ERROR [STDERR]  at org.apache.el.parser.AstValue.invoke(AstValue.java:196) 

11:02:44,338 ERROR [STDERR]  at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276) 

11:02:44,338 ERROR [STDERR]  at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:102) 

11:02:44,338 ERROR [STDERR]  at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:84) 

11:02:44,338 ERROR [STDERR]  ... 27 more 

Любая помощь woul d оценить.

Спасибо.

+0

Пожалуйста, добавьте полный стек. – Jens

ответ

1

, не принимая глубокий взгляд на код, который вы опубликовали, исключения NoClassDefFound обычно вызваны связыванием проблем и не связаны с написанием написанного кода. убедитесь, что вы включили в свой классpath все необходимое.

+0

Хорошо, вы были правы! Я решил добавить в «сборку развертывания» (в Eclipse IDE --- я использую сервер приложений JBoss) библиотеку Omnifaces для ее развертывания в .war. Благодаря! – MarcoSuma

0

Если вы можете, поместите свой проект в новую установку контейнера сервлетов.