Thread: java.lang.NullPointerException msg after upgrade

java.lang.NullPointerException msg after upgrade

From
Olivier BULLAT
Date:
Hello,<br /><br /> With some programs which are OK, we upgrade our version of soft:<br /> Now, we use Apache,
Posgresql7.2, servlet java (JDK 1.2), Jserv and jdbc7.2dev-1.2.jar.<br /><br /> Log gives a message
"java.lang.NullPointerException"on instruction <br /> con =
DriverManager.getConnection(jdbc:postgresql://127.0.0.1:5432/menu,session.getValue("nom") + "",
session.getValue("passe")+ "")<br /><br /> The name of JDBC Driver has been changed in java source (msg
ClassNotFound):<br/> before: Class.forName("postgresql.Driver");<br /> now: Class.forName("org.postgresql.Driver");<br
/><br/> Example:<br /> try {<br /><br /> System.err.println("ChoixRecherche.java: Avant ouverture driver");<br /> try
{<br/> // Modif OBULLAT 13/05/03<br /> // Class.forName("postgresql.Driver");<br />
Class.forName("org.postgresql.Driver");//on charge le driver postgresql<br /> } catch (ClassNotFoundException cnfe)
{<br/> System.err.println("Programme ChoixRecherche.java: Couldn't find driver class:");<br />
cnfe.printStackTrace();<br/> }<br /><br /> System.err.println("ChoixRecherche.java: Aprés ouverture driver");<br />
System.err.println("ProgrammeChoixRecherche.java: variables_menu.url_base " + variables_menu.url_base);<br /> con =
DriverManager.getConnection(variables_trombi.url_base,session.getValue("nom")+"",session.getValue("passe")+"");<br/>
System.err.println("ChoixRecherche.java:Aprés con = DriverManager.getConnection");<br /> stmt =
con.createStatement();<br/> System.err.println("ChoixRecherche.java: Aprés stmt = con.createStatement()");<br />
choix(stmt,out);<br /> System.err.println("ChoixRecherche.java: Aprés choix(stmt,out)");<br /> stmt.close();<br />
con.close();<br/> }<br /> catch (SQLException ex) {<br /> while (ex != null) {<br /> out.println("<SQLEXCEPTION>
"+ex);<br /> System.err.println("Programme ChoixRecherche.java: SQLEXCEPTION "+ ex);<br /> ex =
ex.getNextException();<br/> }<br /> }<br /> catch (java.lang.Exception ex) {<br /> ex.printStackTrace();<br />
out.println("<JAVALANGEXEPTION>"+ex);<br /> System.err.println("ChoixRecherche.java: JAVALANGEXCEPTION "+ ex);<br
/>}<br /> }<br /><br /><br /> log are:<br /><br /> ChoixRecherche.java: Avant ouverture driver<br />
ChoixRecherche.java:Aprés ouverture driver<br /> Programme ChoixRecherche.java: variables_menu.url_base
jdbc:postgresql://127.0.0.1:7654/menu<br/> java.lang.NullPointerException: <br /> at
ChoixRecherche.service(ChoixRecherche.java:40)<br/> at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)<br
/>at org.apache.jservssi.ServletInfoRequest.runServlet(JServSSI.java:917)<br /> at
org.apache.jservssi.JServSSI.interpretPage(JServSSI.java:366)<br/> at
org.apache.jservssi.JServSSI.doGet(JServSSI.java:302)<br/> at
javax.servlet.http.HttpServlet.service(HttpServlet.java:499)<br/> at
javax.servlet.http.HttpServlet.service(HttpServlet.java:588)<br/> at
org.apache.jserv.JServConnection.processRequest(JServConnection.java:317)<br/> at
org.apache.jserv.JServConnection.run(JServConnection.java:188)<br/> at java.lang.Thread.run(Thread.java:479)<br />
ChoixRecherche.java:JAVALANGEXCEPTION java.lang.NullPointerException: <br /><br /> Any idea ?<br /><br />
--------------------------------------------------------------------------<br/> Olivier BULLAT<br /> Responsable du
Centrede Ressources Informatiques<br /> Institut Francais de Mecanique Avancee - IFMA<br /> Campus de CLERMONT-FERRAND
/Les Cezeaux<br /> BP 265<br /> 63175 AUBIERE Cedex<br /> Tel: 04.73.28.80.35<br /> Fax: 04.73.28.81.00<br /> mail:
<fontcolor="#0000FF"><u>Olivier.Bullat@ifma.fr<br /><a eudora="autourl"
href="http://www.ifma.fr/">http://www.ifma.fr</a><br
/></u></font>--------------------------------------------------------------------------<br /> 

Re: java.lang.NullPointerException msg after upgrade

From
"Nick Fankhauser"
Date:
Olivier-

Are you sure that the problem is with the connection? I'd suggest inserting
this line before opening the connection to make sure the session values
exist in this environment:

System.err.println(" URL: "+variables_trombi.url_base+
                   " nom: "+session.getValue("nom")+
                   " passe: "+session.getValue("passe"));

Regards,
    -Nick


-----Original Message-----
From: pgsql-jdbc-owner@postgresql.org
[mailto:pgsql-jdbc-owner@postgresql.org]On Behalf Of Olivier BULLAT
Sent: Thursday, May 15, 2003 2:19 AM
To: pgsql-jdbc@postgresql.org
Subject: [JDBC] java.lang.NullPointerException msg after upgrade


Hello,

With some programs which are OK, we upgrade our version of soft:
Now, we use Apache, Posgresql 7.2, servlet java (JDK 1.2), Jserv and
jdbc7.2dev-1.2.jar.

Log gives a message "java.lang.NullPointerException" on instruction
con = DriverManager.getConnection(jdbc:postgresql://127.0.0.1:5432/menu,
session.getValue("nom") + "", session.getValue("passe") + "")

The name of JDBC Driver has been changed in java source (msg ClassNotFound):
before: Class.forName("postgresql.Driver");
now: Class.forName("org.postgresql.Driver");

Example:
try {

System.err.println("ChoixRecherche.java: Avant ouverture driver");
try {
// Modif OBULLAT 13/05/03
// Class.forName("postgresql.Driver");
Class.forName("org.postgresql.Driver"); //on charge le driver postgresql
} catch (ClassNotFoundException cnfe) {
System.err.println("Programme ChoixRecherche.java: Couldn't find driver
class:");
cnfe.printStackTrace();
}

System.err.println("ChoixRecherche.java: Aprés ouverture driver");
System.err.println("Programme ChoixRecherche.java: variables_menu.url_base "
+ variables_menu.url_base);
con =
DriverManager.getConnection(variables_trombi.url_base,session.getValue("nom"
)+"",session.getValue("passe")+"");
System.err.println("ChoixRecherche.java: Aprés con =
DriverManager.getConnection");
stmt = con.createStatement();
System.err.println("ChoixRecherche.java: Aprés stmt =
con.createStatement()");
choix(stmt, out);
System.err.println("ChoixRecherche.java: Aprés choix(stmt,out)");
stmt.close();
con.close();
}
catch (SQLException ex) {
while (ex != null) {
out.println("<SQLEXCEPTION> "+ ex);
System.err.println("Programme ChoixRecherche.java: SQLEXCEPTION "+ ex);
ex = ex.getNextException();
}
}
catch (java.lang.Exception ex) {
ex.printStackTrace();
out.println("<JAVALANGEXEPTION>"+ ex);
System.err.println("ChoixRecherche.java: JAVALANGEXCEPTION "+ ex);
}
}


log are:

ChoixRecherche.java: Avant ouverture driver
ChoixRecherche.java: Aprés ouverture driver
Programme ChoixRecherche.java: variables_menu.url_base
jdbc:postgresql://127.0.0.1:7654/menu
java.lang.NullPointerException:
at ChoixRecherche.service(ChoixRecherche.java:40)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
at org.apache.jservssi.ServletInfoRequest.runServlet(JServSSI.java:917)
at org.apache.jservssi.JServSSI.interpretPage(JServSSI.java:366)
at org.apache.jservssi.JServSSI.doGet(JServSSI.java:302)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:499)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
at org.apache.jserv.JServConnection.processRequest(JServConnection.java:317)
at org.apache.jserv.JServConnection.run(JServConnection.java:188)
at java.lang.Thread.run(Thread.java:479)
ChoixRecherche.java: JAVALANGEXCEPTION java.lang.NullPointerException:

Any idea ?

--------------------------------------------------------------------------
Olivier BULLAT
Responsable du Centre de Ressources Informatiques
Institut Francais de Mecanique Avancee - IFMA
Campus de CLERMONT-FERRAND / Les Cezeaux
BP 265
63175 AUBIERE Cedex
Tel: 04.73.28.80.35
Fax: 04.73.28.81.00
mail: Olivier.Bullat@ifma.fr
http://www.ifma.fr
--------------------------------------------------------------------------