Sunday, July 29, 2007

Enabling Expression Language (EL) in JSP

You can do it in two ways:

  • Enable it for whole application : Put following in web.xml

    <jsp-config>
    <jsp-property-group>
    <url-pattern>*.jsp</url-pattern>
    <el-ignored>false</el-ignored>
    </jsp-property-group>
    </jsp-config>

  • Enable it for just one JSP page : put following at top of your JSP Page
    <%@ page isELIgnored="false" %>
Make sure when you use the first option you use 2.4 schema or above. i. e. your root tag in web .xml looks something like this.

< web-app id="WebApp" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">

make sure you are using Jasper jars for JSP 2.0 or above.

Saturday, July 28, 2007

AndroMDA: Generating create/drop schema script with Maven 2

First of all I would recommend anyone who is using the anroMDA for first time to read
${application_root}/readme.txt file carefully. This helps understanding the generated schema.

If you read readme.txt, you will notice two tasks

  • mvn -f core/pom.xml andromdapp:schema -Dtasks=create --> generates the DDL create code and subsequently tells the database to create the schema for the entities

  • mvn -f core/pom.xml andromdapp:schema -Dtasks=drop --> generates the DDL drop code and subsequently tells the database to drop the schema for the entities

  • mvn -f core/pom.xml andromdapp:schema -Dtasks=drop,create
But wait, these target don't seem to work for me if i use maven-2 (mvn) with AndroMDA 3.2.
add following to the plugin configuration in core/pom.xml
<executescripts>false</executescripts>
<tasks>create</tasks>
<tasks>drop</tasks>
and now when you run the above targets, the create and drop DDLs are generated in the path specified by createOutputPath and dropOutputPath property.

The default location for generated scripts is ${application_root}/app/target/

Remote and Local EJB with AndroMDA

@andromda.ejb.viewType "both" isn't supported, that's the reason. If you want to use remote at all, then set it to "remote", most application servers (like JBoss) treat remote interfaces as local when they're in the same JVM anyway.

Understanding Java Security and permission

This is a must read for any java programmer, combined with this article on JavaWorld

Monday, June 04, 2007

Installing AndroMDA plugin for Maven 2

  1. Click here to download the the AndroMDA plugin installer.
  2. Unzip the contents of the installer into your Maven repository at C:\Documents and Settings\your user name\.m2\repository.
  3. Verify that the following directory was created:
    C:\Documents and Settings\your user name\.m2\repository\org\andromda\maven\plugins\andromda-maven-plugin
  4. Create a temporary directory, e.g. C:\andromda-temp.
  5. Create a file called pom.xml in this directory with the following content.

  6. <project>

    <modelVersion>4.0.0</modelVersion>
    <groupId>samples.test</groupId>
    <artifactId>test</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>
    <name>test</name>

    <build>
    <defaultGoal>compile</defaultGoal>
    <plugins>
    <plugin>
    <groupId>org.andromda.maven.plugins</groupId>
    <artifactId>andromdapp-maven-plugin</artifactId>
    <version>3.2</version>
    </plugin>
    </plugins>
    </build>

    <repositories>
    <repository>
    <id>andromda</id>
    <name>AndroMDA Repository</name>
    <url>http://team.andromda.org/maven2</url>
    </repository>
    </repositories>

    <pluginRepositories>
    <pluginRepository>
    <id>andromda</id>
    <name>AndroMDA Repository</name>
    <url>http://team.andromda.org/maven2</url>
    </pluginRepository>
    </pluginRepositories>

    </project>
  7. Open a Command Prompt in the directory where you created this pom.xml and run the command mvn without any arguments. Make sure the command completes successfully by displaying the BUILD SUCCESSFUL message.
  8. You can now delete the temporary directory you created in step 1.
  9. use maven 2.0.5 or 2.0.4. i was getting following error with 2.0.6, see andromda forum topic for details. You get "An invalid artifact was detected." error with maven 2.0.6
  10. Use following command to generate the project:
mvn org.andromda.maven.plugins:andromdapp-maven-plugin:generate

instead of

mvn andromdapp:generate