Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Could not initialize class  RSS feed

 
Rene Ribeiro
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!

I'm creating a project in JSF / JPA, but displays the following error:



Here are a few files!











 
Tim Holloway
Bartender
Posts: 18702
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think we need more stacktrace. There's probably a "Caused By" parent exception somewhere further down it that indicates more precisely what the problem is.

You need to study more on the proper naming and capitalization of classes and entities in Java. For example, "ManagedBean" is not a proper package name. Some conventions which are not actually part of the language specification are required to be observed or certain Java tools will not operate properly. Upper case in a package name component is not good, but a class name beginning with a lower-case letter is likely to fail.

With databases, it's even worse. Some systems don't care about capitalization when referencing table or column names, some do, and some only care about capitalization when it's done in certain ways.

There's also this:


That's not good. First, because JSF action methods are not supposed to take parameters. The "parameters" for the action are expected to already be present in the backing bean, since the JSF lifecycle posts updated form data to the backing bean before the action method is called - the FORM (client) doesn't call the action method - JSF itself does. Secondly, it's redundant to pass contabean.conta into the action method, since it's already in the bean. Third, it's questionable to attempt to pass in a binary object anyway, since the client's data is all in text form, because that's a restriction on HTML itself. And finally, an action method is supposed to return a navigation request back to JSF, and not void. If you want the current View to redisplay, return null.

 
Rene Ribeiro
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Tim Holloway
Bartender
Posts: 18702
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is probably because you didn't adhere to proper capitalization conventions.

Normally, you'd name your bean's class "Contabean" and JSF would by default keep that mean in its context under the case-folder name "contabean". Using "contabean" as the class name probably confused it.

Try renaming the class from "contabean" to "Contabean" and see if you still get that error.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!