• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Exception creating bean of class

 
Ranch Hand
Posts: 180
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,

I am getting this exception while trying to run my program.

exception

javax.servlet.ServletException: Exception creating bean of class org.jboss.saurav.action.LookupForm: {1}
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.displayMBeans_jsp._jspService(displayMBeans_jsp.java:85)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)


root cause

javax.servlet.jsp.JspException: Exception creating bean of class org.jboss.saurav.action.LookupForm: {1}
org.apache.struts.taglib.html.FormTag.initFormBean(FormTag.java:487)
org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:457)
org.apache.jsp.displayMBeans_jsp._jspx_meth_html_form_0(displayMBeans_jsp.java:101)
org.apache.jsp.displayMBeans_jsp._jspService(displayMBeans_jsp.java:75)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)

Please find below the code.

Struts-config.xml file
 
saurav sarkar
Ranch Hand
Posts: 180
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This example i am trying to do from a book.
Please find below the other classes and the web.xml

The web.xml



The Action Class



The Form class



Friends please help me out..

Thanks ,
Saurav
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nine times out of ten, this error is the result of a simple spelling error. Double check that the fully qualified class name of the form listed in the struts-config.xml file is the actual name of the class.

Secondly, check to make sure that you actually did compile the class and put the .class file in the WEB-INF/classes directory.
 
saurav sarkar
Ranch Hand
Posts: 180
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Merill for your reply.

I have double checked both the names as well
as my classes are inside WEB-INF/Classes/(package)/...

Please advise what to do next

Thanks
Saurav
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Show is the complete code for your Action form including the package assignment. Also show us the code for your JSP.
 
saurav sarkar
Ranch Hand
Posts: 180
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

This is the code for my form class




the package is org.jboss.saurav.action

Here is the code for my jsp


 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since you haven't included a package declaration in your code, the ActionForm class is assumed to be in the default package. The first line of your code should be:

in order to be consistent the entry in the struts-config.xml.
[ January 08, 2007: Message edited by: Merrill Higginson ]
 
saurav sarkar
Ranch Hand
Posts: 180
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks again Merill for your reply.
I did the changes.....but still the error is coming.
Please help.
 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Saurav how you create your struts application? If all are correct start your application from the struts-blank application WAR file.Hope it will work.
 
Ingoba Ningthoujam
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Saurav how you create your struts application? If all are correct start your application from the struts-blank application WAR file.Hope it will work.
 
saurav sarkar
Ranch Hand
Posts: 180
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ingoba for your reply.
But nothing seems to work
 
Ingoba Ningthoujam
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
check all the jar files in classpath and struts version.I came across that problem while I was new in struts.Copy your struts blank WAR file in WEBAPP and start Tomcat then it will automatically create your struts-blank applicaion.rename to your project name and change the project name in build.xml in SRC folder to your project name and use this build file to compile your project.Hope it will work.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now check to see that the class is compiled and the .class file exists in the WEB-INF/classes/org/jboss/saurav/action directory.
 
saurav sarkar
Ranch Hand
Posts: 180
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ingoba and Merill for your reply.
I am not using build.xml.
I am just making a .war folder and deploying
it on jBoss.The class files are compiled
and are under the required package.
But still not working.
Please help
 
saurav sarkar
Ranch Hand
Posts: 180
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i believe the reason cud be the version of struts or jboss.
As programmitically everything seems to be fine
 
saurav sarkar
Ranch Hand
Posts: 180
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i resolved the problem by changing the TLD versions.
Now i am facing one more problem.


org.apache.jasper.JasperException: /index.jsp(12,0) Unable to find setter method for attribute: name
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:49)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:383)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:141)
at org.apache.jasper.compiler.Generator$GenerateVisitor.generateSetters(Generator.java:1728)
at org.apache.jasper.compiler.Generator$GenerateVisitor.generateCustomStart(Generator.java:1315)
at org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1137)
at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:659)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:999)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:1041)
at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:1047)
at org.apache.jasper.compiler.Node$Root.accept(Node.java:186)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:999)
at org.apache.jasper.compiler.Generator.generate(Generator.java:1894)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:203)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:355)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:427)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:142)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:240)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:187)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:198)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:144)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:209)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:595)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java

 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Saurav Java,

