Spring - Primefaces - AjaxBehavior not found exception

UI Components for JSF
Post Reply
priyaesh
Posts: 26
Joined: 07 Feb 2011, 03:37

02 Jul 2011, 19:33

Hello Team

We have migrated from Richfaces 3.3 to Primefaces 4 months back. We are extremely amazed by the rich features that you offer. First of all thanks for your good work. Keep going.

There is one issue that we kept postponing to bring it to you guys attention. We are using Spring 3.0.2 with Primefaces 3.0.M1. All features works but for p:ajax tag. When I add this tag, got AjaxBehavior not found exception. I have posted my simple example which dont work. But when I replace p:ajax tag with f:ajax, I dont get any exception but the ajax behavior dont work as expected. Please note that in our project managed bean is configured with Spring's @Component annotation. I dont know if this is the reason for Exception.

Would greatly appreciate if you could help us to solve this problem

testMasterView.xhtml

<ui:composition 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"
xmlns:p="http://primefaces.prime.com.tr/ui"
template="template.xhtml">
<ui:define name="content">

<div class="entry">
<h1 class="title ui-widget-header ui-corner-all">Employee Master </h1>

<h:form id="employeeData" >

<p:growl id="growl" autoUpdate="true"/>

<p:panel>
<h:panelGrid columns="2">

<h:outputLabel value="Employee Name" />
<p:inputText id="empName" label="Employee Name" value="#{employeeController.empName}"
required="true" >
<p:ajax event="keyup" update="empNameId"/>
</p:inputText>

<h:outputLabel value="Employee Designation" />
<p:inputText value="#{employeeController.empDes}" required="true" label="Employee Design"/>

<h:outputText id="empNameId" value="#{employeeController.empName}"/>
<p:commandButton value="Submit" action="#{employeeController.testMessage}"/>

</h:panelGrid>

</p:panel>

</h:form>
</div>

</ui:define>
</ui:composition>

TestMasterController.java

package com.test.controller;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

@Component("employeeController")
@Scope("view")
public class TestMasterController {

private String empName;
private String empDes;

public String getEmpName() {
return empName;
}
public void setEmpName(String empName) {
this.empName = empName;
}

public String getEmpDes() {
return empDes;
}
public void setEmpDes(String empDes) {
this.empDes = empDes;
}

public String onClickEdit(){
System.out.println("Inside Controller");
return "employeeFormEdit";
}

public void testMessage(){
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Test Employee", null));
}

}


web.xml:


<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" >

<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>aristo</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/META-INF/applicationContext.xml</param-value>
</context-param>

<context-param>
<param-name>facelets.SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>

<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener
</listener-class>
</listener>

<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>

</web-app>



faces-config.xml


<?xml version="1.0" encoding="UTF-8"?>
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-f ... ig_2_0.xsd"
version="2.0" metadata-complete="true">


<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application>

</faces-config>





Stacktrace:


javax.faces.FacesException: Expression Error: Named Object: org.primefaces.component.AjaxBehavior not found.
com.sun.faces.application.ApplicationImpl.createBehavior(ApplicationImpl.java:860)
com.sun.faces.facelets.tag.jsf.BehaviorTagHandlerDelegateImpl.applyAttachedObject(BehaviorTagHandlerDelegateImpl.java:146)
javax.faces.view.facelets.FaceletsAttachedObjectHandler.applyAttachedObject(FaceletsAttachedObjectHandler.java:98)
com.sun.faces.facelets.tag.jsf.BehaviorTagHandlerDelegateImpl.apply(BehaviorTagHandlerDelegateImpl.java:127)
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
com.sun.faces.facelets.tag.ui.DefineHandler.applyDefinition(DefineHandler.java:103)
com.sun.faces.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:178)
com.sun.faces.facelets.impl.DefaultFaceletContext$TemplateManager.apply(DefaultFaceletContext.java:395)
com.sun.faces.facelets.impl.DefaultFaceletContext.includeDefinition(DefaultFaceletContext.java:366)
com.sun.faces.facelets.tag.ui.InsertHandler.apply(InsertHandler.java:108)
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
com.sun.faces.facelets.tag.jsf.core.ViewHandler.apply(ViewHandler.java:167)
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:82)
com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:308)
com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:367)
com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:346)
com.sun.faces.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:199)
com.sun.faces.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:155)
com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)
com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:82)
com.sun.faces.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:152)
com.sun.faces.application.view.FaceletViewHandlingStrategy.buildView(FaceletViewHandlingStrategy.java:744)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:100)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:313)




Regards
Priyaesh
Spring 3.0.2,
Primefaces 3.0.M1,
Mojarra 2.0.4, (jsf-api-2.0.4, jsf-impl-2.0.4.,)
Tomcat 6, JPA 1.0
priyaesh

Primefaces 4, JSF 2.1, Spring 3.2, SpringSecurity 3, JPA 2.0, Tomcat 7

cagatay.civici
Prime
Posts: 18543
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

02 Jul 2011, 21:48

Not sure why this happens but in 3.0.M1 ajax behavior is configured via annotation so it seems your environment can't find it, in 3.0.M2 we configure p:ajax in xml so it should guarantee that it's found.

priyaesh
Posts: 26
Joined: 07 Feb 2011, 03:37

03 Jul 2011, 05:12

Wow.. My issue got solved when I replaced primefaces 3.0.M1 jar with latest snapshot - primefaces-3.0.M2-SNAPSHOT.jar

Thanks a lot Optimus. :D

Just to share another exercise I did. I setup the primemovie project which is kind of RI for Spring - Primefaces integration, and replaced primefaces, jsf core jar to 3.0.M1 and jsf-api-2.0.4, jsf-impl-2.0.4. Surprise is that AjaxBehavior worked. No exception with p:ajax tag.

I dont know whats difference in my project but the conclusion is mine works with 3.0.M2 snapshot. ;)

Thanks again.
priyaesh

Primefaces 4, JSF 2.1, Spring 3.2, SpringSecurity 3, JPA 2.0, Tomcat 7

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Baidu [Spider] and 5 guests