jQuery in Action, 2nd edition*
The moose likes JSF and the fly likes Cant instantiate class: Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Cant instantiate class:" Watch "Cant instantiate class:" New topic
Author

Cant instantiate class:

Avik Mazunder
Ranch Hand

Joined: Jun 27, 2012
Posts: 39

I am tring to add data in datatable...
My home.jsf is..


home.java


bookdetails.java



face-config.xml





Its is giving this error...



Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15957
    
  19

If you http://www.coderanch.com/how-to/java/UseCodeTags it will be a lot more readable than if you simply boldface your code and XML.

In Java, class names must begin with an upper-case letter. Instance and property names must begin with a lower-case letter. So "home" is not a proper class name, and even though it will compile, JSF won't like it.

Additionally, you should always declare a package to contain classes. When you do not, a "default package" is assigned, and that, too makes a lot of Java systems unhappy. When you map the class in faces-config.xml, supply the fully-qualified classname. For example:



Customer surveys are for companies who didn't pay proper attention to begin with.
Avik Mazunder
Ranch Hand

Joined: Jun 27, 2012
Posts: 39

Tim Holloway wrote:If you http://www.coderanch.com/how-to/java/UseCodeTags it will be a lot more readable than if you simply boldface your code and XML.

In Java, class names must begin with an upper-case letter. Instance and property names must begin with a lower-case letter. So "home" is not a proper class name, and even though it will compile, JSF won't like it.

Additionally, you should always declare a package to contain classes. When you do not, a "default package" is assigned, and that, too makes a lot of Java systems unhappy. When you map the class in faces-config.xml, supply the fully-qualified classname. For example:



I have followed your suggestion but it didn't work....getting the same error...!Thank you...
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15957
    
  19

I do recommend that you find good some books covering both basic JavaBeans and JSF.

There are a number of things that can go wrong, and understanding the fundamentals of the platform will help a lot. Among the things that can cause an instantiation failure are:

o Failure to name the class ".java" file properly. Even in Windows, the source file name is case-sensitive. So the class named "com.javaranch.demo.Home" must reside in com\javaranch\demo\Home.java, and not "home.java".

o Failure in constructor code. If the class has a constructor (or inherits one) and there is an Exception thrown in the constructor method, this will cause instantiation failure

o Failure to specify the JSF configuration file properly. It must be (unless overridden explicitly in web.xml) at /WEB-INF/faces-config.xml. You wrote "face-config", not "faces-config", so make sure that the actual name is correct.

There are, unfortunately, a lot of other things that have to be done properly as well, but these are all critical ones.
Avik Mazunder
Ranch Hand

Joined: Jun 27, 2012
Posts: 39

is the java code right??
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cant instantiate class:
 
Similar Threads
How to upload file in jsf using richfaces?
Error: Dynamic Menu + Richfaces + A4j
Error reading "member"
Web app JSF+Facelets+Hibernate error: "No Persistence provider for EntityManager named"
javax.faces.FacesException: javax.faces.model.NoRowAvailableException