Nouveautés

JBoss AS T Datasource

EJB (EJB 3.0, EJB 3.1)

  • EJB 3.1: les nouveautés avec Java EE 6
    • Plus besoin d'interfaces locales ! @Stateless ou @Stateful
    • Le Singleton Bean et la concurrence d'accès : @Singleton @ReadOnly et @ReadWrite remplacées par @Lock(LockType.READ) et @Lock(LockType.WRITE). La concurrence d'accès peut être gérée soit par le container, soit par le développeur du bean (@BeanManagedConcurrency).
    • EJB Timer : @Schedule, avant on devait passer par l'interface javax.ejb.TimerService (@Resource TimerService et @Timeout)
    • Appels asynchrones : Avec les EJB 3.0, les appels asynchrones se font exclusivement via les Message Driven Beans et JMS, avec les EJB 3., les beans peuvent aussi être appelées de façon asynchrone @Asynchronous
    • EJB dans un WAR : Il n'est plus nécessaire de créer une archive JAR et une archive EAR, tout peut être contenu dans une unique archive WAR.
    • Support des stateful web services : Les EJB 3.0 supportent les stateless web services. Avec la version 3.1, les stateful web services seront aussi supportés. @WebService @Stateful ou @Stateless
  • EJB 3.0: les interceptors
12:04:06,276 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) Starting deployment of "Jboss7Ear.ear"
12:04:06,313 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) Starting deployment of "Jboss7Ejb.jar"
12:04:06,425 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-4) JNDI bindings for session bean named MySchedul in deployment unit subdeployment "Jboss7Ejb.jar" of deployment "Jboss7Ear.ear" are as follows:

	java:global/Jboss7Ear/Jboss7Ejb/MySchedul!com.placeoweb.MySchedul
	java:app/Jboss7Ejb/MySchedul!com.placeoweb.MySchedul
	java:module/MySchedul!com.placeoweb.MySchedul
	java:global/Jboss7Ear/Jboss7Ejb/MySchedul
	java:app/Jboss7Ejb/MySchedul
	java:module/MySchedul

12:04:06,838 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "Jboss7Ear.ear"

JBAS014120: Error invoking timeout for timer: timedObjectId=Jboss7Ear.Jboss7Ejb.MySchedul auto-timer?:true persistent?:true timerService=org.jboss.as.ejb3.timerservice.TimerServiceImpl@72845cd initialExpiration=Fri Dec 30 00:00:00 CET 2011 intervalDuration(in milli sec)=0 nextExpiration=Fri Dec 30 16:02:16 CET 2011 timerState=RETRY_TIMEOUT: javax.ejb.ConcurrentAccessTimeoutException: JBAS014373: EJB 3.1 PFD2 4.8.5.5.1 concurrent access timeout on org.jboss.invocation.InterceptorContext$Invocation@1d783350 - could not obtain lock within 5000MILLISECONDS

EJB 3.1 18.2.5.3 entity bean class implemented TimedObject, but has a different timeout method specified either via annotations or via the deployment descriptor


