IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Servlets/JSP Java Discussion :

java.lang.NullPointerException lors de l'exécution de la servlet


Sujet :

Servlets/JSP Java

  1. #1
    Membre du Club
    Inscrit en
    Mars 2010
    Messages
    75
    Détails du profil
    Informations forums :
    Inscription : Mars 2010
    Messages : 75
    Points : 61
    Points
    61
    Par défaut java.lang.NullPointerException lors de l'exécution de la servlet
    Bonsoir
    Mon problème est que les même méthodes fonctionnent normalement sans JSP et Servlet cad j'ai fait une classe de test et ça marche bien avec connexion et enregistrement dans la bade de données sauf que suite au clic sur le bouton qui va exécuter la servlet apparait l'erreur suivante

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
    	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
    	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
    	at java.lang.Class.forName0(Native Method)
    	at java.lang.Class.forName(Unknown Source)
    	at com.formation.db.Cnx.connecter(Cnx.java:14)
    	at com.formation.dao.ServiceDao.<init>(ServiceDao.java:19)
    	at com.formation.servlet.AjouterService.doGet(AjouterService.java:41)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
    	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
    	at java.lang.Thread.run(Unknown Source)
    2 janv. 2011 03:04:50 org.apache.catalina.core.StandardWrapperValve invoke
    GRAVE: "Servlet.service()" pour la servlet AjouterService a généré une exception
    java.lang.NullPointerException
    	at com.formation.db.Cnx.modif(Cnx.java:23)
    	at com.formation.dao.ServiceDao.saveService(ServiceDao.java:31)
    	at com.formation.servlet.AjouterService.doGet(AjouterService.java:48)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
    	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
    	at java.lang.Thread.run(Unknown Source)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
     
    		ServiceDao servicedao = new ServiceDao();
     
    		Service s = new Service();
    		String nom_service = request.getParameter("nom_service");
    		s.setNom(nom_service);
     
    		try {
    			servicedao.saveService(s);
    		} catch (SQLException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}
    		response.sendRedirect("AjouterService.jsp");
     
    	}
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    <form action="AjouterService" method="get">
    .
    .
    <input type="submit" class="Bouton" value="Envoyer" />
    Je vous remercie

  2. #2
    Expert éminent sénior
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 482
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Points : 48 807
    Points
    48 807
    Par défaut
    il manque votre driver oracle.

  3. #3
    Membre du Club
    Inscrit en
    Mars 2010
    Messages
    75
    Détails du profil
    Informations forums :
    Inscription : Mars 2010
    Messages : 75
    Points : 61
    Points
    61
    Par défaut
    Merci mais ça marche bien la connexion a la BD sans servlet
    Mais une croix rouge sur web.xml indique qu'elle contient une erreur
    et je sais pas comment
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
      <?xml version="1.0" encoding="UTF-8" ?> 
    - <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
      <display-name>AFormation</display-name> 
    - <welcome-file-list>
      <welcome-file>index.html</welcome-file> 
      <welcome-file>index.htm</welcome-file> 
      <welcome-file>index.jsp</welcome-file> 
      <welcome-file>default.html</welcome-file> 
      <welcome-file>default.htm</welcome-file> 
      <welcome-file>default.jsp</welcome-file> 
      </welcome-file-list>
    - <servlet>
      <description /> 
      <display-name>AjouterService</display-name> 
      <servlet-name>AjouterService</servlet-name> 
      <servlet-class>com.formation.servlet.AjouterService</servlet-class> 
      </servlet>
    - <servlet-mapping>
      <servlet-name>AjouterService</servlet-name> 
      <url-pattern>/AjouterService</url-pattern> 
      </servlet-mapping>
    - <servlet>
      <description /> 
      <display-name>AjouterPersonne</display-name> 
      <servlet-name>AjouterPersonne</servlet-name> 
      <servlet-class>com.formation.servlet.AjouterPersonne</servlet-class> 
      </servlet>
    - <servlet-mapping>
      <servlet-name>AjouterPersonne</servlet-name> 
      <url-pattern>/AjouterPersonne</url-pattern> 
      </servlet-mapping>
    - <servlet>
      <description /> 
      <display-name>ServletRecuperationServices</display-name> 
      <servlet-name>ServletRecuperationServices</servlet-name> 
      <servlet-class>com.formation.servlet.ServletRecuperationServices</servlet-class> 
      </servlet>
    - <servlet-mapping>
      <servlet-name>ServletRecuperationServices</servlet-name> 
      <url-pattern>/ServletRecuperationServices</url-pattern> 
      </servlet-mapping>
    - <servlet>
      <description /> 
      <display-name>ServletRechercheService</display-name> 
      <servlet-name>ServletRechercheService</servlet-name> 
      <servlet-class>com.formation.servlet.ServletRechercheService</servlet-class> 
      </servlet>
    - <servlet-mapping>
      <servlet-name>ServletRechercheService</servlet-name> 
      <url-pattern>/ServletRechercheService</url-pattern> 
      </servlet-mapping>
    - <servlet>
      <description /> 
      <display-name>ModifierServiceServlet</display-name> 
      <servlet-name>ModifierServiceServlet</servlet-name> 
      <servlet-class>com.formation.servlet.ModifierServiceServlet</servlet-class> 
      </servlet>
    - <servlet-mapping>
      <servlet-name>ModifierServiceServlet</servlet-name> 
      <url-pattern>/ModifierServiceServlet</url-pattern> 
      </servlet-mapping>
    - <taglib>
      <taglib-uri>/tags/c</taglib-uri> 
      <taglib-location>/WEB-INF/c.tld</taglib-location> 
      </taglib>
      </web-app>
    corriger

  4. #4
    Futur Membre du Club
    Inscrit en
    Janvier 2011
    Messages
    6
    Détails du profil
    Informations forums :
    Inscription : Janvier 2011
    Messages : 6
    Points : 6
    Points
    6
    Par défaut salut mon amis
    et bah alors je vais essayer de résoudre votre problème. Il faut suivre les étapes : dans une application web il faut mettre votre driver oracle ".jar" en dossier web-INF/lib et ça marche!

    Essayez ça et répondez moi. Bonne chance

Discussions similaires

  1. L'exécution m'affiche le message d'erreur java.lang.NullPointerException
    Par a.collery dans le forum Interfaces Graphiques en Java
    Réponses: 1
    Dernier message: 30/10/2014, 16h39
  2. java.lang.NullPointerException lors de l'affectation d'une valeur null
    Par NicolasTT dans le forum Développement de jobs
    Réponses: 2
    Dernier message: 24/04/2012, 11h16
  3. Réponses: 7
    Dernier message: 02/02/2011, 18h22
  4. java.lang.NullPointerException erreur exécution
    Par akram_dhiabi dans le forum Général Java
    Réponses: 0
    Dernier message: 07/03/2010, 00h55
  5. Réponses: 0
    Dernier message: 26/12/2007, 17h28

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo