Tuesday, December 14, 2010

Andromda 3.4 -> Glassfish v3 -> JPA->Hibernate->MYSQL

Several issues arise right now with the andromda 3.4-SNAPSHOT build. Could not compile due to incomplete code generated by the JSF-Cartridge. Modified the files:
%JSF_CARTRIDGE%/templates/jsf/utils/ControllerBase.java, and JsfVariableResolver.java
to resolve.

Also, the application.xml that is generated is invalid ... open application.xml and move the <description> tag above the <display-name> tag.

Configuration of Glassfish:
Installed fresh install of Glassfish.
Created a jdbc connection pool in the glassfish v3 admin console.
Common Tasks>Create New JDBC Connection Pool

in the additional parameters section:
servername: localhost
port: 3306
user: user
password: pass
databasename: newdbname

Deploy the mysql connector (mysql-connector-java-5.1.5-bin.jar' into the folder:
%glassfish_install_folder%\domains\domain1\lib\ext


Modifying Andromda build.
For this test I have previously reverse engineered a model from an existing schema which I already have installed in my mysql db. I generated a new clean andromda 3.4-SNAPSHOT project, and tinkered to get it to successfully build. Upon deployment to Glassfish, it complained about missing hibernate classes.

Modify main pom.xml to include hibernate .jars:

<dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-core</artifactId>
                <version>3.6.0.Final</version>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-entitymanager</artifactId>
                <version>3.6.0.Final</version>
                <scope>compile</scope>
            </dependency>

Wednesday, December 1, 2010

Creating Liferay 6 portlets using Andromda

I am going to attempt to build a liferay 6 portlet using Andromda 3.4-SNAPSHOT.
This initial attempt is just to get a portlet running and deployed, and this blog is really intended as documentation of the steps for my reference... so reader beware.

Step 1 - Generate initial andromda project.
I have previously installed  maven 2.2.1 and Java JDK v 1.6.0_22

I created a folder c:/development/andromda_liferay6

From a command line I run the command:

mvn org.andromda.maven.plugins: andromdapp-maven-plugin :3.4-SNAPSHOT: generate


This will generate a new andromda project:

I created a j2ee project, uml2, no persistence cartridge, jsf, portlet, icefaces support.

Edited the mda\src\main\uml\sample_project.xml using MagicDraw 16.5 community version
Added a state diagram with one state and one controller class.
Tested compiling from the command line with the mvn command from the root folder of the sample_project folder.  The project compiled with a number of isses, look like missing icefaces components.  Ran the command mvn eclipse:eclipse to generate the eclipse project so that I could review the code inside of Eclipse.  Got the following error:

"Cant canonicalize system path:"  --->  had to change line in the web/pom.xml from

<targetPath>${project.basedir}/target/src/main/webapp</targetPath>
to:

<targetPath>../target/src/main/webapp</targetPath> 

Compiled ok. Open in Eclipse (Helios).