Lacking any help from the masses, I'll post my own follow ups for those in a similar
situation as myself. Maybe someone else will find this useful.
I found two pieces of information that helped me get past the migration from Middlegen to
Hibernate. The first is the O'Reilly text "Enterprise Java Bean 3.0",
(
http://www.oreilly.com/catalog/entjbeans5/) which (to me, and I'm an author myself)
is the easiest to follow text I've found so far. Mixed with the online chapter for
Hibernate (
http://www.manning.com/bauer2/), I was able to migrate my build system from
Middlegen to Hibernate using reverse-engineering (as they call it - that means something a
little different from the world I come from) techniques on our existing MySQL database.
First I generate an XML mapping file using HibernateToolTask:
<taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="hclasspath"/>
| <target name="-genConfig" if="db.init.Required"
description="Produces XML mapping files in src directory">
| <hibernatetool destdir="${build.hibernate.dir}">
| <classpath>
| <pathelement location="${config.hibernate.dir}"/>
| </classpath>
| <jdbcconfiguration
propertyfile="${config.hibernate.dir}/db.properties"
| revengfile="${config.hibernate.dir}/reveng.xml"/>
| <hbm2hbmxml/> <!-- Export Hibernate XML files -->
| <hbm2cfgxml ejb3="true"/> <!-- Export a
hibernate.cfg.xml file -->
| </hibernatetool>
| </target>
Then I generate the Entity Beans, DAO templates and Entity Bean documentation from the
mapping files:
<target name="-genPojos" depends="-genConfig"
if="db.init.Required"
| description="Produces Java classes from XML mappings">
| <hibernatetool destdir="${build.hibernate.dir}/src">
| <configuration
propertyfile="${config.hibernate.dir}/db.properties" >
| <fileset dir="${build.hibernate.dir}">
| <include name="**/*.hbm.xml"/>
| </fileset>
| </configuration>
|
| <!-- Generate Entity Beans -->
| <hbm2java jdk5="true" ejb3="true"/>
|
| <!-- Generate DAO (Data Access Object's) for entity beans. -->
| <hbm2dao/>
|
| <!-- Generate Entity Bean documentation. -->
| <hbm2doc destdir="${build.docs.dir}/hibernate" />
|
| </hibernatetool>
| </target>
Finally, I compile these into the classes that will be used by my server side code to work
with the database:
| <target name="-genRun" depends="-genPojos"
if="db.init.Required"
| description="Compiles entity bean code generated by Hibernate">
| <javac srcdir="${build.hibernate.dir}/src"
| destdir="${build.hibernate.classes.dir}"
| debug="on"
| deprecation="on"
| optimize="off"
| includes="**/*.java">
| <classpath refid="hc.classpath"/>
| </javac>
| </target>
So now I have the Entity Beans generated. The next step was to write some Session Beans
that would act as my WebServices interfaces. The EJB3.0 book from OReilly explained how
to do this (chapter 19, but be certain you understand what Session Beans and Remote
interfaces are before you read this chapter). With those written, I could use slightly
modified code from the old build to generate the WSDL interfaces for both the server and
client sides, along with their Java classes (email me if you want to see that code - they
use the java2wsdl and wsdl2java Ant tasks from the Apache Axis project).
Our project doesn't have a Web browser interface (no JSP or similar) so I left out the
web.war file from the application ear file, but this turned out to be a mistake. I had to
put the web.war file in the ear along with some configuration information (security
constraints, etc. from the web.xml) into the ear before it would deploy. I have a feeling
I could still leave out the web.war as long as the proper config files were included in
the ear, but I'm not sure which config files to leave in.
As an added problem, I'm doing all this with a migration from JBOSS 4.0.5GA to
4.2.2GA. One minor issue I found with this is that with 4.0.5GA I could deploy a
*-login-config-service.xml to the server/default/deploy directory and the associated
*-login-config.xml to server/default/conf. With 4.2.2GA these both have to go in
server/default/conf. Where is the documentation that says that? It's not with the
DynamicLoginConfig documentation I found on the JBOSS web site.
The deployment is still not complete, however, as I now have some problem with my
DataSourceBinding. I believe this to be a configuration error as I changed from one
naming scheme for the old project to a new one for the new version of the project. If
anyone is interested (and might have a pointer for where to look for this problem), these
are the messages I get on the JBOSS console at deploy time:
| 10:17:11,403 INFO [EARDeployer] Init J2EE application:
file:/home/mjhammel/src/cei/jboss-4.2.2.GA-cei/server/default/deploy/Crunch.ear
| 10:17:11,548 INFO [JmxKernelAbstraction] creating wrapper delegate for:
org.jboss.ejb3.entity.PersistenceUnitDeployment
| 10:17:11,554 INFO [JmxKernelAbstraction] installing MBean:
persistence.units:ear=Crunch.ear,unitName=crunch with dependencies:
| 10:17:11,554 INFO [JmxKernelAbstraction]
jboss.jca:name=CrunchDS,service=DataSourceBinding
| 10:17:11,557 INFO [EJB3Deployer] Deployed:
file:/home/mjhammel/src/cei/jboss-4.2.2.GA-cei/server/default/tmp/deploy/tmp26596Crunch.ear-contents/crunch-ejb.jar
| 10:17:11,565 INFO [EARDeployer] Started J2EE application:
file:/home/mjhammel/src/cei/jboss-4.2.2.GA-cei/server/default/deploy/Crunch.ear
| 10:17:11,566 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
|
| --- Packages waiting for a deployer ---
| org.jboss.deployment.DeploymentInfo@51a7c24d {
url=file:/home/mjhammel/src/cei/jboss-4.2.2.GA-cei/server/default/deploy/crunch-login-config.xml
}
| deployer: null
| status: null
| state: INIT_WAITING_DEPLOYER
| watch:
file:/home/mjhammel/src/cei/jboss-4.2.2.GA-cei/server/default/deploy/crunch-login-config.xml
| altDD: null
| lastDeployed: 1198773984468
| lastModified: 1198773984000
| mbeans:
|
| --- Incompletely deployed packages ---
| org.jboss.deployment.DeploymentInfo@83ba23ed {
url=file:/home/mjhammel/src/cei/jboss-4.2.2.GA-cei/server/default/deploy/Crunch.ear }
| deployer: org.jboss.deployment.EARDeployer@18baf36
| status: null
| state: FAILED
| watch:
file:/home/mjhammel/src/cei/jboss-4.2.2.GA-cei/server/default/deploy/Crunch.ear
| altDD: null
| lastDeployed: 1198771941640
| lastModified: 1198771941000
| mbeans:
|
| org.jboss.deployment.DeploymentInfo@51a7c24d {
url=file:/home/mjhammel/src/cei/jboss-4.2.2.GA-cei/server/default/deploy/crunch-login-config.xml
}
| deployer: null
| status: null
| state: INIT_WAITING_DEPLOYER
| watch:
file:/home/mjhammel/src/cei/jboss-4.2.2.GA-cei/server/default/deploy/crunch-login-config.xml
| altDD: null
| lastDeployed: 1198773984468
| lastModified: 1198773984000
| mbeans:
|
| --- MBeans waiting for other MBeans ---
| ObjectName: persistence.units:ear=Crunch.ear,unitName=crunch
| State: NOTYETINSTALLED
| I Depend On:
| jboss.jca:name=CrunchDS,service=DataSourceBinding
|
| --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
| ObjectName: jboss.jca:name=CrunchDS,service=DataSourceBinding
| State: NOTYETINSTALLED
| Depends On Me:
| persistence.units:ear=Crunch.ear,unitName=crunch
|
When I get all this deployed I still have a major task of rewriting all my original server
side code to talk with the database, but this version is a complete rewrite anyway so most
of what I'm doing now is just learning how the build system will use newer
technologies (like Hibernate and EJB3) as part of the larger project. Once the build is
autogenerating whatever code needs to be autogenerated (and deployed) then I can start to
focus on the meat of the project rewrite.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4115760#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...