Solved

Cannot create bean of class

Posted on 2002-06-14
13
247 Views
Last Modified: 2010-05-18
After suffering from a virus attack and having to format and reinstall everything i am having troulbe get my java application to function once again.  Although i think i have set everything up correctly i must have missed something.  I am getting the following error when i try to access one of my jsp pages using Jbuilders tomcat 3.2

javax.servlet.ServletException:  Cannot create bean of class app.MyBean

and when i run the application directly from tomcat (ver 4) i get this error

javax.servlet.ServletException: class app.MyBean: java.lang.NullPointerException

I have no idea what to do, i have double check all the settings and i think it should be working now...it was working before and i have not changed the code, so it must be my settings...and ideas?
0
Comment
Question by:menreeq
  • 7
  • 6
13 Comments
 
LVL 92

Expert Comment

by:objects
ID: 7079569
Can u post the code for app.MyBean.
0
 

Author Comment

by:menreeq
ID: 7079699
Objects, i am glad that you have answered my request for help. I have no problem posting the code expect that this one bean is about 700 lines of code and tad complicated/confusing.  Perhaps you can tell me what it is that you are looking for.  Remember, that this same exact code worked before i formated my computer.
0
 
LVL 92

Expert Comment

by:objects
ID: 7079720
Just post the ctor then.
Not really looking for a problem in the code, more trying to see what it is doing. And what external things could influence it. Does it load any config files on startup, that may be missing.

A stack trace for the NPE would also be helpful to determine exactly where the exception is occurring.

0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:menreeq
ID: 7079783
Here is the stack trace

javax.servlet.ServletException:  Cannot create bean of class ies.InformesEstudiantesBean
 at _0002fInformesEstudiantes_0002ejspInformesEstudiantes_jsp_0._jspService(_0002fInformesEstudiantes_0002ejspInformesEstudiantes_jsp_0.java:84)
 at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
 at org.apache.jasper.servlet.JspServlet$JspCountedServlet.service(JspServlet.java:130)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
 at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:282)
 at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:429)
 at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:500)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
 at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
 at org.apache.tomcat.core.Handler.service(Handler.java:287)
 at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
 at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:812)
 at org.apache.tomcat.core.ContextManager.service(ContextManager.java:758)
 at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213)
 at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
 at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
 at java.lang.Thread.run(Thread.java:484)

And i think this is what you mean by ctor:

import java.lang.String;
import java.util.Vector;
import ies.EstudiantesBean;
import java.sql.ResultSet;
import java.sql.Statement;

public class InformesEstudiantesBean extends EstudiantesBean {

  // Fields
  private ResultSet resultSet;
  private Statement statement;
  private Vector estudiantes;
  private Vector universidads;
  private String _filtorPorUniversidad;
  private String _filtorPorPractica;
  private String _filtorPorCodigo;

  // Constructors
  public InformesEstudiantesBean() { }
  public InformesEstudiantesBean(String p0) { }

  // Methods
  public void loadSingleEstudiante(String p0) { }
  public Vector getAllEstudianteIds(String p0, String p1, String p2, String p3) { }
  public Vector getAllUniversidads(String p0) { }
  public void set_filtorPorUniversidad(String p0) { }
  public void set_filtorPorPractica(String p0) { }
  public void set_filtorPorCodigo(String p0) { }
  public String get_filtorPorUniversidad() { }
  public String get_filtorPorPractica() { }
  public String get_filtorPorCodigo() { }
}

This part may be help too:

import java.sql.*;
import java.util.*;

public class InformesEstudiantesBean extends EstudiantesBean{

  public InformesEstudiantesBean(){
    super();
    statement = ConnectToDB.connectToDB();
  }

And estudiantesBean:

public class EstudiantesBean {

  public EstudiantesBean(){
    statement = ConnectToDB.connectToDB();

    //Only deletes the contents of the temp folder when the application is first started
    if( tempPhotoCount == 0 && !tempPhotoFolderFlushed )
      flushTempFolder();

  }
0
 
LVL 92

Expert Comment

by:objects
ID: 7079798
Check your classpath that tomcat can find your bean class.
Maybe try commenting out the contents of the ctor so that ihe default ctor does nothing and then try it.
If you get the same error then it's pretty sure that the problem is that tomcat cannot find the class.
0
 

Author Comment

by:menreeq
ID: 7079805
If i comment out from the following from the jsp file that call that bean

<jsp:useBean id="informesEstudiantesHandler" class="ies.InformesEstudiantesBean" scope="request"/>

then i no longer get the error.  I also think that it is unable to find that bean or more likely a package that the bean uses...smartUpload.  How do i verify this, where should the classpath be specified, is it in windows environments? And is it just classpath=...?

0
 
LVL 92

Expert Comment

by:objects
ID: 7079815
Check if your classes are in the web-inf directory of your webapp.
jars should be in <webapp>/web-inf/lib
classes should be in <webapp>/web-inf/classes
0
 

Author Comment

by:menreeq
ID: 7079863
Turns out that my application needed to have a folder available which I had forgotten to create.  So there was nothing wrong with the code or setup.
0
 
LVL 92

Expert Comment

by:objects
ID: 7079870
good to hear you got it working :-)
0
 

Author Comment

by:menreeq
ID: 7079894
What do you suggest i do with this question?
0
 
LVL 92

Accepted Solution

by:
objects earned 100 total points
ID: 7079898
It's up to you.
You can award me the points (I did mention above that there may be some required files missing :) , or delete the question if you can't 'afford' the points.

:-)

0
 

Author Comment

by:menreeq
ID: 7080096
Thanks once again for the help, Objects.
0
 
LVL 92

Expert Comment

by:objects
ID: 7080922
Anytime.
Thanks for the points :-)

http://www.objects.com.au/staff/mick
Brainbench MVP for Java 1
http://www.brainbench.com
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Problem with Pie chart in Jsp 20 222
problem with  angularjs dropdwon search at object property (name) level 2 104
gZip compression filter 2 174
spring example non maven 4 92
Giving access to ESXi shell console is always an issue for IT departments to other Teams, or Projects. We need to find a way so that teams can use ESXTOP for their POCs, or tests without giving them the access to ESXi host shell console with a root …
Most MSPs worth their salt are already offering cybersecurity to their customers. But cybersecurity as a service is wide encompassing and can mean many things.  So where are MSPs falling in this spectrum?
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question