Before we get any further with this, there is something you need to take care of.

The name you're using does not meet the standards in The JavaRanch naming policy. According to the policy, the "publicly displayed name" in your profile must not be obiously fictitious.

This may seem like a trivial matter to you, but the naming policy is an important part of the JavaRanch culture, and we take it quite seriously.

Please change your display name before we continue this discussion.
 
saurav sarkar
Ranch Hand
Posts: 180
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Merill,

I understand the policy.Sorry for that.
I have changed my display name.

Cheers,
Saurav
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Saurav,

You shouldn't be getting these errors on such a simple application. I'm going to assume that your Struts installation is seriously messed up and suggest that you start over. Here's what I'd recommend:

  • Save your work in a separate directory somewhere. Then start with a completely fresh work environment
  • Go to the Struts Website and re-download whichever version of struts you're using.
  • Unzip the file you get from the download. Then find the file struts-blank.war and unzip it into a separate directory. If you're using an IDE such as Eclipse, import this directory as a project. This is your new working environment
  • Recreate your ActionForm and Action classes and your JSP. This time I'd recommend using a simple package name such as test.saurav.
  • Compile the Java code and make sure that the class files are placed in WEB-INF/classes/<package>
  • You will find that a shell struts-config.xml file has already been created. Add the <form-bean> and <action> entries to this file, making sure that class names and package names are the right ones and spelled correctly.
  • Package this environment as a war file, deploy to your application server, and re-test.

  •  
    saurav sarkar
    Ranch Hand
    Posts: 180
    Hibernate Eclipse IDE Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks a lot Merill for your reply.
    The problem is i can not download any software
    as its against my company policies.
    I have worked on JSP/Java Beans a lot.
    So, i was trying out with Struts to keep me updated.
    Seems that i am stuck big time.
    I tried with Jboss and tomcat.
    Both are not working
     
    Merrill Higginson
    Ranch Hand
    Posts: 4864
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    If you can't re-download the software, at least look to see if there is an existing struts-blank.war file already at your site that you can use.
     
    saurav sarkar
    Ranch Hand
    Posts: 180
    Hibernate Eclipse IDE Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Merill,


    I am using struts.jar and all the tlds from
    the exsisting apps.I wont be able to
    see the blank struts.war


    Saurav
     
    saurav sarkar
    Ranch Hand
    Posts: 180
    Hibernate Eclipse IDE Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi,

    I tried with blank struts .war
    But then its also giving me xml parsing error in web.xml

    Below is the web.xml



    Please help
     
    saurav sarkar
    Ranch Hand
    Posts: 180
    Hibernate Eclipse IDE Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    A very strange thing i am finding.....
    i have just commented everything in my jsp and struts-config.xml
    But still the error "can not find setter method for attribute: name"
    is coming.
    I even delted the contents of the work folder and the contents of the temp folder of the tomcat directory.
    Please help i am unable to find out what is the problem.

    Thanks,
    Saurav
     
    Ranch Hand
    Posts: 180
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I even delted the contents of the work folder and the contents of the temp folder of the tomcat directory.

    Hi Saurav,
    Try to change the names of the classes and the property from "name" to "firstname" or something. Start a new project.. after all life is not that bad with struts
    Secondly, the web.xml is not a valid xml. Please correct the XML and then use it.
    Please post your code with the stack trace and exceptions.
     
    saurav sarkar
    Ranch Hand
    Posts: 180
    Hibernate Eclipse IDE Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi Roshani,

    Thanks a lot for your reply.

    I tried to change the property name to name1.But the same error.
    Please tell me that what is the error in web.xml.
    I have removed everything from my web.xml,struts-config.xml and jsp.
    But still getting the same jsp error.

    Please find the codes below

    web.xml


    Struts-config.xml




    Jsp



    exception





    Please help.
    Life is looking bad for me in struts


    Saurav
     
    I yam what I yam and that's all that I yam - the great philosopher Popeye. Tiny ad:
    a bit of art, as a gift, that will fit in a stocking
    https://gardener-gift.com
    reply
      Bookmark Topic Watch Topic
    • New Topic