16:15:59,029 ERROR [org.jboss.as.ejb3] (pool-9-thread-5) JBAS014120: Error invoking timeout for timer: [id=510f1e85-23ac-4042-838d-df39795066d8 timedObjectId=Jboss7Ear.Jboss7Ejb.TimerSessionBean auto-timer?:true persistent?:true timerService=org.jboss.as.ejb3.timerservice.TimerServiceImpl@59795b39 initialExpiration=Fri Dec 30 00:00:00 CET 2011 intervalDuration(in milli sec)=0 nextExpiration=Fri Dec 30 16:16:00 CET 2011 timerState=IN_TIMEOUT: javax.ejb.ConcurrentAccessTimeoutException: JBAS014373: EJB 3.1 PFD2 4.8.5.5.1 concurrent access timeout on org.jboss.invocation.InterceptorContext$Invocation@722a4dfd - could not obtain lock within 5000MILLISECONDS
	at org.jboss.as.ejb3.concurrency.ContainerManagedConcurrencyInterceptor.processInvocation(ContainerManagedConcurrencyInterceptor.java:101) [jboss-as-ejb3-7.1.0.CR1b.jar:7.1.0.CR1b]
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
	at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
	at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
	at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53) [jboss-as-ee-7.1.0.CR1b.jar:7.1.0.CR1b]
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
	at org.jboss.as.ejb3.component.singleton.SingletonComponentInstanceAssociationInterceptor.processInvocation(SingletonComponentInstanceAssociationInterceptor.java:53) [jboss-as-ejb3-7.1.0.CR1b.jar:7.1.0.CR1b]
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
	at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:228) [jboss-as-ejb3-7.1.0.CR1b.jar:7.1.0.CR1b]
	at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:304) [jboss-as-ejb3-7.1.0.CR1b.jar:7.1.0.CR1b]
	at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:190) [jboss-as-ejb3-7.1.0.CR1b.jar:7.1.0.CR1b]
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
	at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) [jboss-as-ejb3-7.1.0.CR1b.jar:7.1.0.CR1b]
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
	at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50) [jboss-as-ee-7.1.0.CR1b.jar:7.1.0.CR1b]
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
	at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45) [jboss-as-ee-7.1.0.CR1b.jar:7.1.0.CR1b]
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
	at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
	at org.jboss.as.ejb3.timerservice.TimedObjectInvokerImpl.callTimeout(TimedObjectInvokerImpl.java:101) [jboss-as-ejb3-7.1.0.CR1b.jar:7.1.0.CR1b]
	at org.jboss.as.ejb3.timerservice.task.CalendarTimerTask.callTimeout(CalendarTimerTask.java:60) [jboss-as-ejb3-7.1.0.CR1b.jar:7.1.0.CR1b]
	at org.jboss.as.ejb3.timerservice.task.TimerTask.run(TimerTask.java:126) [jboss-as-ejb3-7.1.0.CR1b.jar:7.1.0.CR1b]
	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [:1.7.0_02]
	at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) [:1.7.0_02]
	at java.util.concurrent.FutureTask.run(Unknown Source) [:1.7.0_02]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [:1.7.0_02]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [:1.7.0_02]
	at java.lang.Thread.run(Unknown Source) [:1.7.0_02]
	at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.0.0.GA.jar:2.0.0.GA]

16:15:59,033 INFO  [org.jboss.as.ejb3] (pool-9-thread-5) JBAS014121: Timer: [id=510f1e85-23ac-4042-838d-df39795066d8 timedObjectId=Jboss7Ear.Jboss7Ejb.TimerSessionBean auto-timer?:true persistent?:true timerService=org.jboss.as.ejb3.timerservice.TimerServiceImpl@59795b39 initialExpiration=Fri Dec 30 00:00:00 CET 2011 intervalDuration(in milli sec)=0 nextExpiration=Fri Dec 30 16:16:00 CET 2011 timerState=IN_TIMEOUT will be retried
16:15:59,033 INFO  [org.jboss.as.ejb3] (pool-9-thread-5) JBAS014123: Retrying timeout for timer: [id=510f1e85-23ac-4042-838d-df39795066d8 timedObjectId=Jboss7Ear.Jboss7Ejb.TimerSessionBean auto-timer?:true persistent?:true timerService=org.jboss.as.ejb3.timerservice.TimerServiceImpl@59795b39 initialExpiration=Fri Dec 30 00:00:00 CET 2011 intervalDuration(in milli sec)=0 nextExpiration=Fri Dec 30 16:16:00 CET 2011 timerState=IN_TIMEOUT
  • Why is JBoss AS 7 so fast?
  • JBoss AS 7: Catching up with Java EE 6
    • Avec quelques modifications mineures, j'ai été en mesure de déployer le même WAR sur JBoss AS 7 et de répéter les mesures que j'ai fait pour JBoss AS 6.
    • Mais la performance n'est pas le seul facteur qui compte. La documentation continue d'être schématique et bien en dessous du niveau de JBoss AS 5.
    • JBoss AS 7 est plus que compensé par les fuites classloader problèmes de productivité d'intégration d'Eclipse et le manque de soutien pour les fournisseurs JPA autre que Hibernate

Boot

12:39:25,395 Infos [org.jboss.modules] JBoss Modules version 1.1.0.CR6
12:39:26,373 INFO  [org.jboss.msc] JBoss MSC version 1.0.1.GA
12:39:26,448 INFO  [org.jboss.as] JBoss AS 7.1.0.CR1b "Flux Capacitor" starting
12:39:28,593 INFO  [org.jboss.as] Creating http management service using  socket-binding (management-http)
12:39:28,595 INFO  [org.xnio] XNIO Version 3.0.0.CR7
12:39:28,632 INFO  [org.xnio.nio] XNIO NIO Implementation Version 3.0.0.CR7
12:39:28,661 INFO  [org.jboss.remoting] JBoss Remoting version 3.2.0.CR8
12:39:28,684 INFO  [org.jboss.as.clustering] JBAS010300: Activating Infinispan subsystem.
12:39:28,720 INFO  [org.jboss.as.security] Activating Security Subsystem
12:39:28,727 INFO  [org.jboss.as.logging] JBAS011502: Removing bootstrap log handlers
12:39:28,742 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 38) JBAS011800: Activating Naming Subsystem
12:39:28,746 INFO  [org.jboss.as.security] (MSC service thread 1-4) Picketbox version=4.0.6.Beta2
12:39:28,756 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension
12:39:28,771 INFO  [org.jboss.as.osgi] (ServerService Thread Pool -- 39) JBAS011910: Activating OSGi Subsystem
12:39:28,808 INFO  [org.jboss.as.connector] (MSC service thread 1-6) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.6.Final)
12:39:29,176 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 26) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
12:39:29,185 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 26) JBAS010404: Deploying non-JDBC-compliant driver class com.mysql.jdbc.Driver (version 5.1)
12:39:30,170 INFO  [org.jboss.as.naming] (MSC service thread 1-6) JBAS011802: Starting Naming Service
12:39:30,180 INFO  [org.jboss.as.jaxr] (MSC service thread 1-6) Binding JAXR ConnectionFactory: java:jboss/jaxr/ConnectionFactory
12:39:30,213 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-3) JBAS015400: Bound mail session [java:jboss/mail/Default]
12:39:30,530 INFO  [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-7) JBoss Web Services - Stack CXF Server 4.0.0.GA
12:39:31,041 INFO  [org.jboss.as.remoting] (MSC service thread 1-3) Listening on /127.0.0.1:4447
12:39:31,372 INFO  [org.apache.coyote.http11.Http11AprProtocol] (MSC service thread 1-8) Démarrage de Coyote HTTP/1.1 sur http--127.0.0.1-8080
12:39:31,463 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-6) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
12:39:31,493 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-2) JBAS015012: Started FileSystemDeploymentService for directory C:\jboss-as-7.1.0.CR1b\standalone\deployments
12:39:31,500 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found Jboss7Ear.ear in deployment directory. To trigger deployment create a file called Jboss7Ear.ear.dodeploy
12:39:31,882 INFO  [org.jboss.as] (MSC service thread 1-6) JBoss AS 7.1.0.CR1b "Flux Capacitor" started in 7216ms - Started 162 of 239 services (70 services are passive or on-demand)

