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

Wildfly/JBoss Java Discussion :

Problème DataSource getConnection dans JBoss-4.2.0.GA


Sujet :

Wildfly/JBoss Java

  1. #1
    Candidat au Club
    Profil pro
    Inscrit en
    Mai 2007
    Messages
    3
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2007
    Messages : 3
    Points : 2
    Points
    2
    Par défaut Problème DataSource getConnection dans JBoss-4.2.0.GA
    Bonjour,

    J'essaye de migrer une application J2EE qui fonctionne très bien sur un JBoss 3.2.7 et 4.0.5 vers un JBoss 4.2.0.GA.

    Sur Jboss 4.2.0.GA l'appel à dataSource.getConnection() comme dans le code suivant :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    private Connection getConnection(){
       Connection conn = null;
       try {
          Context ctx = new InitialContext();
          DataSource dataSource = (DataSource)ctx.lookup("java:/jdbc/Administration");
          conn = dataSource.getConnection();
          if(logger.isTraceEnabled()){
             logger.trace("Recuperation de la connection java:/jdbc/Administration");
          }
       }catch(Exception e) {
          throw new EJBException(e);
       }
       return conn;
    }
    provoque invariablement l'exception suivante :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    java.rmi.ServerException: EJBException:; nested exception is: 
    	javax.ejb.EJBException: org.jboss.util.NestedSQLException: Could not enlist in transaction on entering meta-aware object!; - nested throwable: (javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous warnings. tx=TransactionImple < ac, BasicAction: -53effaf0:8ac:465ed728:98 status: ActionStatus.ABORT_ONLY >); - nested throwable: (org.jboss.resource.JBossResourceException: Could not enlist in transaction on entering meta-aware object!; - nested throwable: (javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous warnings. tx=TransactionImple < ac, BasicAction: -53effaf0:8ac:465ed728:98 status: ActionStatus.ABORT_ONLY >))
    	at org.jboss.ejb.plugins.LogInterceptor.handleException(LogInterceptor.java:365)
    	at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:209)
    	at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:138)
    	at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:648)
    	at org.jboss.ejb.Container.invoke(Container.java:960)
    Les datasources utilisés sont déclarés dans le fichier postgres-ds.xml

    Est-ce que quelqu'un a une idée ou a rencontré le même problème?
    D'avance merci.

  2. #2
    Membre éclairé Avatar de XmasRock
    Inscrit en
    Janvier 2007
    Messages
    729
    Détails du profil
    Informations forums :
    Inscription : Janvier 2007
    Messages : 729
    Points : 821
    Points
    821
    Par défaut
    montres nous le contenu de ton fichier postgres-de.xml.
    Quelle est la valeur de l'attribut de transaction de ton EJB ?

  3. #3
    Candidat au Club
    Profil pro
    Inscrit en
    Mai 2007
    Messages
    3
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2007
    Messages : 3
    Points : 2
    Points
    2
    Par défaut
    Merci pour la réponse si rapide,

    Voila le contenu du fichier postgres-ds.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
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    <?xml version="1.0" encoding="UTF-8"?>
    <!-- edited with XMLSPY v2004 rel. 3 U (http://www.xmlspy.com) by Bertrand Cedric (POLYMEDIS S.A.) -->
    <!-- ===================================================================== -->
    <!--                                                                       -->
    <!--  JBoss Server Configuration                                           -->
    <!--                                                                       -->
    <!-- ===================================================================== -->
    <!-- $Id: postgres-ds.xml,v 1.1 2002/07/22 22:57:24 d_jencks Exp $ -->
    <!-- ==================================================================== -->
    <!--  Datasource config for Postgres                                      -->
    <!-- ==================================================================== -->
    <datasources>
    	<local-tx-datasource>
    		<jndi-name>jdbc/Jboss</jndi-name>
    		<connection-url>jdbc:postgresql://db:5432/jboss</connection-url>
    		<driver-class>org.postgresql.Driver</driver-class>
    		<user-name>arthur</user-name>
    		<password>dev</password>
    		<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
    	</local-tx-datasource>
    	<local-tx-datasource>
    		<jndi-name>jdbc/Administration</jndi-name>
    		<connection-url>jdbc:postgresql://db:5432/administration</connection-url>
    		<driver-class>org.postgresql.Driver</driver-class>
    		<user-name>arthur</user-name>
    		<password>dev</password>
    	</local-tx-datasource>
    	<local-tx-datasource>
    		<jndi-name>jdbc/View</jndi-name>
    		<connection-url>jdbc:postgresql://db:5432/view</connection-url>
    		<driver-class>org.postgresql.Driver</driver-class>
    		<user-name>arthur</user-name>
    		<password>dev</password>
    	</local-tx-datasource>
    	<local-tx-datasource>
    		<jndi-name>jdbc/Pid</jndi-name>
    		<connection-url>jdbc:postgresql://db:5432/pid</connection-url>
    		<driver-class>org.postgresql.Driver</driver-class>
    		<user-name>arthur</user-name>
    		<password>dev</password>
    	</local-tx-datasource>
    	<local-tx-datasource>
    		<jndi-name>jdbc/Documents</jndi-name>
    		<connection-url>jdbc:postgresql://db:5432/documents</connection-url>
    		<driver-class>org.postgresql.Driver</driver-class>
    		<user-name>arthur</user-name>
    		<password>dev</password>
    	</local-tx-datasource>
    	<local-tx-datasource>
    		<jndi-name>jdbc/IheDB</jndi-name>
    		<connection-url>jdbc:postgresql://db:5432/ihedb</connection-url>
    		<driver-class>org.postgresql.Driver</driver-class>
    		<user-name>arthur</user-name>
    		<password>dev</password>
    	</local-tx-datasource>
    </datasources>
    Voici la déclaration dans ejb-jar.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
    <session >
             <description><![CDATA[]]></description>
             <display-name>DictionaryManager</display-name>
     
             <ejb-name>DictionaryManager</ejb-name>
     
             <home>ehcr_application.ejb.session.dictionary.DictionaryManagerHome</home>
             <remote>ehcr_application.ejb.session.dictionary.DictionaryManager</remote>
             <local-home>ehcr_application.ejb.session.dictionary.DictionaryManagerLocalHome</local-home>
             <local>ehcr_application.ejb.session.dictionary.DictionaryManagerLocal</local>
             <ejb-class>ehcr_application.ejb.session.dictionary.DictionaryManagerBean</ejb-class>
             <session-type>Stateless</session-type>
             <transaction-type>Container</transaction-type>
     
             <resource-ref >
                <res-ref-name>jdbc/Administration</res-ref-name>
                <res-type>javax.sql.DataSource</res-type>
                <res-auth>Container</res-auth>
             </resource-ref>
     
          </session>
    Voici la déclaration dans jboss.xml
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    <session>
             <ejb-name>DictionaryManager</ejb-name>
             <jndi-name>ejb/session/DictionaryManager</jndi-name>
             <local-jndi-name>DictionaryManagerLocal</local-jndi-name>
     
            <method-attributes>
            </method-attributes>
          </session>
    Le type de transaction est donc celui par défault donc si je ne m'abuse "Required".

    A noter également que j'ai des entityBean qui eux fonctionne sans erreur.

    Voilà j'espère avoir répondu correctement.
    Et encore merci

  4. #4
    Membre éclairé Avatar de XmasRock
    Inscrit en
    Janvier 2007
    Messages
    729
    Détails du profil
    Informations forums :
    Inscription : Janvier 2007
    Messages : 729
    Points : 821
    Points
    821
    Par défaut
    est-ce que dans ton code tu tentes de récuperer des connexions à plusieurs bases de données qui pourrait faire croire au TxManager que la transaction devrait etre distribuée ?
    Ainsi, comme elles ne sont pas déclarées XA (seulement <local-tx-datasource>) le TXManager râle.

    Il faudrait :
    1) soit tu as un vrai besoin de transaction distribuee et il faudrait que tu declares tes datasources en consequence ;
    2) soint tu n'as pas ce besoin et ton EJB session ne devrait pas demander de contexte transactionnel (attribut de transaction "NotSupported" par exemple)

  5. #5
    Candidat au Club
    Profil pro
    Inscrit en
    Mai 2007
    Messages
    3
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2007
    Messages : 3
    Points : 2
    Points
    2
    Par défaut
    Grand merci pour la solution;
    C'est en effet le problème, j'ai besoin de transactions distribuées puisque dans une même transaction j'accède à différents datasources. J'ai donc changé mon fichier postgres-ds.xml en postgres-xa-ds.xml comme ci-après:
    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
    <!-- ===================================================================== -->
    <!--                                                                       -->
    <!--  JBoss Server Configuration                                           -->
    <!--                                                                       -->
    <!-- ===================================================================== -->
    <!-- $Id: postgres-xa-ds.xml,v 1.1 2002/07/22 22:57:24 d_jencks Exp $ -->
    <!-- ==================================================================== -->
    <!--  Datasource config for Postgres with XA support                                      -->
    <!-- ==================================================================== -->
    <datasources>
    	<xa-datasource>
    		  <jndi-name>jdbc/Jboss</jndi-name> 
    		  <track-connection-by-tx /> 
    		  <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class> 
    		  <xa-datasource-property name="ServerName">db</xa-datasource-property> 
    		  <!--  <xa-datasource-property name="PortNumber">5432</xa-datasource-property> --> 
    		  <xa-datasource-property name="DatabaseName">jboss</xa-datasource-property> 
    		  <xa-datasource-property name="User">arthur</xa-datasource-property> 
    		  <xa-datasource-property name="Password">dev</xa-datasource-property> 
    		 <!--  corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) --> 
    		 <metadata>
    		  <type-mapping>PostgreSQL 8.0</type-mapping> 
    		  </metadata>
    	  </xa-datasource>
    	<xa-datasource>
    		  <jndi-name>jdbc/Administration</jndi-name> 
    		  <track-connection-by-tx /> 
    		  <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class> 
    		  <xa-datasource-property name="ServerName">db</xa-datasource-property> 
    		 <!--  <xa-datasource-property name="PortNumber">5432</xa-datasource-property> --> 
    		  <xa-datasource-property name="DatabaseName">administration</xa-datasource-property> 
    		  <xa-datasource-property name="User">arthur</xa-datasource-property> 
    		  <xa-datasource-property name="Password">dev</xa-datasource-property> 
    		 <!--  corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) --> 
    		 <metadata>
    		  <type-mapping>PostgreSQL 8.0</type-mapping> 
    		  </metadata>
    	  </xa-datasource>
    	 <xa-datasource>
    		  <jndi-name>jdbc/View</jndi-name> 
    		  <track-connection-by-tx /> 
    		  <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class> 
    		  <xa-datasource-property name="ServerName">db</xa-datasource-property> 
    		 <!--  <xa-datasource-property name="PortNumber">5432</xa-datasource-property> --> 
    		  <xa-datasource-property name="DatabaseName">view</xa-datasource-property> 
    		  <xa-datasource-property name="User">arthur</xa-datasource-property> 
    		  <xa-datasource-property name="Password">dev</xa-datasource-property> 
    		 <!--  corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) --> 
    		 <metadata>
    		  <type-mapping>PostgreSQL 8.0</type-mapping> 
    		  </metadata>
    	  </xa-datasource>
    	- <xa-datasource>
    		  <jndi-name>jdbc/Pid</jndi-name> 
    		  <track-connection-by-tx /> 
    		  <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class> 
    		  <xa-datasource-property name="ServerName">db</xa-datasource-property> 
    		 <!--  <xa-datasource-property name="PortNumber">5432</xa-datasource-property> --> 
    		  <xa-datasource-property name="DatabaseName">pid</xa-datasource-property> 
    		  <xa-datasource-property name="User">arthur</xa-datasource-property> 
    		  <xa-datasource-property name="Password">dev</xa-datasource-property> 
    		 <!--  corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) --> 
    		 <metadata>
    		  <type-mapping>PostgreSQL 8.0</type-mapping> 
    		  </metadata>
    	  </xa-datasource>
    	 <xa-datasource>
    		  <jndi-name>jdbc/Documents</jndi-name> 
    		  <track-connection-by-tx /> 
    		  <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class> 
    		  <xa-datasource-property name="ServerName">db</xa-datasource-property> 
    		 <!--  <xa-datasource-property name="PortNumber">5432</xa-datasource-property> --> 
    		  <xa-datasource-property name="DatabaseName">documents</xa-datasource-property> 
    		  <xa-datasource-property name="User">arthur</xa-datasource-property> 
    		  <xa-datasource-property name="Password">dev</xa-datasource-property> 
    		 <!--  corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) --> 
    		 <metadata>
    		  <type-mapping>PostgreSQL 8.0</type-mapping> 
    		  </metadata>
    	  </xa-datasource>
    	 <xa-datasource>
    		  <jndi-name>jdbc/IheDB</jndi-name> 
    		  <track-connection-by-tx /> 
    		  <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class> 
    		  <xa-datasource-property name="ServerName">db</xa-datasource-property> 
    		 <!--  <xa-datasource-property name="PortNumber">5432</xa-datasource-property> --> 
    		  <xa-datasource-property name="DatabaseName">ihedb</xa-datasource-property> 
    		  <xa-datasource-property name="User">arthur</xa-datasource-property> 
    		  <xa-datasource-property name="Password">dev</xa-datasource-property> 
    		 <!--  corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) --> 
    		 <metadata>
    		  <type-mapping>PostgreSQL 8.0</type-mapping> 
    		  </metadata>
    	  </xa-datasource>
      </datasources>
    Je n'ai plus l'erreur Could not enlist in transaction on entering meta-aware object sur le datasource.getConnection()

    Ca fonctionne. J'ai juste du changer la version d'une de mes DB qui n'acceptée pas les Xa datasource.

    Il me reste juste quelques warnings :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    10:48:34,843 WARN  [loggerI18N] [com.arjuna.ats.internal.jta.resources.arjunacore.norecoveryxa] [com.arjuna.ats.internal.jta.resources.arjunacore.norecoveryxa]
    Could not find new XAResource to use for recovering non-serializable XAResource < 131075, 28, 26, 1--53effaf0:544:465fcca7:176-53effaf0:544:465fcca7:17a >
    10:48:34,859 WARN  [loggerI18N] [com.arjuna.ats.internal.jta.resources.arjunacore.norecoveryxa] [com.arjuna.ats.internal.jta.resources.arjunacore.norecoveryxa]
    Could not find new XAResource to use for recovering non-serializable XAResource < 131075, 27, 25, 1--53effaf0:5bc:465fd23b:72-53effaf0:5bc:465fd23b:76 >
    10:48:34,875 WARN  [loggerI18N] [com.arjuna.ats.internal.jta.resources.arjunacore.norecoveryxa] [com.arjuna.ats.internal.jta.resources.arjunacore.norecoveryxa]
    Could not find new XAResource to use for recovering non-serializable XAResource < 131075, 28, 26, 1--53effaf0:5bc:465fd23b:16b-53effaf0:5bc:465fd23b:16f >
    10:48:34,890 WARN  [loggerI18N] [com.arjuna.ats.internal.jta.resources.arjunacore.norecoveryxa] [com.arjuna.ats.internal.jta.resources.arjunacore.norecoveryxa]
    Could not find new XAResource to use for recovering non-serializable XAResource < 131075, 27, 25, 1--53effaf0:544:465fcca7:6f-53effaf0:544:465fcca7:73 >
    Faut-il que je m'en préocupe?
    Y a-t-il d'autres configurations à apporter pour éliminer ces warnings?

    En tout cas encore un grand merci pour l'aide.

  6. #6
    Membre du Club
    Profil pro
    Inscrit en
    Mai 2007
    Messages
    104
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2007
    Messages : 104
    Points : 52
    Points
    52
    Par défaut Problème identique avec JBoss 4.2.0GA et MySQL 4
    Mon application fonctionne correctement avec la datasource mysql suivante sous JBoss 4.0.0 mais génère la même erreur sous JBoss 4.2.0GA.

    myapp-ds.xml
    ---
    <?xml version="1.0" encoding="UTF-8"?>
    <!-- ==================================================================== -->
    <!-- Datasource config for MyApp -->
    <!-- ==================================================================== -->
    <datasources>
    <local-tx-datasource>
    <jndi-name>MyApp_RW_DS</jndi-name>
    <connection-url>jdbc:mysql://localhost/myApp</connection-url>
    <driver-class>org.gjt.mm.mysql.Driver</driver-class>
    <transaction-isolation>TRANSACTION_REPEATABLE_READ</transaction-isolation>
    <user-name>root</user-name>
    <password></password>
    <min-pool-size>20</min-pool-size>
    <max-pool-size>500</max-pool-size>
    </local-tx-datasource>

    <local-tx-datasource>
    <jndi-name>MyApp_RO_DS</jndi-name>
    <connection-url>jdbc:mysql://localhost/myApp</connection-url>
    <driver-class>org.gjt.mm.mysql.Driver</driver-class>
    <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
    <user-name>root</user-name>
    <password></password>
    <min-pool-size>20</min-pool-size>
    <max-pool-size>500</max-pool-size>
    </local-tx-datasource>
    </datasources>
    ---

    La base de donnée étant du MySQL 4 et celle-ci ne fonctionnant pas à priori en mode XA, y a t il un moyen de contournement ?

  7. #7
    Membre éclairé Avatar de XmasRock
    Inscrit en
    Janvier 2007
    Messages
    729
    Détails du profil
    Informations forums :
    Inscription : Janvier 2007
    Messages : 729
    Points : 821
    Points
    821
    Par défaut
    Blured,
    Ouvres ta propre discussion et expliques mieux ton problème STP.

  8. #8
    Membre confirmé
    Avatar de grishka
    Inscrit en
    Janvier 2003
    Messages
    285
    Détails du profil
    Informations forums :
    Inscription : Janvier 2003
    Messages : 285
    Points : 499
    Points
    499
    Par défaut
    je ressucite ce thread pour apporter une précision quant aux warning, vu que j'avais les mêmes : ils proviennent du module JTA Arjuna de Jboss qui tente de récupérer d'anciennes transactions à partir des logs suite à un crash.
    Cf https://issues.jboss.org/browse/JBTM-570

    Le plus simple est d'arrêter jboss, de supprimer le répertoire data/tx-object-store puis de redémarrer.
    "Les gens normaux croient que si ca marche, c'est qu'il n'y a rien à reparer. Les ingénieurs croient que si ca marche, c'est que ca ne fait pas encore assez de choses."
    --Scott Adams

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

Discussions similaires

  1. Connexion à une DataSource Postgresql dans JBoss 7.1.1
    Par lamipatterson dans le forum Wildfly/JBoss
    Réponses: 3
    Dernier message: 19/07/2014, 22h15
  2. Réponses: 1
    Dernier message: 05/05/2010, 16h28
  3. Problème déploiement EJB Entity dans JBoss
    Par anismouali dans le forum Java EE
    Réponses: 3
    Dernier message: 12/02/2010, 14h23
  4. Réponses: 0
    Dernier message: 26/02/2008, 21h10
  5. Réponses: 3
    Dernier message: 03/10/2007, 13h40

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