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

JDBC Java Discussion :

Erreur "No suitable driver found for jdbc:oracle:thin" sous Tomcat, OK dans Eclipse/Jetty


Sujet :

JDBC Java

  1. #1
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2007
    Messages
    50
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2007
    Messages : 50
    Points : 37
    Points
    37
    Par défaut Erreur "No suitable driver found for jdbc:oracle:thin" sous Tomcat, OK dans Eclipse/Jetty
    Bonjour à tous,

    Je paye une bière à celui qui résoudra mon problème qui est le suivant.

    Environnement :
    JDK 1.7
    Tomcat 7
    Oracle 11g
    Spring 3
    Hibernate 4
    Maven 2
    CXF 2.6
    Jetty

    J'ai développé un web service avec Eclipse (m2eclipse), Maven2, CXF, Hibernate4 et Spring3, qui permet de récupérer des infos client dans une base Oracle (11g) sur un serveur Tomcat 7 (pour l'instant en local).

    L'application fonctionne bien avec Jetty ou même avec un test unitaire dans Eclipse.

    J'utilise la lib ojdbc6.jar que j'ai installé manuellement avec Maven.

    Dès lors que je déploie le WAR généré avec Maven sur un Tomcat, j'ai l'erreur suivante :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    2012-05-16 00:44:54,338 [http-bio-8080-exec-3] DEBUG org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl - Opening new JDBC connection
    2012-05-16 00:44:54,339 [http-bio-8080-exec-3] DEBUG org.hibernate.engine.jdbc.spi.SqlExceptionHelper - Could not open connection [n/a]
    java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=172.25.12.76)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=DELTA)))
    J'ai vérifié le déploiement, ojdbc est bien dans le classpath (WEB-INF/lib).

    Ce que j'ai essayé :
    - Changer de version de ojdbc (11.1 et 11.2)
    - Placer la ojdbc dans la lib Tomcat
    - Changer le nom du driver : oracle.jdbc.OracleDriver et oracle.jdbc.driver.OracleDriver
    - Retourner l'url jdbc dans tous les sens, pour finir j'ai laissé comme c'était car çà fonctionne dans Jetty et Eclipse.

    J'ai fouillé le web entier pour trouver comment résoudre ce problème en vain.

    Quelques infos :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
    <hibernate-configuration>
      <session-factory>
        <property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
        <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
        <property name="hibernate.connection.url">jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=172.25.12.76)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=DELTA)))</property>
        <!--<property name="hibernate.connection.url">jdbc:oracle:thin:@//172.25.12.76:1521/DELTA1</property>-->
        <property name="hibernate.connection.username">user</property>
        <property name="hibernate.connection.password">password</property>
        <property name="current_session_context_class">thread</property>
        <mapping resource="hibernate.customer.xml"/>
      </session-factory>
    </hibernate-configuration>
    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
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    	xmlns:jaxws="http://cxf.apache.org/jaxws"
        xmlns:context="http://www.springframework.org/schema/context"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans 
    						http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
    						http://cxf.apache.org/jaxws 
    						http://cxf.apache.org/schemas/jaxws.xsd
    					    http://www.springframework.org/schema/context 
    					    http://www.springframework.org/schema/context/spring-context-2.5.xsd">
     
    	<import resource="classpath:META-INF/cxf/cxf.xml" />
    	<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
    	<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
     
    	<!-- Package a scanner par SPRING. -->
        <context:component-scan base-package="com.maboite"/>
     
    	<jaxws:endpoint id="customerService"
    		implementor="com.maboite.ws.service.CustomerServiceImpl" address="/CustomerSrv">
    		<jaxws:properties>
    			<entry key="mtom-enabled" value="true" />
    		</jaxws:properties>
    	</jaxws:endpoint>
    </beans>
    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
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
     
     
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <groupId>com.maboite</groupId>
      <artifactId>ws</artifactId>
      <packaging>war</packaging>
      <version>0.0.1-SNAPSHOT</version>
      <url>http://maven.apache.org</url>
      <name>RedWs</name>
     
      <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <jdk.version>1.7</jdk.version>
        <spring.version>3.1.1.RELEASE</spring.version>
      </properties>
     
      <organization>
      	<name>Ma boite</name>
      	<url>http://www.maboite.com</url>
      </organization>
     
      <dependencies>
        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>4.10</version>
          <scope>test</scope>
        </dependency>
        <dependency>
        	<groupId>org.apache.cxf</groupId>
        	<artifactId>cxf-rt-frontend-jaxws</artifactId>
        	<version>2.6.0</version>
        </dependency>
        <dependency>
        	<groupId>org.apache.cxf</groupId>
        	<artifactId>cxf-rt-transports-http</artifactId>
        	<version>2.6.0</version>
        </dependency>
        <dependency>
        	<groupId>log4j</groupId>
        	<artifactId>log4j</artifactId>
        	<version>1.2.16</version>
        </dependency>
        <dependency>
        	<groupId>org.hibernate</groupId>
        	<artifactId>hibernate-core</artifactId>
        	<version>4.1.2.Final</version>
        </dependency>
        <dependency>
        	<groupId>org.springframework</groupId>
        	<artifactId>spring-context</artifactId>
        	<version>${spring.version}</version>
        </dependency>
        <dependency>
        	<groupId>org.springframework</groupId>
        	<artifactId>spring-web</artifactId>
        	<version>${spring.version}</version>
        </dependency>
        <dependency>
        	<groupId>org.springframework</groupId>
        	<artifactId>spring-webmvc</artifactId>
        	<version>${spring.version}</version>
        </dependency>
        <dependency>
        	<groupId>org.springframework</groupId>
        	<artifactId>spring-test</artifactId>
        	<version>${spring.version}</version>
        </dependency>
        <dependency>
        	<groupId>org.springframework</groupId>
        	<artifactId>spring-aop</artifactId>
        	<version>${spring.version}</version>
        </dependency>
        <dependency>
    		<groupId>com.oracle</groupId>
    		<artifactId>ojdbc6</artifactId>
    		<version>11.1.0</version>
    	</dependency>
     
      </dependencies>
     
      <build>
    	<finalName>${project.name}</finalName>
      	<plugins>
      	    <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.2</version>
            </plugin>
      		<plugin>
      			<groupId>org.mortbay.jetty</groupId>
      			<artifactId>maven-jetty-plugin</artifactId>
      			<version>6.1.4</version>
    			<configuration>
    			    <source>${jdk.version}</source>
                    <target>${jdk.version}</target>
    				<scanIntervalSeconds>3</scanIntervalSeconds>
    				<contextPath>/jetty</contextPath>
    				<connectors>
    					<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
    						<port>5500</port>
    					</connector>
    				</connectors>
    			</configuration>
      		</plugin>
      	</plugins>
      </build>
    </project>
    Merci d'avance

  2. #2
    Membre expérimenté
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2004
    Messages
    1 184
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Avril 2004
    Messages : 1 184
    Points : 1 745
    Points
    1 745
    Par défaut
    Peut-être une piste :
    <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
    => https://forums.oracle.com/forums/ann.jspa?annID=201
    Essaye avec oracle.jdbc.OracleDriver

    Au passage, si ton jar est dans le dossier lib de tomcat, tu ne doit plus en avoir besoin dans /WEB-INF/lib.


    Edit :
    Je n'avais pas vu que tu as essayé les 2 classes. Désolé.

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

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

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 481
    Points : 48 806
    Points
    48 806
    Par défaut
    Citation Envoyé par houpli Voir le message
    Je paye une bière à celui qui résoudra mon problème qui est le suivant.
    Je t'aurais bien aidé, mais vu que je suis déjà servi

    Première suggestion, écrire un servlet ou un context listener qui essaie par lui même d'accéder à la classe oracle.jdbc.Driver (histoire de s'assurer que tomcat la voit), et qui fait une DriverManager.getDrivers() pour te lister (information) les drivers disponibles. Enfin, tenter manellement une connexion.

    perso j'ai plutot tendance à faire pointer hibernate vers un datasource.

    Dernière chose, quelle variante de ojdbc as tu téléchargé (ojdbc14, 15, 16 ?)

  4. #4
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2007
    Messages
    50
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2007
    Messages : 50
    Points : 37
    Points
    37
    Par défaut
    Pour info si j'ajoute Class.forName("oracle.jdbc.OracleDriver") dans mon dao çà fonctionne bien

  5. #5
    Rédacteur/Modérateur
    Avatar de andry.aime
    Homme Profil pro
    Inscrit en
    Septembre 2007
    Messages
    8 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Ile Maurice

    Informations forums :
    Inscription : Septembre 2007
    Messages : 8 391
    Points : 15 059
    Points
    15 059
    Par défaut
    Essaie de mettre directement ojdbc dans le repertoire lib de tomcat.

    A+.

  6. #6
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2007
    Messages
    50
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2007
    Messages : 50
    Points : 37
    Points
    37
    Par défaut
    Je l'avais fait, çà ne change rien.

    Problème résolu en implémentant hibernate via spring

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. No suitable driver found for jdbc.mysql://localhost:3306/
    Par bubulemaster dans le forum JDBC
    Réponses: 2
    Dernier message: 15/08/2016, 19h47
  2. Réponses: 5
    Dernier message: 31/08/2012, 09h23
  3. Réponses: 3
    Dernier message: 27/05/2012, 13h25
  4. Réponses: 1
    Dernier message: 04/06/2008, 23h22
  5. Réponses: 1
    Dernier message: 04/06/2008, 23h18

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