Télécharger Jboss 7

Page des téléchargement de JBoss Application Server

EAP 6.3.0 GA 	EAP built from AS 7.4 	2014-8-6 	LGPL 	ZIP (151MB)
EAP 6.2.0 GA 	EAP built from AS 7.3 	2013-12-4 	LGPL 	ZIP (144MB)
EAP 6.1.0 GA 	EAP built from AS 7.2 	2013-05-20 	LGPL 	ZIP (110MB)
JBoss AS 7.1.1.Final 	AS Certified Java EE 6 Full Profile 	2012-03-09 	LGPL 	ZIP (127MB)
JBoss AS 7.1.0.Final 	AS Certified Java EE 6 Full Profile 	2012-02-16 	LGPL 	ZIP (100MB)
7.0.2.Final	Arc	Web Profile Only (Java EE6 Certified)	68 MB	2011-09-22	LGPL
		Web Profile Only (Java EE6 Certified)	68 MB	2011-09-22	LGPL
		Everything (NOT Java EE6 Certified)	75MB	2011-09-22	LGPL
		Everything (NOT Java EE6 Certified)	75MB	2011-09-22	LGPL
		Quick Starts	109 KB	2011-07-12	ASL
7.0.1.Final	Zap	Web Profile Only (Java EE6 Certified)	68 MB	2011-08-17	LGPL
		Web Profile Only (Java EE6 Certified)	68 MB	2011-08-17	LGPL
		Everything (NOT Java EE6 Certified)	74 MB	2011-08-17	LGPL
		Everything (NOT Java EE6 Certified)	74 MB	2011-08-17	LGPL
		Quick Starts	109 KB	2011-07-12	ASL
7.0.0.Final	Lightning	Web Profile Only (Java EE6 Certified)	66 MB	2011-07-12	LGPL
		Web Profile Only (Java EE6 Certified)	66 MB	2011-07-12	LGPL
		Everything (NOT Java EE6 Certified)	72 MB	2011-07-12	LGPL
		Everything (NOT Java EE6 Certified)	72 MB	2011-07-12	LGPL
		Quick Starts	109 KB	2011-07-12	LGPL

Jboss AS 7 tourne avec Java 6. Java 7 peut être utilisé avec JBoss AS 7.

L'administration par défaut

Plus d'Admin Console, ni de JBossWS, ni de JMX Agent View (JMX Console), il ne reste plus qu'une console : l'Administration Console

Eclipse 3.6 (helios) & Jboss 6

