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

JPA Java Discussion :

Problème de création du fichier persistence.xml


Sujet :

JPA Java

  1. #1
    Membre du Club
    Homme Profil pro
    Développeur Java
    Inscrit en
    Mars 2014
    Messages
    67
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mars 2014
    Messages : 67
    Points : 63
    Points
    63
    Par défaut Problème de création du fichier persistence.xml
    bonjour, j'ai créer un projet web sous eclipse, mais je ne sais pas comment integré le jpaContent ainsi que le persistence.xml.
    je souhaiterai savoir comment le générer dans un dynamic web project et comment bien le configurer merci.

  2. #2
    Membre actif
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Mai 2014
    Messages
    153
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Mai 2014
    Messages : 153
    Points : 227
    Points
    227
    Par défaut
    Le persistence context doit contenir le provider (org.hibernate.ejb.HibernatePersistence)et les properties(la bdd) ainsi que le nom choisi pour l'unité de persistence.(le même repris dans web.xml bien sur).
    Pour le jpa dans ton applicationcontext.xml tu inclues les beans persistenceUnitManager,le JpaTransactionManager.
    Bonne continuation.

  3. #3
    Membre du Club
    Homme Profil pro
    Développeur Java
    Inscrit en
    Mars 2014
    Messages
    67
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mars 2014
    Messages : 67
    Points : 63
    Points
    63
    Par défaut
    bonjour, voici mon xml il s'integre au JPA Content mais j ai un problème au lancement du serveur jboss j'ai pourtant modifier le standalone.xml

    voici l'erreur si sa peut aidé

    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
     
    <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
    	<persistence-unit name="persistence" transaction-type="RESOURCE_LOCAL">
    		<provider>org.hibernate.ejb.HibernatePersistence</provider>
    		 <jta-data-source>java:/datasourceStudent</jta-data-source>
    		<class>com.Student</class>
    		<properties>
    		    <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
    		    <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
                <property name="hibernate.connection.password" value="root"/>
                <property name="hibernate.connection.url" value="jdbc:mysql://127.0.0.1:3306/eclipse"/>
                <property name="hibernate.connection.username" value="root"/>
    		    <property name="hibernate.showSql" value="true" />
    		    <property name="hibernate.hbm2ddl.auto" value="create-drop" />
    		    <property name="hibernate.connection.autocommit" value="true" />
    		          <property name="jboss.entity.manager.factory.jndi.name" value="java:/pmsEntityManagerFactory"/>
    		</properties>
    	</persistence-unit>
    </persistence>
    voici la console
    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
     
    21:14:59,393 INFOS [org.jboss.modules] JBoss Modules version 1.1.1.GA
    21:14:59,941 INFO  [org.jboss.msc] JBoss MSC version 1.0.2.GA
    21:15:00,055 INFO  [org.jboss.as] JBAS015899: JBoss AS 7.1.1.Final "Brontes" starting
    21:15:01,924 INFO  [org.xnio] XNIO Version 3.0.3.GA
    21:15:01,930 INFO  [org.jboss.as.server] JBAS015888: Creating http management service using socket-binding (management-http)
    21:15:01,947 INFO  [org.xnio.nio] XNIO NIO Implementation Version 3.0.3.GA
    21:15:01,967 INFO  [org.jboss.remoting] JBoss Remoting version 3.2.3.GA
    21:15:02,025 INFO  [org.jboss.as.logging] JBAS011502: Removing bootstrap log handlers
    21:15:02,037 INFO  [org.jboss.as.configadmin] (ServerService Thread Pool -- 26) JBAS016200: Activating ConfigAdmin Subsystem
    21:15:02,061 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 31) JBAS010280: Activating Infinispan subsystem.
    21:15:02,111 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 38) JBAS011800: Activating Naming Subsystem
    21:15:02,124 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 44) JBAS013101: Activating Security Subsystem
    21:15:02,145 INFO  [org.jboss.as.osgi] (ServerService Thread Pool -- 39) JBAS011940: Activating OSGi Subsystem
    21:15:02,152 INFO  [org.jboss.as.connector] (MSC service thread 1-4) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.9.Final)
    21:15:02,166 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension
    21:15:02,210 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
    21:15:02,308 INFO  [org.jboss.as.security] (MSC service thread 1-2) JBAS013100: Current PicketBox version=4.0.7.Final
    21:15:02,337 INFO  [org.jboss.as.naming] (MSC service thread 1-1) JBAS011802: Starting Naming Service
    21:15:02,340 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-3) JBAS015400: Bound mail session [java:jboss/mail/Default]
    21:15:02,579 INFO  [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-8) JBoss Web Services - Stack CXF Server 4.0.2.GA
    21:15:03,235 INFO  [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-1) Démarrage de Coyote HTTP/1.1 sur http-localhost-127.0.0.1-8080
    21:15:03,549 INFO  [org.jboss.as.remoting] (MSC service thread 1-5) JBAS017100: Listening on localhost/127.0.0.1:9999
    21:15:03,549 INFO  [org.jboss.as.remoting] (MSC service thread 1-2) JBAS017100: Listening on localhost/127.0.0.1:4447
    21:15:03,556 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-8) JBAS015012: Started FileSystemDeploymentService for directory C:\Users\dandy\jboss-as-7.1.1.Final\standalone\deployments
    21:15:03,587 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015014: Re-attempting failed deployment CRUD_JSP_EJB_JPA.war
    21:15:03,602 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found CRUD_JSP_EJB_JPA.war in deployment directory. To trigger deployment create a file called CRUD_JSP_EJB_JPA.war.dodeploy
    21:15:03,956 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-5) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
    21:15:04,265 INFO  [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report
    JBAS014775:    New missing/unsatisfied dependencies:
          service jboss.jdbc-driver.com_mysql_jdbc_Driver (missing) dependents: [service jboss.data-source.java:/datasourceStudent] 
     
    21:15:04,317 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015876: Starting deployment of "CRUD_JSP_EJB_JPA.war"
    21:15:04,785 INFO  [org.jboss.as.jpa] (MSC service thread 1-4) JBAS011401: Read persistence.xml for persistence
    21:15:05,014 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-6) JNDI bindings for session bean named StudentEJB in deployment unit deployment "CRUD_JSP_EJB_JPA.war" are as follows:
     
    	java:global/CRUD_JSP_EJB_JPA/StudentEJB!com.StudentEJB
    	java:app/CRUD_JSP_EJB_JPA/StudentEJB!com.StudentEJB
    	java:module/StudentEJB!com.StudentEJB
    	java:global/CRUD_JSP_EJB_JPA/StudentEJB!com.StudentEJBLocal
    	java:app/CRUD_JSP_EJB_JPA/StudentEJB!com.StudentEJBLocal
    	java:module/StudentEJB!com.StudentEJBLocal
     
    21:15:05,431 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC00001: Failed to start service jboss.deployment.unit."CRUD_JSP_EJB_JPA.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."CRUD_JSP_EJB_JPA.war".INSTALL: Failed to process phase INSTALL of deployment "CRUD_JSP_EJB_JPA.war"
    	at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
    	at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    	at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_71]
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_71]
    	at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_71]
    Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011047: Component class com.StudentEJB for component StudentEJB has errors: 
    JBAS011428: Cannot inject RESOURCE_LOCAL container managed EntityManagers using @PersistenceContext
    	at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor$1.handle(ModuleJndiBindingProcessor.java:169)
    	at org.jboss.as.ee.component.ClassDescriptionTraversal.run(ClassDescriptionTraversal.java:54)
    	at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.processClassConfigurations(ModuleJndiBindingProcessor.java:162)
    	at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.deploy(ModuleJndiBindingProcessor.java:155)
    	at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
    	... 5 more
     
    21:15:05,467 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "CRUD_JSP_EJB_JPA.war" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"CRUD_JSP_EJB_JPA.war\".INSTALL" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"CRUD_JSP_EJB_JPA.war\".INSTALL: Failed to process phase INSTALL of deployment \"CRUD_JSP_EJB_JPA.war\""}}
    21:15:05,473 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
    JBAS014777:   Services which failed to start:      service jboss.deployment.unit."CRUD_JSP_EJB_JPA.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."CRUD_JSP_EJB_JPA.war".INSTALL: Failed to process phase INSTALL of deployment "CRUD_JSP_EJB_JPA.war"
     
    21:15:05,483 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"CRUD_JSP_EJB_JPA.war\".INSTALL" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"CRUD_JSP_EJB_JPA.war\".INSTALL: Failed to process phase INSTALL of deployment \"CRUD_JSP_EJB_JPA.war\""}}}}
    21:15:05,507 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-7) JBAS015877: Stopped deployment CRUD_JSP_EJB_JPA.war in 40ms

  4. #4
    Membre actif
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Mai 2014
    Messages
    153
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Mai 2014
    Messages : 153
    Points : 227
    Points
    227
    Par défaut
    Je pensai que tu étais en spring donc tomcat!!
    Là c'est ejb!
    Donc ton serveur est un serveur d'appli jee lourd.Par conséquent la config est différente:
    ton persistence context est réduit au minimum :
    le jta-data-source ex java:/produitDS
    les properties
    <property name="hibernate.hbm2ddl.auto" value="update"/>
    </properties> et c'est tout !jboss fait le boulot.ici le produitDS correspond à la config standalone.xml
    Dans ton daoimplem ,tu injectes @persistencecontext(persistence unit name choisi)
    Bonne continuation

  5. #5
    Membre chevronné Avatar de jeffray03
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2008
    Messages
    1 501
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Allemagne

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juillet 2008
    Messages : 1 501
    Points : 2 120
    Points
    2 120
    Par défaut
    Salut,
    et n´oublie pas demettre le type de transaction en JTA
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
      <persistence-unit name="persistence" transaction-type="JTA">
    eric

  6. #6
    Membre du Club
    Homme Profil pro
    Développeur Java
    Inscrit en
    Mars 2014
    Messages
    67
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mars 2014
    Messages : 67
    Points : 63
    Points
    63
    Par défaut
    j'ai réussi voici les fichiers si sa peut aidé, par contre tu peux m'expliquer la difference entre JTA et RESSOURCE_LOCAL

    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
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence version="1.0"
    	xmlns="http://java.sun.com/xml/ns/persistence" xmlns:orm="http://java.sun.com/xml/ns/persistence/orm"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_1_0.xsd">
     
    	<persistence-unit name="persist" transaction-type="RESOURCE_LOCAL">
    		<provider>org.hibernate.ejb.HibernatePersistence</provider>
    		<jta-data-source>java:jboss/datasources/mydb</jta-data-source>
     
    		<!-- The tables that will be created in your specified sql schema -->
    		<class>com.exo.User</class>
    		<properties>
    			<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
    			<property name="hibernate.connection.autocommit" value="false" />
    			<property name="hibernate.max_fetch_depth" value="3" />
    		<!-- <property name="hibernate.hbm2ddl.auto" value="create" /> -->
    			<property name="hibernate.show_sql" value="true" />
    			<property name="hibernate.transaction.manager_lookup_class"
    				value="org.hibernate.transaction.JBossTransactionManagerLookup" />
    		</properties>
    	</persistence-unit>
    </persistence>
    ainsi que la partie modifié du standalone.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
     
     
    <subsystem xmlns="urn:jboss:domain:datasources:2.0">
                <datasources>
                    <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
                        <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
                        <driver>h2</driver>
                        <security>
                            <user-name>sa</user-name>
                            <password>sa</password>
                        </security>
                    </datasource>
                    <datasource jndi-name="java:jboss/datasources/mydb" pool-name="mydb" enabled="true" use-java-context="true">
                        <connection-url>jdbc:mysql://127.0.0.1:3306/mydb</connection-url>
                        <driver>mysql</driver>
                        <security>
                            <user-name>root</user-name>
                            <password>banane</password>
                        </security>
                    </datasource>
                    <drivers>
                        <driver name="h2" module="com.h2database.h2">
                            <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
                        </driver>
                        <driver name="mysql" module="com.sql.mysql">
                            <driver-class>com.mysql.jdbc.Driver</driver-class>
                            <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
                        </driver>
                    </drivers>
                </datasources>
            </subsystem>

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

Discussions similaires

  1. Problème dans NetBeans avec le fichier persistence.xml
    Par egondragon dans le forum NetBeans
    Réponses: 0
    Dernier message: 01/09/2011, 11h47
  2. Problème de création de fichier XML
    Par libery dans le forum C#
    Réponses: 1
    Dernier message: 12/06/2009, 19h43
  3. Problème de création de fichier XML
    Par TheReturnOfMuton dans le forum VB 6 et antérieur
    Réponses: 2
    Dernier message: 14/12/2007, 13h56
  4. Problème de création de fichier
    Par dani22 dans le forum Langage
    Réponses: 4
    Dernier message: 18/10/2006, 17h50
  5. [Delphi 2005] Débutant avec problème de création de fichier
    Par Patcdc dans le forum Bases de données
    Réponses: 2
    Dernier message: 06/06/2005, 18h41

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