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 Web Java Discussion :

Tapestry5, Spring et Hibernate


Sujet :

Spring Web Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé
    Inscrit en
    Mai 2003
    Messages
    351
    Détails du profil
    Informations forums :
    Inscription : Mai 2003
    Messages : 351
    Par défaut Tapestry5, Spring et Hibernate
    Bonjour, j'ai suivi un tuto sur votre site http://baptiste-meurant.developpez.c...ing-hibernate/.

    Je précise que au lieu d'eclipse j'utilise Netbeans.
    Je suis coincé à trois niveaux:
    1-
    définition du proxy général OK, pas de problème
    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory"/>
    </bean>
    <bean id="transactionProxy" abstract="true"
    class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    <property name="transactionManager">
    <ref bean="transactionManager"/>
    </property>
    <property name="transactionAttributes">
    <props>
    <prop key="insert*">PROPAGATION_REQUIRED</prop>
    <prop key="update*">PROPAGATION_REQUIRED</prop>
    <prop key="save*">PROPAGATION_REQUIRED</prop>
    <prop key="*">PROPAGATION_REQUIRED, readOnly</prop>
    </props>
    </property>
    </bean>
    Configuration proxy spécifique Là ça coince
    <bean id="userManagerTarget" class="tuto.webssh.service.impl.UserManagerImpl">
    <property name="userDao">
    <ref bean="userDao" />
    </property>
    </bean>
    <bean id="userManager" parent="transactionProxy">
    <property name="target">
    <ref bean="userManagerTarget"/>
    </property>
    <property name="transactionAttributeSource">
    <bean class="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource"/>
    </property>
    </bean>
    Après la configuration du proxy spécifique, erreur de déploiement mais quand je modifie en :
    <bean id="userManagerTarget" class="tuto.webssh.service.impl.UserManagerImpl">
    <property name="userDao">
    <ref bean="userDao" />
    </property>
    </bean>
    <bean id="userManager" abstract="true" parent="transactionProxy">
    <property name="target">
    <ref bean="userManagerTarget"/>
    </property>
    <property name="transactionAttributeSource">
    <bean class="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource"/>
    </property>
    </bean>
    Là ça passe mais le problème est que la bean userManager est abstrait.

    2 - Le deuxième problème est dans le web.xml
    Initialement j'ai:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    <context-param>
    	  <param-name>contextConfigLocation</param-name>
    	  <param-value>/WEB-INF/applicationContext.xml </param-value>
    	</context-param>
    et quand je modifie en:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    <context-param>
    	  <param-name>contextConfigLocation</param-name>
    	  <param-value>/WEB-INF/applicationContext.xml /WEB-INF/applicationContextDao.xml</param-value>
    	</context-param>
    en ajoutant /WEB-INF/applicationContextDao.xml ça ne passe plus

    3- Le troisième problème c'est au niveau des filtres, quand j'ajoute
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     
    <filter>
    	    <filter-name>app</filter-name>
    	    <filter-class>org.apache.tapestry.TapestryFilter</filter-class>
            </filter>
     
            <filter-mapping>
    		<filter-name>app</filter-name>
    		<url-pattern>/*</url-pattern>
    	</filter-mapping>
    au web.xml, le déploiement n'est plus possible mais quand je retire ça marche.
    Merci pour votre aide

  2. #2
    Membre chevronné
    Profil pro
    Inscrit en
    Décembre 2003
    Messages
    476
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2003
    Messages : 476
    Par défaut
    Salut,

    Pourrez tu nous expliciter les messages d'erreur que tu as pour chacun de tes problèmes ?
    erreur de déploiement
    c'est un peu vague quand même
    Ca nous aiderait à diagnostiquer plus facilement (il y a plusieurs causes possibles pour tes problèmes)

  3. #3
    Membre éclairé
    Inscrit en
    Mai 2003
    Messages
    351
    Détails du profil
    Informations forums :
    Inscription : Mai 2003
    Messages : 351
    Par défaut
    Ok, nous allons alors aborder les problèmes un à un.
    voici mon fichier applicationcontext.xml actuel qui marche:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schem...-beans-3.0.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schem...ng-aop-3.0.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

    <!-- General -->
    <bean id="userDao" class="tuto.webssh.domain.dao.hibernate3.UserDaoImpl">
    <property name="sessionFactory">
    <ref bean="sessionFactory" />
    </property>
    </bean>


    <!-- sessionFactory -->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="configLocation">
    <value>classpath:hibernate.cfg.xml</value>
    </property>
    <property name="configurationClass">
    <value>org.hibernate.cfg.AnnotationConfiguration</value>
    </property>
    </bean>
    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory"/>
    </bean>
    <bean id="transactionProxy" abstract="true"
    class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    <property name="transactionManager">
    <ref bean="transactionManager"/>
    </property>
    <property name="transactionAttributes">
    <props>
    <prop key="insert*">PROPAGATION_REQUIRED</prop>
    <prop key="update*">PROPAGATION_REQUIRED</prop>
    <prop key="save*">PROPAGATION_REQUIRED</prop>
    <prop key="*">PROPAGATION_REQUIRED, readOnly</prop>
    </props>
    </property>
    </bean>

    <bean id="userManagerTarget" class="tuto.webssh.service.impl.UserManagerImpl">
    <property name="userDao">
    <ref bean="userDao" />
    </property>
    </bean>

    <bean id="userManager" abstract="true" parent="transactionProxy">
    <property name="transactionManager">
    <ref bean="transactionManager"/>
    </property>
    <property name="target">
    <ref bean="userManagerTarget"/>
    </property>
    <property name="transactionAttributeSource">
    <bean class="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource"/>
    </property>
    </bean>

    </beans>
    Et quand je le modifie le bean userManager pour être conforme au tuto en enlevant la propriété abstract='true' en gras i.e cela devient :

    <bean id="userManager" parent="transactionProxy">
    <property name="transactionManager">
    <ref bean="transactionManager"/>
    </property>
    <property name="target">
    <ref bean="userManagerTarget"/>
    </property>
    <property name="transactionAttributeSource">
    <bean class="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource"/>
    </property>
    </bean>


    j'ai l'erreur:
    INFO: cleaning up connection pool: jdbc:mysql://localhost:3306/formation
    5 juil. 2010 08:17:04 org.springframework.web.context.ContextLoader initWebApplicationContext
    GRAVE: Context initialization failed
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/aopalliance/aop/Advice
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:955)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:901)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:546)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:872)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3972)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4467)
    at org.apache.catalina.manager.ManagerServlet.start(ManagerServlet.java:1276)
    at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:378)
    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.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:199)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    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.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:558)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    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:298)
    at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)
    at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
    at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1555)
    at java.lang.Thread.run(Thread.java:619)
    Caused by: java.lang.NoClassDefFoundError: org/aopalliance/aop/Advice
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
    at java.lang.Class.getConstructor0(Class.java:2699)
    at java.lang.Class.getDeclaredConstructor(Class.java:1985)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:64)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:948)
    ... 35 more
    Caused by: java.lang.ClassNotFoundException: org.aopalliance.aop.Advice
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1516)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
    ... 41 more
    5 juil. 2010 08:17:04 org.apache.catalina.core.StandardContext start
    GRAVE: Error listenerStart
    5 juil. 2010 08:17:04 org.apache.catalina.core.StandardContext start
    GRAVE: Erreur de démarrage du contexte [/WebApplication1] suite aux erreurs précédentes
    5 juil. 2010 08:17:04 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
    GRAVE: A web application registered the JBDC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
    5 juil. 2010 08:17:04 org.apache.catalina.loader.WebappClassLoader clearReferencesStopTimerThread
    GRAVE: A web application appears to have started a TimerThread named [MySQL Statement Cancellation Timer] via the java.util.Timer API but has failed to stop it. To prevent a memory leak, the timer (and hence the associated thread) has been forcibly cancelled.

  4. #4
    Membre éclairé
    Inscrit en
    Mai 2003
    Messages
    351
    Détails du profil
    Informations forums :
    Inscription : Mai 2003
    Messages : 351
    Par défaut
    je veux simplement préciser que la librairie org/aopalliance/aop/Advice a été ajouter au projet. mais toujours le même message

  5. #5
    Membre éclairé
    Inscrit en
    Mai 2003
    Messages
    351
    Détails du profil
    Informations forums :
    Inscription : Mai 2003
    Messages : 351
    Par défaut
    Finalement cette étape est OK; en ré-compilant tout le projet.

  6. #6
    Membre éclairé
    Inscrit en
    Mai 2003
    Messages
    351
    Détails du profil
    Informations forums :
    Inscription : Mai 2003
    Messages : 351
    Par défaut
    Passons maintenant au problème du filtre:
    web.xml qui marche
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlnssi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext.xml /WEB-INF/applicationContextDao.xml</param-value>
    </context-param>

    <context-param>
    <param-name>tapestry.app-package</param-name>
    <param-value>tuto.webssh.web</param-value>
    </context-param>

    <filter>
    <filter-name>Hibernate Session In View Filter</filter-name>
    <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
    </filter>

    <filter-mapping>
    <filter-name>Hibernate Session In View Filter</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>


    <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>2</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>*.htm</url-pattern>
    </servlet-mapping>
    <session-config>
    <session-timeout>
    30
    </session-timeout>
    </session-config>
    <welcome-file-list>
    <welcome-file>Login.html</welcome-file>
    </welcome-file-list>
    </web-app>
    et quand j'ajoute le filtre :
    <filter>
    <filter-name>app</filter-name>
    <filter-class>org.apache.tapestry5.spring.TapestrySpringFilter</filter-class>
    </filter>

    <filter-mapping>
    <filter-name>app</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>
    a la compilation il ne dit que c'est bon mais il n'arrive pas à déployer et j'ai le message:
    Incrementally deploying http://localhost:8084/WebApplication1
    Completed incremental distribution of http://localhost:8084/WebApplication1
    Incrementally redeploying http://localhost:8084/WebApplication1
    Start is in progress...
    start?path=/WebApplication1
    ECHEC - L'application pour le chemin de contexte /WebApplication1 n'a pas pu être démarrée
    C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.26\webapps\WebApplication1\nbproject\build-impl.xml:700: The module has not been deployed.
    ÉCHEC DE LA GÉNÉRATION (durée totale* 6 secondes)

Discussions similaires

  1. [Tapestry] Premier projet avec Tapestry5, Spring et Hibernate
    Par visiteur2 dans le forum Spring Web
    Réponses: 3
    Dernier message: 07/12/2009, 09h12
  2. Réponses: 5
    Dernier message: 12/05/2006, 22h02
  3. SPRING+STRUTS+HIBERNATE. Une bonne solution ?
    Par ollivier dans le forum Struts 1
    Réponses: 9
    Dernier message: 10/04/2006, 13h16
  4. [Hibernate][Spring] Session Hibernate initialisée
    Par mauvais_karma dans le forum Hibernate
    Réponses: 12
    Dernier message: 08/08/2005, 13h07

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