Server Adapter Jboss 6 pour Eclipse

Eclipse, pour Jboss 6, ne fournit pas par défaut et ne propose pas non plus dans sa liste "Server Adapters" d'adaptateur Jboss 6 de pour lancer Jboss depuis Eclipse

Pour rajouter un server adapter, utiliser la procédure suivante :

  1. Lancer Eclipse.
  2. Sélectionner menu: File | New | Other
  3. Développez le dossier "Server", Sélectionner "Server" et appuyer sur le boutton "Next".
  4. Cliquer sur le lien "Download additional server adapters".
  5. Sélectionner l'adaptateur de serveur dont vous avez besoin et appuyer sur le boutton "Next".
  6. Lire et accepter l'accord de licence et appuyer sur le bouton "Finish".
  7. Relancer Eclipse.

Ressources :

Jboss est en écoute seulement sur l'interface local

Il faut rajouter l'option "-b" au lancement de Jboss :

./run.sh -c default -b 0.0.0.0

Que ce soit sous linux ou sous windows, JBoss AS démarre en se liant à toutes les interfaces réseau. C'est ce qu'il est possible de voir dans les logs de démarrage lorsqu'au lieu de l'adresse IP il affiche "0.0.0.0" . C'est pour ça qu'en utilisant la commande "run.sh -b 0.0.0.0" on obtiens le même résultat.

Si ça ne marche pas ---> il faut aller voir celui qui administre la machine. La plupart du temps il y a plusieurs carte réseaux et seulement une partie est visible. Il faudra démarrer JBoss AS en précisant cette interface avec la commande ci-dessus et en remplaçant "0.0.0.0" par l'adresse IP visible.

Attention : l'option "-B" permet de spécifier un répertoire où aller chercher les librairies nécessaires au démarrage de JBoss AS. Rien à voir donc avec l'option "-b" qui permet de spécifier l'interface réseau (l'adresse IP) sur laquelle JBoss AS doit écouter. Merci à developpez.net pour la solution.

Pensez a rajouter l'option dans le script de démarrage : /etc/init.d/jboss

JBOSSSH=${JBOSSSH:-"$JBOSS_HOME/bin/run.sh -c $JBOSS_LVL -b 0.0.0.0"}

Jboss est en écoute seulement sur le port par défaut 8080

Changer ou ajouter un port d'écoute tel que le port 80

jboss-6.0.0.Final/server/default/deploy/jbossweb.sar/server.xml :

<Service name="jboss.web">
 
      <!-- A HTTP/1.1 Connector on port 8080 -->
      <Connector protocol="HTTP/1.1" port="${jboss.web.http.port}" address="${jboss.bind.address}" 
         redirectPort="${jboss.web.https.port}" />
 
      <!-- Add this option to the connector to avoid problems with 
          .NET clients that don't implement HTTP/1.1 correctly 
         restrictedUserAgents="^.*MS Web Services Client Protocol 1.1.4322.*$"
      -->	
 
      <!-- Ajout d'un connecteur sur le port web standard, le port 80 -->
      <!-- A HTTP/1.1 Connector on port 80 -->
      <Connector protocol="HTTP/1.1" port="80" address="${jboss.bind.address}" 
         redirectPort="${jboss.web.https.port}" />

Puisque Jboss réponds sur toutes les interfaces, il faut bloquer l'accès anonyme à l'administration.

jmx-console http://localhost:8080/jmx-console/

Activation de l'authentification pour bloquer l'accès à la jmx-console pour les utilisateurs anonymes et non identifiés

C:\jboss-6.0.0.Final\common\deploy\jmx-console.war\WEB-INF\web.xml :

