aspose file tools*
The moose likes JSF and the fly likes JBOSS not finding JSF backing bean function Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "JBOSS not finding JSF backing bean function" Watch "JBOSS not finding JSF backing bean function" New topic
Author

JBOSS not finding JSF backing bean function

Oscar Law
Greenhorn

Joined: Dec 16, 2008
Posts: 4
I have an input screen generated using JSF 1.2. my command button has an action of "{OrgBean.addRecord}" which when the button is selected on my web browser jboss errors with the following:

javax.servlet.ServletException: /orgmaint.jsp(63,15) '#{OrgBean.addRecord}' Method not found: mysite.generalledger.OrgBean@11cf7d7.addRecord()

If I change the action to be a string result, and have faces send it to another jsp, that jsp can display the contents of the bean so I know the bean is being instantiated and loaded. Why does jboss append the @11cf7d7 to the call. Is that the problem or do I have a different problem. The function addRecord is present in the OrgBean class.

Any help would be appreciated. I'm still a beginner.
Duc Vo
Ranch Hand

Joined: Nov 20, 2008
Posts: 254
Do you have this method in the backing bean?

public String addRecord()

It must be public, and must return a string, and must not have any argument.
[ December 16, 2008: Message edited by: Duc Vo ]

“Everything should be as simple as it is, but not simpler.” Albert Einstein
Oscar Law
Greenhorn

Joined: Dec 16, 2008
Posts: 4
Yes I do. Here is the entire function:

public String addRecord() {
System.out.println("In saveRecord, not doing anything");
return "saved";
}
Duc Vo
Ranch Hand

Joined: Nov 20, 2008
Posts: 254
Is this a newly added method? Have you tried to clear and redeploy the application?
Raymond Van Eperen
Greenhorn

Joined: Oct 07, 2008
Posts: 17

Would you please include the declaration for the managed bean from faces config. Also, would you include the code for the entire command button? Lastly, is the class marked as final?
Oscar Law
Greenhorn

Joined: Dec 16, 2008
Posts: 4
I have redployed it a number of times. It is new development meaning it has never worked. I'm still learning. The class is not defined as final. It is just a regular pojo.

jsp code:

<td>  <h:commandButton value=" Save " action="#{OrgBean.addRecord}"/>
</td>

faces-config.xml

<managed-bean>
<managed-bean-name>OrgBean</managed-bean-name>
<managed-bean-class>mysite.generalledger.OrgBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
Raymond Van Eperen
Greenhorn

Joined: Oct 07, 2008
Posts: 17

Sorry, I don't see anything wrong here. I'm pretty sure this has nothing to do with it, but in my experience, the convention for naming managed beans is to use property notation i.e. orgBean instead of OrgBean. I really don't think that is it, but I've seen stranger things. You might try it just in case, but don't get your hopes up. Otherwise, I don't have a clue.
Duc Vo
Ranch Hand

Joined: Nov 20, 2008
Posts: 254
Search for the keyword 'OrgBean' to check if you have duplication of bean definition somewhere.
Also, print the bean on the JSP page to see if it is the correct bean class.
Oscar Law
Greenhorn

Joined: Dec 16, 2008
Posts: 4
I finally found the problem.

I have a jar and a war for my project. The jar holds my ejbs. It happens to have the same mysite.generalledger directory structure that my war held. The OrgBean only existed in my war file not my jar file. When I moved the OrgBean to a different directory structure, in this case it was mysite.web then the methods are called without a problem.

Why this fixes the problem I don't know.
Duc Vo
Ranch Hand

Joined: Nov 20, 2008
Posts: 254
Glad to hear it work.

Originally posted by Oscar Law:

The jar holds my ejbs. It happens to have the same mysite.generalledger directory structure that my war held.


You meant, they have the same package name, right?


Why this fixes the problem I don't know.[/QB]

I think it might be another problem. It seems that you may have a copy of the old class file somewhere in your classloader where Faces loaded it as the backing bean. Changing your bean to some different package name and face-config reconfiguration made it load the right class. To double check it if you are still interested, just keep the old configured bean then on a JSP page, print out the bean. If there is no error, then yes, you do have another copy of the class somewhere.

Cheers,
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Originally posted by Oscar Law:
I finally found the problem.

I have a jar and a war for my project. The jar holds my ejbs. It happens to have the same mysite.generalledger directory structure that my war held. The OrgBean only existed in my war file not my jar file. When I moved the OrgBean to a different directory structure, in this case it was mysite.web then the methods are called without a problem.

Why this fixes the problem I don't know.


You've duplicate different versioned classes of OrgBean thoroughout the classpath. The older versioned one took precedence in classloading which results in a complain about a missing method.

Keep your classpath clean.
 
jQuery in Action, 2nd edition
 
subject: JBOSS not finding JSF backing bean function