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

Spring Java Discussion :

NamingException : Cannot create resource instance


Sujet :

Spring Java

Mode arborescent

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Invité
    Invité(e)
    Par défaut NamingException : Cannot create resource instance
    Salut tout le monde ! J'ai un gros souci depuis 2 jours, je n'arrive pas à régler mon problème, je viens donc quémander de l'aide !

    Environnement : linux / tomcat 6.0.29 / jdk1.0.6_u23 / Spring 2.5 / Hibernate 3.2.7 / DB2 V9.7

    Lorsque je démarre mon tomcat, j'ai un erreur du type :

    catalina.2010-10-07.log
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    7 oct. 2010 12:13:49 org.apache.catalina.startup.HostConfig deployWAR
    INFO: Déploiement de l'archive testwapp.war de l'application web
    7 oct. 2010 12:13:50 org.apache.catalina.core.StandardContext start
    GRAVE: Error listenerStart
    7 oct. 2010 12:13:50 org.apache.catalina.core.StandardContext start
    GRAVE: Erreur de démarrage du contexte [/testwapp] suite aux erreurs précédentes
    localhost.2010-10-07.log
    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
    7 oct. 2010 12:15:50 org.apache.catalina.core.ApplicationContext log
    INFO: Initializing Spring root WebApplicationContext
    7 oct. 2010 12:15:51 org.apache.catalina.core.StandardContext listenerStart
    GRAVE: Exception lors de l'envoi de l'évènement contexte initialisé (context initialized) à l'instance de classe d'écoute (listener) org.springframework.web.context.ContextLoaderListener
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'txAdvice': Cannot resolve reference to bean 'testManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testManager' defined in ServletContext resource [/WEB-INF/applicationContext-service.xml]: Cannot resolve reference to bean 'testDataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testDataSource' defined in ServletContext resource [/WEB-INF/applicationContext-dao.xml]: Invocation of init method failed; nested exception is javax.naming.NamingException: Cannot create resource instance
        [...]
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testManager' defined in ServletContext resource [/WEB-INF/applicationContext-service.xml]: Cannot resolve reference to bean 'testDataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testDataSource' defined in ServletContext resource [/WEB-INF/applicationContext-dao.xml]: Invocation of init method failed; nested exception is javax.naming.NamingException: Cannot create resource instance
    	[...]
            ... 42 more
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testDataSource' defined in ServletContext resource [/WEB-INF/applicationContext-dao.xml]: Invocation of init method failed; nested exception is javax.naming.NamingException: Cannot create resource instance
    	[...]
            ... 55 more
    Caused by: javax.naming.NamingException: Cannot create resource instance
        [...]
            ... 65 more
    7 oct. 2010 12:15:51 org.apache.catalina.core.ApplicationContext log
    INFO: Closing Spring root WebApplicationContext
    7 oct. 2010 12:15:52 org.apache.catalina.core.ApplicationContext log
    INFO: ContextListener: contextInitialized()
    7 oct. 2010 12:15:52 org.apache.catalina.core.ApplicationContext log
    INFO: SessionListener: contextInitialized()
    On constate bien qu'il remonte de loin, et après plusieurs essais, notamment en la supprimant, j'ai comme l'impression qu'il n'arrive pas à créer la dataSource (d'où la cascade d'erreurs en aval).

    Voici l'extrait du fichier context.xml, situé dans le répertoire conf de tomcat :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    [...]
     <Resource name="jdbc/test" auth="Container" type="javax.sql.Datasource"
            maxActive="100" maxIdle="30" maxWait="10000"
            username="toto" password="toto" driverClassName="com.ibm.db2.jcc.DB2Driver"
            url="jdbc:db2://127.0.0.1:50000/TEST_DB2:currentSchema=toto;"/>
    [...]
    et le web.xml de ma webapp :
    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
     
    <web-app>
      <display-name>TEST Web Application</display-name>
     
            <!--  CONTEXT-PARAM -->
            <context-param>
                    <param-name>log4jConfigLocation</param-name>
                    <param-value>/WEB-INF/log4j.properties</param-value>
            </context-param>
            <context-param>
                    <param-name>log4jRefreshInterval</param-name>
                    <param-value>1000</param-value>
            </context-param>
            <context-param>
                    <param-name>flex.class.path</param-name>
                    <param-value>/WEB-INF/flex/hotfixes,/WEB-INF/flex/jars</param-value>
            </context-param>
            <context-param>
                    <param-name>contextConfigLocation</param-name>
                    <param-value>/WEB-INF/applicationContext*.xml </param-value>
            </context-param>
            <listener>
                    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
            </listener>
            <listener>
                    <listener-class>flex.messaging.HttpFlexSession</listener-class>
            </listener>
     
     
            <servlet>
                    <servlet-name>MessageBrokerServlet</servlet-name>
                    <display-name>MessageBrokerServlet</display-name>
                    <servlet-class>flex.messaging.MessageBrokerServlet</servlet-class>
                    <init-param>
                            <param-name>services.configuration.file</param-name>
                            <param-value>/WEB-INF/flex/services-config.xml</param-value>
                    </init-param>
                    <load-on-startup>1</load-on-startup>
            </servlet>
     
        <servlet-mapping>
                    <servlet-name>MessageBrokerServlet</servlet-name>
                    <url-pattern>/messagebroker/*</url-pattern>
            </servlet-mapping>
     
            <welcome-file-list>
                    <welcome-file>index.jsp</welcome-file>
            </welcome-file-list>
     
        <resource-ref>
      <description>Database TEST_DB2 Connection</description>
            <res-ref-name>jdbc/test</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Container</res-auth>
            <res-sharing-scope>Unshareable</res-sharing-scope>
        </resource-ref>
     
    </web-app>
    Enfin, mon fichier applicationContext-dao.xml

    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
     
    <beans>
        <bean id="testDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    		<property name="jndiName" value="java:comp/env/jdbc/test"/>
        </bean>
     
        <bean id="testHibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
            <property name="sessionFactory" ref="testSessionFactory"/>
            <property name="alwaysUseNewSession" value="false"/>
        </bean>
     
        <bean id="testSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
            <property name="dataSource">
    			<ref local="testDataSource" />
    		</property>
            <property name="mappingResources">
                <list>
    				<value>TestOne.hbm.xml</value>
    				<value>TestTwo.hbm.xml</value>
    			</list>
            </property>
            <property name="hibernateProperties">
    			<props>
    				<prop key="hibernate.dialect">org.hibernate.dialect.DB2Dialect</prop>
                    <prop key="hibernate.show_sql">true</prop>
                    <prop key="use_sql_comments">true</prop>
                    <prop key="hibernate.connection.autocommit">false</prop>
                </props>
            </property>
        </bean>
    	[...]
    </beans>
    Avez-vous des idées, des pistes... j'ai bien les bons .jar dans mon répertoire lib (notamment db2jcc pour le driver..)

    Je n'arrive pas à voir pourquoi il ne parvient pas à créer le nom, visiblement c'est un problème en lien avec le JNDI mais je sèche...

    Aussi, voilà mes variables $PATH & $CLASSPATH :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    echo $CLASSPATH
        > .:/home/jdk1.6.0_23/lib/classes.zip:/home/tomcat-daniel-6.0.29/lib/db2jcc4.jar
    echo $PATH
        > [...]:/home/jdk1.6.0_23/bin
    Dernière modification par Robin56 ; 08/01/2013 à 22h48. Motif: MAJ du préfixe

Discussions similaires

  1. Cannot create a new instance
    Par iacobm dans le forum JOnAS
    Réponses: 2
    Dernier message: 20/02/2008, 00h16
  2. Réponses: 2
    Dernier message: 29/01/2008, 11h34
  3. Réponses: 7
    Dernier message: 10/09/2006, 11h58
  4. [struts]Cannot create iterator for this collection
    Par jamal_b dans le forum Struts 1
    Réponses: 3
    Dernier message: 13/04/2006, 17h00
  5. Réponses: 4
    Dernier message: 07/10/2004, 15h41

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