<!-- A security constraint that restricts access to the HTML JMX console
   to users with the role JBossAdmin. Edit the roles to what you want and
   uncomment the WEB-INF/jboss-web.xml/security-domain element to enable
   secured access to the HTML JMX console.
   -->
   <security-constraint>
     <web-resource-collection>
       <web-resource-name>HtmlAdaptor</web-resource-name>
       <description>An example security config that only allows users with the
         role JBossAdmin to access the HTML JMX console web application
       </description>
       <url-pattern>/*</url-pattern>
     </web-resource-collection>
     <auth-constraint>
       <role-name>JBossAdmin</role-name>
     </auth-constraint>
   </security-constraint>
   <!-- -->

C:\jboss-6.0.0.Final\common\deploy\jmx-console.war\WEB-INF\jboss-web.xml :

<!DOCTYPE jboss-web PUBLIC
   "-//JBoss//DTD Web Application 5.0//EN"
   "http://www.jboss.org/j2ee/dtd/jboss-web_5_0.dtd">
 
<jboss-web>
   <!-- Uncomment the security-domain to enable security. You will
      need to edit the htmladaptor login configuration to setup the
      login modules used to authentication users.
   -->
      <security-domain>java:/jaas/jmx-console</security-domain>
   <!-- -->
</jboss-web>

Changement du mot de passe pour la jmx-console et de l'admin-console

jboss-6.0.0.Final/server/default/conf/props/jmx-console-users.properties :

# A sample users.properties file for use with the UsersRolesLoginModule
#admin=admin
admin=newPassword
#http://community.jboss.org/wiki/DIGESTAuth
#[starksm@banshee9100 security]$ java -cp $JBOSS_HOME/server/default/lib/jbosssx.jar org.jboss.security.auth.spi.RFC2617Digest admin2 "JBoss JMX Console" admin2
# with JBoss AS 6.x: java -cp $JBOSS_HOME/common/lib/jbosssx-server.jar org.jboss.security.auth.spi.RFC2617Digest admin2 "JBoss JMX Console" admin2
admin2=a28c9ab431e878852135eac336fb0968

Relance du serveur pour recharger les paramètres de sécurité

Maintenant, si vous relancer votre serveur Jboss, les accès à la jmx-console et de l'admin-console seront identifiés avec ce nouveau mot de passe.

Voir aussi les ressources Jboss :

Jboss ROOT, changer la page d'accueil par défaut de Jboss

Voyez le post modification du context root de Jboss pour changer la page accueil

Ejb3 entity, erreurs à ne pas commettre :

  • nommer son fichier à la française : persistance.xml à la place de persistence.xml
  • recopier le fichier persistence.xml depuis le web à la place de le copier depuis les exemples fournis dans la documentation de jboss-6.0.0.Final/docs/examples/jca/mysql-ds.xml

Manager de transaction (JTA)

L'accès a plusieurs ressources dans une seule transaction n'est plus autorisé par défaut par le nouveau manager de transaction. Si vous obtenez un message :

[com.arjuna.ats.arjuna] ARJUNA-12140 Adding multiple last resources is disallowed. Current resource is com.arjuna.ats.internal.arjuna.abstractrecords.LastResourceRecord@de988a
[org.hibernate.util.JDBCExceptionReporter] 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: 0:ffffac141eca:126a:4d235506:156d 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: 0:ffffac141eca:126a:4d235506:156d status: ActionStatus.ABORT_ONLY >))
[org.hibernate.event.def.DefaultLoadEventListener] Error performing load command: org.hibernate.exception.GenericJDBCException: Cannot open connection

Éditez le fichier C:\jboss-6.0.0.Final\server\default\deploy\transaction-jboss-beans.xml et ajoutez la propriété "com.arjuna.ats.jta.allowMultipleLastResources" avec la valeur "true":

<bean name="CoreEnvironmentBean" class="com.arjuna.ats.arjuna.common.CoreEnvironmentBean">
 
        <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.jta:name=CoreEnvironmentBean", exposedInterface=com.arjuna.ats.arjuna.common.CoreEnvironmentBeanMBean.class, registerDirectly=true)</annotation>
 
        <constructor factoryClass="com.arjuna.ats.arjuna.common.arjPropertyManager" factoryMethod="getCoreEnvironmentBean"/>
 
<!-- AJOUT -->
<!-- http://localhost:8080/jmx-console/HtmlAdaptor?action=inspectMBean&name=jboss.jta%3Aname%3DCoreEnvironmentBean -->
		<property name="allowMultipleLastResources">true</property>
<!-- 
WARN  [com.arjuna.ats.arjuna] ARJUNA-12142 You have chosen to enable multiple last resources in the transaction manager. This is transactionally unsafe and should not be relied upon.
WARN  [com.arjuna.ats.arjuna] ARJUNA-12141 Multiple last resources have been added to the current transaction. This is transactionally unsafe and should not be relied upon. Current resource is com.arjuna.ats.internal.arjuna.abstractrecords.LastResourceRecord@1b9497f
WARN  [com.arjuna.ats.arjuna] ARJUNA-12141 Multiple last resources have been added to the current transaction. This is transactionally unsafe and should not be relied upon. Current resource is com.arjuna.ats.internal.arjuna.abstractrecords.LastResourceRecord@d35cfe
WARN  [com.arjuna.ats.arjuna] ARJUNA-12141 Multiple last resources have been added to the current transaction. This is transactionally unsafe and should not be relied upon. Current resource is com.arjuna.ats.internal.arjuna.abstractrecords.LastResourceRecord@10f436
WARN  [com.arjuna.ats.arjuna] ARJUNA-12141 Multiple last resources have been added to the current transaction. This is transactionally unsafe and should not be relied upon. Current resource is com.arjuna.ats.internal.arjuna.abstractrecords.LastResourceRecord@d35cfe
-->
<!--
		<property name="myFakePropertie">true</property>
Caused by: java.lang.IllegalArgumentException: No such property myNameIsFakir for bean com.arjuna.ats.arjuna.common.CoreEnvironmentBean available [socketProcessIdPort, nodeIdentifier, buildId, class, pid, processImplementation, disableMultipleLastResourcesWarning, varDir, allowMultipleLastResources, buildVersion, socketProcessIdMaxPorts]
-->

Puis consultez sur la jmx-console, le Bean : com.arjuna.ats.arjuna.common.CoreEnvironmentBean que l'argument allowMultipleLastResources est bien passé à true (false par défaut).

A l'utilisation vous aurrez le warning suivant :

WARN  [com.arjuna.ats.arjuna] ARJUNA-12141 Multiple last resources have been added to the current transaction. This is transactionally unsafe and should not be relied upon. Current resource is com.arjuna.ats.internal.arjuna.abstractrecords.LastResourceRecord@63a188

This is not a bug. You're trying to access multiple one phase resources in a single transaction. This was allowed with the old transaction manager, but it's not allowed in the new one. It is possible to set a property in the transaction service to allow multiple one phase resources, but that could lead to transaction problems. Better use two phase resources.

Les tâches planifiées (cron), avec Jboss il s'agit de scheduler (programmateur)

Le scheduler (cron) Jboss s'administre depuis ces 2 fichiers : jboss-6.0.0.Final/server/default/deploy/schedule-manager-service.xml jboss-6.0.0.Final/server/default/deploy/scheduler-service.xml

Vous pouvez également définir des taches programmées qui seront automatiquement déployées depuis votre programme lors de la publication de celui ci sur le serveur. Il faut ajouter dans le dossier META-INF de votre application un fichier de configuration pour Jboss : myscheduler-service.xml Voici un exemple de contenu du fichier META-INF/myscheduler-service.xml de votre programme :

<?xml version="1.0" encoding="UTF-8"?>
 <server>
 
         <!-- 
         7.1. org.jboss.varia.scheduler.Scheduler
 
 The Scheduler differs from the TimerMBean in that the Scheduler directly invokes a callback on
 an instance of a user defined class, or an operation of a user specified MBean.
 * InitialStartDate: Date when the initial call is scheduled. It can be either:
  * NOW: date will be the current time plus 1 seconds
  * A number representing the milliseconds since 1/1/1970
  * Date as String able to be parsed by SimpleDateFormat with default format pattern "M/d/yy
     h:mm a". If the date is in the past the Scheduler will search a start date in the future with
     respect to the initial repetitions and the period between calls. This means that when you
     restart the MBean (restarting JBoss etc.) it will start at the next scheduled time. When no
     start date is available in the future the Scheduler will not start.
  For example, if you start your Schedulable everyday at Noon and you restart your JBoss
  server then it will start at the next Noon (the same if started before Noon or the next day if
  start after Noon).
 * InitialRepetitions: The number of times the scheduler will invoke the target's callback. If -1
  then the callback will be repeated until the server is stopped.
 * StartAtStartup: A flag that determines if the Scheduler will start when it receives its
  startService life cycle notification. If true the Scheduler starts on its startup. If false, an
  explicit startSchedule operation must be invoked on the Scheduler to begin.
 * SchedulePeriod: The interval between scheduled calls in milliseconds. This value must be
  bigger than 0.  
            -->
 
         <!-- 
 http://docs.jboss.com/jbossas/javadoc/4.0.5/varia/org/jboss/varia/scheduler/Scheduler.html	  
 FixedRate : The default scheduling to use, fixed-rate or fixed-delay (false, default)
 
 void 	restartSchedule()
          Stops the server right now and starts it right now.
 void 	setDateFormat(String dateFormat)
          Sets the date format used to parse date/times
 void 	setFixedRate(boolean fixedRate)
          The default scheduling to use, fixed-rate or fixed-delay (false, default)
 void 	setInitialRepetitions(long pNumberOfCalls)
          Sets the initial number of scheduled calls.
 void 	setInitialStartDate(String pStartDate)
          Sets the first scheduled call.
 void 	setSchedulableArguments(String pArgumentList)
          The arguments to pass to the schedule
 void 	setSchedulableArgumentTypes(String pTypeList)
          Sets the comma seperated list of argument types for the Schedulable class.
 void 	setSchedulableClass(String pSchedulableClass)
          Sets the fully qualified Class name of the Schedulable Class being called by the Scheduler.
 void 	setSchedulableMBean(String pSchedulableMBean)
          Sets the fully qualified JMX MBean name of the Schedulable MBean to be called.
 void 	setSchedulableMBeanMethod(String pSchedulableMBeanMethod)
          Sets the method name to be called on the Schedulable MBean.
 void 	setSchedulePeriod(long pPeriod)
          Sets the Schedule Period between two scheduled call.
 void 	setStartAtStartup(boolean pStartAtStartup)
          Set the scheduler to start when MBean started or not.
 void 	setTimerName(String pTimerName)
          The JMX Timer to use (or create if not there) 
           -->
 
        <!-- Les temps
     1000 1 seconde
    30000 30 secondes
    60000 1 minute
   600000 10 minutes
  3600000 1 heure	   
 86400000 1 jour
          -->
 
        <!-- Test ->
        <!--  
    <mbean code="org.jboss.varia.scheduler.Scheduler"
           name="MonAppTest:service=Scheduler">
        <attribute name="StartAtStartup">true</attribute>
        <attribute name="SchedulableClass">com.placeoweb.schedul.Test</attribute>
        <attribute name="InitialStartDate">NOW</attribute>
        <attribute name="SchedulePeriod">10000</attribute>
        <attribute name="InitialRepetitions">-1</attribute>
        <attribute name="FixedRate">true</attribute>
    </mbean>
    --> 
 
        <!-- JBoss Scheduler avec la initial start date définie à une heure précise -->
        <!--  
    <mbean code="org.jboss.varia.scheduler.Scheduler" name="MyName:service=Scheduler">
        <attribute name="StartAtStartup">true</attribute>
        <attribute name="SchedulableClass">full.package.for.MySchedulableImpl</attribute>
        <attribute name="InitialStartDate">22/10/2009 11:30</attribute>
        <attribute name="DateFormat">dd/MM/yy HH:mm</attribute>
        <attribute name="SchedulePeriod">86400000</attribute>
        <attribute name="InitialRepetitions">-1</attribute>
    </mbean>
    -->
 
        <!-- JBoss Scheduler avec la initial start date définie à une heure précise -->
        <!--  
    <mbean code="org.jboss.varia.scheduler.Scheduler" name="MyName:service=Scheduler">
        <attribute name="StartAtStartup">true</attribute>
        <attribute name="SchedulableClass">full.package.for.MySchedulableImpl</attribute>
        <attribute name="InitialStartDate">22/10/2009 11:30</attribute>
        <attribute name="DateFormat">dd/MM/yy HH:mm</attribute>
        <attribute name="SchedulePeriod">86400000</attribute>
        <attribute name="InitialRepetitions">-1</attribute>
    </mbean>
    -->
 
 </server>

Et le programme à lancer :

package com.placeoweb.schedul;
 
import java.util.Date;
 
import org.jboss.logging.Logger;
import org.jboss.varia.scheduler.Schedulable;
 
/**
 * CRON - Taches automatisées
 *
 */
