S
sengsational
Here are a few discoveries I thought I'd share with the group
concerning my adventures in getting a web application on Geronimo
talking to MySql.
I used Geronimo 2.1 as my container, and I used mysql as a database
for this project. It seems that you MUST start Geronimo, log into the
admin console (username:system, password:manager),and create a
database pool (I called mine "jdbc/MyDataSource"). It seems that just
putting the mysql connector jar (with the com.mysql.jdbc.Driver class)
in the xml deployment descriptors is not enough. A database pool is
required. I actually placed the mysql connector jar file in the
appropriate directory under "repository" before creating the pool.
Then, after you have configured the databse pool, you can click
"Usage" from the list of pools, and it will tell you exactly what
needs to be in web.xml and geronimo-web.xml.
Also, The maven-style paths under "repository" can be troublesome.
Your jar file needs to have a version number on it (ie mysql-connector-
java-5.1.7.jar). If you defined your "groupId" as "mysql", then under
"<GERONIMO_HOME>/repository/", you would have a "mysql" directory (if
you are unfortunate enough to name your "groupId" "com.my.stuff", you
would need to nest "com/my/stuff"). Inside of "mysql", you need to
create a directory matching the "artifactId", and inside of that, you
need to make a directory matching the version (in this case "5.1.7").
Finally, you put your jar file in there. So we have:
"<GERONIMO_HOME>\repository\mysql\mysql-connector-java\5.1.7\mysql-
connector-java-5.1.7.jar"
I'm sure glad this is simplified to such a great extent!
Now, you would think that the following dependency would work:
<dep:dependency>
<dep:groupId>mysql</dep:groupId>
<dep:artifactId>mysql-connector-java</dep:artifactId>
<dep:version>5.1.7</dep:version>
<dep:type>jar</dep:type>
</dep:dependency>
..... but you would be WRONG!
You need to include things something like this in the geronimo-
web.xml:
....
dep:dependency>
<dep:groupId>console.dbpool</dep:groupId>
<dep:artifactId>MyDataSource</dep:artifactId>
/dep:dependency>
....
name:resource-ref>
<name:ref-name>jdbc/MyDataSource</name:ref-name>
<name:resource-link>jdbc/MyDataSource</name:resource-link>
/name:resource-ref>
and in web-xml:
<resource-ref>
<res-ref-name>jdbc/MyDataSource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
(as I mentioned above, the Geronimo Console will give you these
details after you define the pool).
Here are some of the things I saw in my trials, for the googlers of
the world:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
Missing dependency exception
Unable to resolve resource reference res-ref-name
Missing dependency: mysql/mysql-connector-java
java:comp/env/jdbc resource-ref
No guarantees, and the EJB3 stuff is certainly not right yet,
but you can get a copy of the set of eclipse projects here:
http://rapidshare.de/files/40976258/LeaguePlanetEjb3MysqlCh8Iter3.zip.html
--Dale--
concerning my adventures in getting a web application on Geronimo
talking to MySql.
I used Geronimo 2.1 as my container, and I used mysql as a database
for this project. It seems that you MUST start Geronimo, log into the
admin console (username:system, password:manager),and create a
database pool (I called mine "jdbc/MyDataSource"). It seems that just
putting the mysql connector jar (with the com.mysql.jdbc.Driver class)
in the xml deployment descriptors is not enough. A database pool is
required. I actually placed the mysql connector jar file in the
appropriate directory under "repository" before creating the pool.
Then, after you have configured the databse pool, you can click
"Usage" from the list of pools, and it will tell you exactly what
needs to be in web.xml and geronimo-web.xml.
Also, The maven-style paths under "repository" can be troublesome.
Your jar file needs to have a version number on it (ie mysql-connector-
java-5.1.7.jar). If you defined your "groupId" as "mysql", then under
"<GERONIMO_HOME>/repository/", you would have a "mysql" directory (if
you are unfortunate enough to name your "groupId" "com.my.stuff", you
would need to nest "com/my/stuff"). Inside of "mysql", you need to
create a directory matching the "artifactId", and inside of that, you
need to make a directory matching the version (in this case "5.1.7").
Finally, you put your jar file in there. So we have:
"<GERONIMO_HOME>\repository\mysql\mysql-connector-java\5.1.7\mysql-
connector-java-5.1.7.jar"
I'm sure glad this is simplified to such a great extent!
Now, you would think that the following dependency would work:
<dep:dependency>
<dep:groupId>mysql</dep:groupId>
<dep:artifactId>mysql-connector-java</dep:artifactId>
<dep:version>5.1.7</dep:version>
<dep:type>jar</dep:type>
</dep:dependency>
..... but you would be WRONG!
You need to include things something like this in the geronimo-
web.xml:
....
dep:dependency>
<dep:groupId>console.dbpool</dep:groupId>
<dep:artifactId>MyDataSource</dep:artifactId>
/dep:dependency>
....
name:resource-ref>
<name:ref-name>jdbc/MyDataSource</name:ref-name>
<name:resource-link>jdbc/MyDataSource</name:resource-link>
/name:resource-ref>
and in web-xml:
<resource-ref>
<res-ref-name>jdbc/MyDataSource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
(as I mentioned above, the Geronimo Console will give you these
details after you define the pool).
Here are some of the things I saw in my trials, for the googlers of
the world:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
Missing dependency exception
Unable to resolve resource reference res-ref-name
Missing dependency: mysql/mysql-connector-java
java:comp/env/jdbc resource-ref
No guarantees, and the EJB3 stuff is certainly not right yet,
but you can get a copy of the set of eclipse projects here:
http://rapidshare.de/files/40976258/LeaguePlanetEjb3MysqlCh8Iter3.zip.html
--Dale--