users@javaserverfaces.java.net

Error when trying to implement JSF with OSGI and Primefaces. Need help!

From: Peter Penzov <peter.penzov_at_gmail.com>
Date: Sat, 9 Jun 2012 00:42:37 +0300

I managed to run WAB package with JSF and Primefaces. The problem is that
some of the example are working and some of the examples have problems when
I try to implement them. I tested this example:

<?xml version='1.0' encoding='UTF-8' ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:ui="http://java.sun.com/jsf/facelets"
          xmlns:p="http://primefaces.org/ui" >
        <h:head>
            <ui:insert name="header">
                <ui:include src="header.xhtml"/>
            </ui:insert>
        </h:head>
        <h:body>

            <h1><img src="resources/css/images/icon.png"
alt="NVIDIA.com" /> History Center</h1>
            <!-- layer for black background of the buttons -->
            <div id="toolbar" style="margin: 0 auto; width:1180px;
height:30px; position:relative; background-color:black">
                <!-- Include page Navigation -->
                <ui:insert name="Navigation">
                    <ui:include src="Navigation.xhtml"/>
                </ui:insert>

            </div>

            <div id="logodiv" style="position:relative; top:35px; left:0px;">
                <h:graphicImage alt="Demo edit form"
style="position:relative; top:-20px; left:9px;"
value="resources/images/logo_linuxz.png" />
            </div>
            <div id="main" style="margin: 0 auto; width:1190px;
height:700px; position:absolute; background-color:transparent;
top:105px">

                <div id="mainpage" style="margin: 0 auto;
width:1190px; height:500px; position:absolute;
background-color:transparent; top:80px">

                    <div id="settingsHashMap" style="width:350px;
height:400px; position:absolute; background-color:r; top:20px;
left:1px">

                        <h:form>

                            <p:growl id="growl" showDetail="true"
sticky="true" />

                            <p:panel header="Growl">
                                <h:panelGrid columns="2">
                                    <h:outputText value="Your Name: *" />
                                    <p:inputText
value="#{LinuxController.text}" required="true" label="Name"/>
                                </h:panelGrid>

                                <p:commandButton value="Save"
actionListener="#{LinuxController.save}" update="growl"/>
                            </p:panel>

                        </h:form>


                    </div>

                </div>
            </div>

        </h:body>
    </html>

import javax.faces.bean.ViewScoped;

import java.io.Serializable;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

// Update form example
@Named("LinuxController")
@ViewScoped
public class Linux implements Serializable {

    public Linux() {
    }

    private String text;

    public String gettext() {
        return text;
    }
    public void settext(String text) {
        this.text = text;
    }

    public void save(ActionEvent actionEvent) {
        FacesContext context = FacesContext.getCurrentInstance();

        context.addMessage(null, new FacesMessage("Successful", "Hello
" + text));
        context.addMessage(null, new FacesMessage("Second Message",
"Additional Info Here..."));
    }

}

I only get error message. I get this error stack in Glassfish:

[#|2012-06-07T15:45:52.438+0300|SEVERE|glassfish3.1.2|javax.faces.event|_ThreadID=339;_ThreadName=Thread-2;|Received
'javax.el.MethodNotFoundException' when invoking action listener
'#{LinuxController.save}' for component 'j_idt17'|#]

[#|2012-06-07T15:45:52.439+0300|SEVERE|glassfish3.1.2|javax.faces.event|_ThreadID=339;_ThreadName=Thread-2;|javax.el.MethodNotFoundException:
Method not found: com.DX_57.HM_57.Linux_at_2be5284e.save()
    at com.sun.el.util.ReflectionUtil.getMethod(ReflectionUtil.java:160)
    at com.sun.el.parser.AstValue.invoke(AstValue.java:251)
    at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:302)
    at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:153)
    at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
    at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:769)
    at javax.faces.component.UICommand.broadcast(UICommand.java:300)
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1542)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:722)
|#]

[#|2012-06-07T15:45:52.439+0300|SEVERE|glassfish3.1.2|javax.enterprise.resource.webcontainer.jsf.context|_ThreadID=339;_ThreadName=Thread-2;|JSF1073:
javax.faces.event.AbortProcessingException caught during processing of
INVOKE_APPLICATION 5 : UIComponent-ClientId=j_idt12:j_idt17,
Message=Method not found: com.DX_57.HM_57.Linux_at_2be5284e.save()|#]

[#|2012-06-07T15:45:52.440+0300|SEVERE|glassfish3.1.2|javax.enterprise.resource.webcontainer.jsf.context|_ThreadID=339;_ThreadName=Thread-2;|Method
not found: com.DX_57.HM_57.Linux_at_2be5284e.save()
javax.faces.event.AbortProcessingException: Method not found:
com.DX_57.HM_57.Linux_at_2be5284e.save()
    at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:182)
    at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
    at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:769)
    at javax.faces.component.UICommand.broadcast(UICommand.java:300)
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1542)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:722)
Caused by: javax.el.MethodNotFoundException: Method not found:
com.DX_57.HM_57.Linux_at_2be5284e.save()
    at com.sun.el.util.ReflectionUtil.getMethod(ReflectionUtil.java:160)
    at com.sun.el.parser.AstValue.invoke(AstValue.java:251)
    at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:302)
    at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:153)
    ... 33 more
|#]

What may cause this problem?

I changed the name of the managed bean. It turns out that the framework is
searching for the wrong name of the managed bean
javax.el.MethodNotFoundException:
Method not found: com.DX_57.HM_57.Linux_at_c280dca.save(). It should be
javax.el.MethodNotFoundException:
Method not found: com.DX_57.HM_57.Linux_at_LinuxController.save() Is this a
configuration problem?

Best Wishes
Peter