Solved

Cannot create bean of class

Posted on 2002-06-14
13
253 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
Learn why we support net neutrality and why the topic is important to all internet users.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

690 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