public class Test implements Schedulable {
 
	private final Logger logger = Logger.getLogger(this.getClass());
 
	public void perform(Date now, long remainingRepetitions) {
 
        logger.info("perform, now: " + now +
                ", remainingRepetitions: " + remainingRepetitions);
 
        System.out.println(this.getClass()+" SCHEDUL DEBUT "+new Date());
        try {
                MaClasse maClasse = new MaClasse();
                maClasse.lancer();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
        System.out.println(this.getClass()+" SCHEDUL FIN "+new Date());
 
	}
 
}

Ressources sur le scheduler Jboss

Variable d'environnement JBoss avec le système de gestion des Properties : SystemProperties

Une bonne solution pour configurer ses applications en dehors des fichiers de déploiement inclus dans les archives, est d'utiliser le PropertiesService avec un fichier de propriétés dédié à votre application pour lister les variables d'environnement.

Créer un fichier <nomApp>.properties dans le répertoire conf (JBOSS_HOME/default/conf par défaut) où tu liste les différentes variables d'environnement nécessaires à ton application sous la forme :

clé1=valeur1
clé2=valeur2

Puis modifier le fichier properties-service.xml (dans le répertoire où est deployé ton application JBOSS_HOME/default/deploy par exemple) : en ajoutant les lignes suivantes :


<!-- ==================================================================== -->
  <!-- System Properties Service                                            -->
  <!-- ==================================================================== -->
 
  <!--
     | Allows rich access to system properties.
   -->
 
  <mbean code="org.jboss.varia.property.SystemPropertiesService" 
	 name="jboss:type=Service,name=SystemProperties">
 
    <!-- 
       | Load properties from each of the given comma seperated URLs
 
    <attribute name="URLList">
      http://somehost/some-location.properties,
      ./conf/somelocal.properties
    </attribute>
 
    -->
 
    <attribute name="URLList">
      ./conf/<nomApp>.properties
    </attribute>

Vous pouvez ensuite accéder aux variables dans votre application :

System.getProperty("clé1");

Accéder à certificats (keyStore / trustStore)

Solution 1 : lancer la JVM avec les options ssl/certificats lors du lancement de Jboss

L'utilisation du System.setProperty("javax.net.ssl.keyStore","/monPath/maKeyStore") ne fonctionnant plus à la volée, et sans rajouter le certificat dans lib\security\cacerts de java (avec keytool -import), voici comment déclarer un autre keyStore dans Jboss6 (autrement qu'avec les variable de la JVM au lancement du serveur Jboss : -javax.net.ssl.keyStore="/monPath/maKeyStore" -Djavax.net.ssl.keyStoreType=pkcs12 -Djavax.net.ssl.keyStorePassword=secret

System.setProperty("javax.net.ssl.keyStore",keyStore);
		System.setProperty("javax.net.ssl.keyStoreType", keyStoreType);
		System.setProperty("javax.net.ssl.keyStorePassword", keyStorePassword);
//		Au besoin pour débuguer toutes les flux HTTPS ajoutez :
		System.setProperty("javax.net.debug", "all");

Solution 2 : configurer la sécurité dans le fichier jboss-6.0.0.Final\server\default\conf\bootstrap\security.xml

<!-- http://community.jboss.org/wiki/OverridingkeystoresandtruststoresinJBossAS -->
   <bean name="JBossSSLConfiguration" class="org.jboss.security.ssl.JBossSSLConfiguration">
      <property name="keyStoreURL">/home/mmoyses/my.keystore</property>
      <property name="keyStorePassword">changeit</property>
   </bean>

Et des liens sur les propriétés et SSL

Many Java applications that use SSL rely on the configuration of KeyStores. The default configuration is often based on VM properties such as javax.net.ssl.keyStore, javax.net.ssl.keyStorePassword, javax.net.ssl.keyStoreProvider and javax.net.ssl.trustStore.

Arrêter proprement le serveur

./shutdown.sh -S

ou

./shutdown.sh --shutdown

Sauf que si vous avez spécifier, un mot de passe pour votre console jmx, il faudra s'en servir avec les options -u (user) et -p (password) pour arrêter correctement votre serveur, sinon vous aurez le message :

Exception in thread "main" java.lang.SecurityException: Failed to authenticate principal=null, securityDomain=jmx-console

Pensez a rajouter l'option dans le script de d'arrêt : /etc/init.d/jboss

CMD_STOP="java -classpath $JBOSSCP org.jboss.Shutdown --shutdown -u admin -p votreMotDePasse"

Et si vous lancez Jboss6 depuis Eclipse, et que vous avez modifier le mot de passe, vous aurez l'erreur suivante ;

Exception in thread "main" java.lang.SecurityException: JMXConnectorAuthenticator requires userid/password credentials to be passed inconsulter

http://grepcode.com/file/repository.jboss.org/nexus/content/repositories/releases/org.jboss.jbossas/jboss-as-system/6.0.0.20100429-M3/org/jboss/system/server/jmx/JMXConnectorAuthenticator.java

Liens de configuration de l'arrêt de Jboss depuis Eclipse :

Pour ma part, C:\eclipse-jee-helios-win32\eclipse\plugins\org.eclipse.jst.server.generic.jboss_1.6.1.v200904151730\servers\jboss5.serverdef contient :

<stop>
		<mainClass>org.jboss.Shutdown</mainClass>
		<workingDirectory>${serverRootDirectory}/bin</workingDirectory>
		<programArguments>-S</programArguments>
		<vmParameters>-Djboss.boot.loader.name=shutdown.bat</vmParameters>
		<classpathReference>jboss.shutdown</classpathReference>
	</stop>

Alors que j'éteins le serveur comme ceci :

JAVAPTH="/APP/jre1.6.0_22/bin"
JBOSS_HOME=${JBOSS_HOME:-"/APP/jboss-4.2.3.GA-jdk6"}
JBOSSCP=${JBOSSCP:-"$JBOSS_HOME/bin/shutdown.jar:$JBOSS_HOME/client/jnet.jar"}
CMD_STOP="$JAVAPTH/java -classpath $JBOSSCP org.jboss.Shutdown --shutdown -u admin -p mySecretPass"

Ressources