Solved

Cannot create bean of class

Posted on 2002-06-14
13
238 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
 

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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

HOW TO: Upload an ISO image to a VMware datastore for use with VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere Host Client, and checking its MD5 checksum signature is correct.  It's a good idea to compare checksums, because many installat…
Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now