Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JBOSS not finding JSF backing bean function

 
Oscar Law
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Oscar Law
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this a newly added method? Have you tried to clear and redeploy the application?
 
Raymond Van Eperen
Greenhorn
Posts: 17
Java Mac Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
Java Mac Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic