Solved

Cannot create bean of class

Posted on 2002-06-14
13
245 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
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Coldfusion 10 - JSP File Not Found - 404 Error 5 92
immutable object concept 5 119
spring example non maven 4 87
Use tracing facilities in your browser steps 2 117
When we purchase storage, we typically are advertised storage of 500GB, 1TB, 2TB and so on. However, when you actually install it into your computer, your 500GB HDD will actually show up as 465GB. Why? It has to do with the way people and computers…
Data breaches are on the rise, and companies are preparing by boosting their cybersecurity budgets. According to the Cybersecurity Market Report (http://www.cybersecurityventures.com/cybersecurity-market-report), worldwide spending on cybersecurity …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

773 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