File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cant instantiate class:

 
Avik Mazunder
Ranch Hand
Posts: 39
Chrome Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 17645
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:


 
Avik Mazunder
Ranch Hand
Posts: 39
Chrome Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 17645
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 39
Chrome Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is the java code right??
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic