......
<copy todir="${tmp}/META-INF/lib">
<fileset dir="${lib}" >
<exclude name="j2ee.jar" />
</fileset>
</copy>
<jar destfile="${build}/linuxmag.jar"
basedir="${tmp}"/>
jonas.service.dbm.datasources PostgreSQL1
$JONAS_ROOT/bin/unix/config_env
j'ajoute
POSTGRE_CLASSES=/usr/share/pgsql/pg73jdbc3.jar
bin/unix/jonas checkme dit:
The JOnAS environment seems correct.
$ cd $JONAS_ROOTEnsuite l'application est disponible à l'URL http://locahost:8088/snipsnap-0.5.1a/
$ bin/unix/jonas admin -a ~/distribs/snipsnap-0.5.1a.war
export JONAS_ROOT=/home/jmv/usr2/jonas-3-3-6Voilà ce que ça donne côté serveur :
jmv@protea:/home/jmv/usr2/jonas-3-3-6$ ./bin/unix/jonas admin \
-a $JBOSS_HOME/server/default/deploy/linuxmag.ear
jmv@protea:/home/jmv/usr2/jonas-3-3-6/bin/unix$ 2004-04-11 15:38:17,336 : EjbDeploymentDescManager.getDeploymentDescriptor : Cannot read the XML deployment descriptors for /home/jmv/usr2/jonas-3-3-6/apps/jonas/linuxmag_2004.04.11-10.47.02/linuxmag.jar:Accessoirement on remarque que la pile d'appel est beaucoup moins profonde qu'avec JBoss. Aparemment le linuxmag.jar ne lui plaît pas, mais côté console déploiement c'est plutôt ceci:
java.lang.NullPointerException
at java.util.zip.ZipFile.getInputStream(ZipFile.java:184)
at org.objectweb.jonas_ejb.deployment.lib.EjbDeploymentDescManager.getDeploymentDescriptor(EjbDeploymentDescManager.java:941)
at org.objectweb.jonas_ejb.deployment.lib.EjbDeploymentDescManager.loadDeploymentDesc(EjbDeploymentDescManager.java:335)
at org.objectweb.jonas_ejb.deployment.lib.EjbDeploymentDescManager.getDeploymentDesc(EjbDeploymentDescManager.java:236)
at org.objectweb.jonas.container.EJBServiceImpl.createContainer(EJBServiceImpl.java:488)
at org.objectweb.jonas.container.EJBServiceImpl.deployJars(EJBServiceImpl.java:1010)
at org.objectweb.jonas.ear.EarServiceImpl.deployEar(EarServiceImpl.java:813)
at org.objectweb.jonas.ear.EarServiceImpl.deployEarMBean(EarServiceImpl.java:926)
at org.objectweb.jonas.adm.Adm.addEar(Adm.java:250)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at org.objectweb.carol.rmi.jrmp.server.JUnicastServerRef.runDispatch(JUnicastServerRef.java:165)
at org.objectweb.carol.rmi.jrmp.server.JUnicastServerRef.dispatch(JUnicastServerRef.java:149)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:534)
2004-04-11 15:38:17,394 : EJBServiceImpl.createContainer : Cannot read the deployment descriptors '/home/jmv/usr2/jonas-3-3-6/apps/jonas/linuxmag_2004.04.11-10.47.02/linuxmag.jar': org.objectweb.jonas_ejb.deployment.api.DeploymentDescException: Cannot read the XML deployment descriptors for /home/jmv/usr2/jonas-3-3-6/apps/jonas/linuxmag_2004.04.11-10.47.02/linuxmag.jar:java.lang.NullPointerException
2004-04-11 15:38:17,402 : EJBServiceImpl.deployJars : Error when deploying '/home/jmv/usr2/jonas-3-3-6/apps/jonas/linuxmag_2004.04.11-10.47.02/linuxmag.jar'
2004-04-11 15:38:17,416 : EJBServiceImpl.deployJars : Cannot read the XML deployment descriptors for /home/jmv/usr2/jonas-3-3-6/apps/jonas/linuxmag_2004.04.11-10.47.02/linuxmag.jar:java.lang.NullPointerException: org.objectweb.jonas_ejb.deployment.api.DeploymentDescException: Cannot read the XML deployment descriptors for /home/jmv/usr2/jonas-3-3-6/apps/jonas/linuxmag_2004.04.11-10.47.02/linuxmag.jar:java.lang.NullPointerException
2004-04-11 15:38:17,420 : EJBServiceImpl.deployJars : Undeploy ejb-jar of the ear application
2004-04-11 15:38:17,430 : EarServiceImpl.deployEar : Error during the deployment of the jars files of the Ear file /home/jmv/opt2/jboss-3.2.3/server/default/deploy/linuxmag.ear': Error during the deployment: org.objectweb.jonas.service.ServiceException : Cannot read the XML deployment descriptors for /home/jmv/usr2/jonas-3-3-6/apps/jonas/linuxmag_2004.04.11-10.47.02/linuxmag.jar:java.lang.NullPointerException: org.objectweb.jonas_ejb.deployment.api.DeploymentDescException: Cannot read the XML deployment descriptors for /home/jmv/usr2/jonas-3-3-6/apps/jonas/linuxmag_2004.04.11-10.47.02/linuxmag.jar:java.lang.NullPointerException
Cannot read the XML deployment descriptors forVoici le contenu exact de cette archive qui pose problème :
/home/jmv/usr2/jonas-3-3-6/apps/jonas/linuxmag_2004.04.11-10.47.02/linuxmag.jar:
java.lang.NullPointerException
unzip -l $jboss_exemple/build/linuxmag.jarJe crois qu'il est temps de faire tourner un exemple d'ObjectWeb pour pouvoir comparer tout ça.
Archive: /home/jmv/contrats/formation-j2ee/jboss/jboss_linuxmag//build/linuxmag.jar
Length Date Time Name
-------- ---- ---- ----
0 04-11-04 10:46 META-INF/
103 04-11-04 10:46 META-INF/MANIFEST.MF
0 04-11-04 10:46 META-INF/lib/
0 04-11-04 10:46 org/
0 04-11-04 10:46 org/linuxmag/
0 04-11-04 10:46 org/linuxmag/jboss/
0 04-11-04 10:46 org/linuxmag/jboss/ejb/
3658 04-11-04 10:46 META-INF/ejb-jar.xml
598 04-11-04 10:46 META-INF/jboss.xml
1451 04-11-04 10:46 META-INF/jbosscmp-jdbc.xml
209915 04-11-04 10:46 META-INF/lib/pg74.1jdbc3.jar
1675 04-11-04 10:46 org/linuxmag/jboss/ejb/LinuxmagBean.class
381 04-11-04 10:46 org/linuxmag/jboss/ejb/LinuxmagLocal.class
629 04-11-04 10:46 org/linuxmag/jboss/ejb/LinuxmagLocalHome.class
215 04-11-04 10:46 org/linuxmag/jboss/ejb/LinuxmagSession.class
1452 04-11-04 10:46 org/linuxmag/jboss/ejb/LinuxmagSessionBean.class
267 04-11-04 10:46 org/linuxmag/jboss/ejb/LinuxmagSessionHome.class
-------- -------
220344 17 files
07:38:01,245 WARN [verifier] EJB spec violation:Soit je corrige ces incohérences avec les fichiers XML de déploiement, soit je répercute dans le LinuxmagSession une méthode pour créer un objet.
Bean : Linuxmag
Section: 12.2.10
Warning: Entity bean's local interface must extend the javax.ejb.EJBLocalObject interface.
07:38:01,273 WARN [verifier] EJB spec violation:
Bean : Linuxmag
Method : public abstract void remove() throws RemoteException, RemoveException
Section: 12.2.10
Warning: The methods in the local interface must not include java.rmi.RemoteException in their throws clause.
................
07:38:01,307 WARN [verifier] EJB spec violation:
Bean : Linuxmag
Method : public abstract void remove() throws RemoteException, RemoveException
Section: 12.2.10
Warning: For each method defined in the local interface, there must be a matching method in the entity bean's class that has the same name and argument types.
// Méthode EJB qui crée l'objet en base de donnéesSans ces trois appels, l'objet restait vide, bien sûr.
public Integer ejbCreate(Integer number, Date date, String mainTitle) throws CreateException {
System.out.println("Linuxmag CMP Entity Bean Create");
setNumber(number);
setDate(date);
setMainTitle(mainTitle);
return number;
}
Maintenant ça
marche !!!
http://localhost:8088/linuxmag/addItem.jsp?number=333&date=Sat%2C+12+Aug+1995+13%3A30%3A00+GMT&maintitle=titre+jmv
date: Sat, 12 Aug 1995 13:30:00 GMTJ'avais fait ceci en JSP comme page de saisie pour ajouter des objets LinuxMag :
, number: 223
, maintitle: titre jmv
Exception: javax.ejb.CreateException: Could not create
entity:java.sql.SQLException: ERROR: ExecInsert: Fail to add null value
in not null attribute number
<%Clairement c'est
String date = request.getParameter("date");
out.println( "date: " + date );
String number = request.getParameter("number");
out.println( ", number: " + number );
String maintitle = request.getParameter("maintitle");
out.println( ", maintitle: " + maintitle );
out.println( "<br>");
try {
InitialContext context = new InitialContext();
// note : pas bon de faire accès directement à un objet local je crois
LinuxmagLocalHome linuxmaghome = (LinuxmagLocalHome)context.lookup("linuxmag/Linuxmag");
out.println("LinuxmagLocalHome Bean Method Call: create()");
linuxmaghome.create(new Integer(number), new java.util.Date(date), maintitle);
out.println( "OK, objet ajouté<br>");
} catch(Exception e) {
out.println("Exception: " + e);
}
%>
<a href="index.jsp">Retourner à page accueil Linuxmag</a>
linuxmaghome.create()qui ne passe pas. Dans ejb-jar.xml il y a:
<primkey-field>number</primkey-field>et dans conf/ejb/jbosscmp-jdbc.xml il n'y a rien de tel, mais dans les deux il y a l'indication de la correspondance entre les champs Java et les champs relationnels.
Exception: javax.ejb.CreateException: Could not createLe changement de base se fait dans jbosscmp-jdbc.xml :
entity:java.sql.SQLException: Try to insert null into a non-nullable
column in statement [INSERT INTO LINUXMAG (number, date, maintitle)
VALUES (NULL, NULL, NULL)]
<datasource>java:/DefaultDS</datasource>
<datasource-mapping>Hypersonic SQL</datasource-mapping>
postgresql-jdbc-7.3.4-1PGDG.i386.rpm | 608 KB | 28.07.2003 | 00:00:00 |
/usr/bin/createdb testet je vérifie que je peux me connecter avec le client basique:
/usr/bin/psql test
java -cp .:/usr/share/pgsql/pg73jdbc3.jar \===> Ca marche !!!! et même avec le driver JDBC plus récent que la base, pg74.1jdbc3.jar, utilisé par J.B. Onofré
JDBC2XML -url jdbc:postgresql://localhost/test/ \
-driver org.postgresql.Driver -user jmv \
-sql "CREATE TABLE my_table (column1 text, column2 integer);"
# sudo -u jboss ./run.shToujours le même message:
org.jboss.deployment.DeploymentException: Error: can't find data source: java:/PostgreDS;
- nested throwable: (javax.naming.NameNotFoundException: PostgreDS not bound)
-bash-2.05b$ /usr/bin/createdb jboss
CREATE DATABASE
-bash-2.05b$ id
uid=26(postgres) gid=26(postgres) groupes=26(postgres)
/usr/bin/psql jboss
CREATE USER postgres PASSWORD 'postgres'
createBeanClassInstanceCommand == null; CausedByException is:
createBeanClassInstanceCommand == null
at org.linuxmag.jboss.ejb.LinuxmagSessionBean.listAll(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:683)
default/deploy/jbossweb-tomcat41.sar/META-INF/jboss-service.xml
cd jboss_linuxmag; ant
13:26:08,856 INFO [MainDeployer] Starting deployment of package: file:/mnt/home2/jmv/opt/jboss-3.2.3/server/default/deploy/linuxmag.ear
13:26:15,636 INFO [EARDeployer] Init J2EE application: file:/mnt/home2/jmv/opt/jboss-3.2.3/server/default/deploy/linuxmag.ear
13:26:47,518 INFO [EJBDeployer] nested deployment: file:/mnt/home2/jmv/opt/jboss-3.2.3/server/default/tmp/deploy/tmp13994linuxmag.ear-contents/linuxmag.jar-contents/META-INF/lib/j2ee.jar
13:26:47,677 INFO [EJBDeployer] nested deployment: file:/mnt/home2/jmv/opt/jboss-3.2.3/server/default/tmp/deploy/tmp13994linuxmag.ear-contents/linuxmag.jar-contents/META-INF/lib/pg74.1jdbc3.jar
13:28:39,469 INFO [EjbModule] Deploying Linuxmag
13:28:48,587 INFO [EjbModule] Deploying LinuxmagSession
13:29:27,482 ERROR [EntityContainer] Starting failed
org.jboss.deployment.DeploymentException: Error: can't find data source: java:/PostgreDS; - nested throwable: (javax.naming.NameNotFoundException: PostgreDS not bound)
at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCEntityBridge.init(JDBCEntityBridge.java:143)
......
/sbin/iptables -I INPUT -p tcp --destination-port 4444 -i ppp0 -j DROP
/sbin/iptables -I INPUT -p tcp --destination-port 8009 -i ppp0 -j DROP
touch linuxmag.earque d'arrêter JBoss et de le redémarrer
15:50:42,356 INFO [EmbeddedTomcatService] undeploy, ctxPath=/linuxmag, warUrl=file:/mnt/home2/jmv/opt/jboss-3.2.3/server/default/tmp/deploy/tmp13994linuxmag.ear-contents/linuxmag.war/
15:50:42,421 INFO [Engine] StandardHost[localhost]: Retrait de l'application web pour le chemin de contexte /linuxmag
15:50:42,687 INFO [EjbModule] Stopping jboss.j2ee:module=linuxmag.jar,service=EjbModule
15:50:42,689 INFO [StatelessSessionContainer] Stopping jboss.j2ee:jndiName=linuxmag/LinuxmagSession,service=EJB
15:50:42,696 INFO [StatelessSessionInstancePool] Stopping jboss.j2ee:jndiName=linuxmag/LinuxmagSession,plugin=pool,service=EJB
15:50:42,714 INFO [EARDeployer] Undeploying J2EE application, destroy step: file:/mnt/home2/jmv/opt/jboss-3.2.3/server/default/deploy/linuxmag.ear
15:50:54,988 INFO [EJBModule] destroy(), remove EJB-Module: jboss.management.local:J2EEApplication=linuxmag.ear,J2EEServer=Local,j2eeType=EJBModule,name=linuxmag.jar
15:50:55,065 INFO [MainDeployer] Starting deployment of package: file:/mnt/home2/jmv/opt/jboss-3.2.3/server/default/deploy/linuxmag.ear
15:51:05,085 INFO [EARDeployer] Init J2EE application: file:/mnt/home2/jmv/opt/jboss-3.2.3/server/default/deploy/linuxmag.ear
15:51:19,964 INFO [EJBDeployer] nested deployment: file:/mnt/home2/jmv/opt/jboss-3.2.3/server/default/tmp/deploy/tmp13995linuxmag.ear-contents/linuxmag.jar-contents/META-INF/lib/j2ee.jar
15:51:20,109 INFO [EJBDeployer] nested deployment: file:/mnt/home2/jmv/opt/jboss-3.2.3/server/default/tmp/deploy/tmp13995linuxmag.ear-contents/linuxmag.jar-contents/META-INF/lib/pg74.1jdbc3.jar
15:51:46,968 ERROR [STDERR] javax.management.InstanceNotFoundException: jboss.management.local:J2EEApplication=linuxmag.ear,J2EEServer=Local,j2eeType=EJBModule,name=linuxmag.jar is not registered.
15:51:47,035 ERROR [STDERR] at org.jboss.mx.server.registry.BasicMBeanRegistry.get(BasicMBeanRegistry.java:354)
15:51:47,036 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.getMBeanInfo(MBeanServerImpl.java:557)
.....
15:52:06,722 INFO [EjbModule] Deploying Linuxmag
15:52:06,918 INFO [EjbModule] Deploying LinuxmagSession
15:52:12,950 ERROR [EntityContainer] Starting failed
org.jboss.deployment.DeploymentException: Error: can't find data source: java:/PostgreDS; - nested throwable: (javax.naming.NameNotFoundException: PostgreDS not bound)
at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCEntityBridge.init(JDBCEntityBridge.java:143)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.initStoreManager(JDBCStoreManager.java:420)
# sudo -u jboss ./run.shProblèmes :
## ..... messages ...
07:53:41,074 INFO [Server] JBoss (MX MicroKernel) [3.2.3 (build: CVSTag=JBoss_3_2_3 date=200311301445)] Started in 3m:55s:48ms
# /sbin/iptables -I INPUT -p tcp --source-port 4444 -i ppp0 -j DROP
$ sudo -u jboss ./run.shLa raison était que toute la chaîne de répertoires n'était pas lisible par le compte jboss. A noter que :
run.sh: Missing required file: /home/jmv/opt2/jboss-3.2.3/bin/run.jar
# ls -l /home/jmv/opt2/jboss-3.2.3/bin/run.jar
-rwxrwsr-x 1 jboss jboss 30186 nov 30 21:45 /home/jmv/opt2/jboss-3.2.3/bin/run.jar
$ export JBOSS_HOME=/home/jmv/opt2/jboss-3.2.3n'est pas nécessaire. Ensuite tous les services JBoss mettent 4 minutes à se lancer sur mon 500MHz :-( .