[fleXive] Developer Blog

July 21, 2010

[fleXive] 3.1.4 released, adds Web Profile support

Filed under: Announcements,Development News,Releases — Daniel Lichtenberger @ 12:17

A new update release containing important bugfixes has been released. Head over to our homepage for release notes and download links.

The major new feature of this release is support for the JavaEE 6 Web Profile, a slimmed-down version of JavaEE 6. It provides all the good stuff of JavaEE that [fleXive] already uses (managed beans, container managed transactions, connection pooling, JSF), but removes a lot of the baggage from the J2EE era. Actually the only feature we are using that is not part of the web profile is remote interfaces. To see this in action just download flexive-admin.war, get Glassfish 3 Web, and drop the WAR file into the glassfish/domains/domain1/autodeploy folder. It should just work, without further configuration. The default data source is defined with the new DataSourceDefinition annotation (but can of course be overridden with a custom datasource).

To use [fleXive] in a WAR project, either create the project using our Maven archetype or include the [fleXive] EJBs in your (Maven) application:

        <dependency>
            <groupId>com.flexive</groupId>
            <artifactId>flexive-ejb</artifactId>
            <type>ejb</type>
            <version>3.1.4</version>
            <exclusions>
                <!-- Exclude remote interfaces to enable web profile deployment -->
                <exclusion>
                    <groupId>com.flexive</groupId>
                    <artifactId>flexive-ejb-interfaces-all</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- Add only local EJB interfaces for flexive -->
        <dependency>
            <groupId>com.flexive</groupId>
            <artifactId>flexive-ejb-interfaces-local</artifactId>
            <version>3.1.4</version>
        </dependency>

        <dependency>
            <groupId>com.flexive</groupId>
            <artifactId>flexive-plugin-jsf2-core</artifactId>
            <version>3.1.4</version>
        </dependency>

May 20, 2010

JSF2 support in [fleXive]

Filed under: Development News — Tags: , , , — Daniel Lichtenberger @ 13:50

I added a page regarding JSF2 support in [fleXive] to our wiki:

  • [fleXive] 3.1.0+ should run on any JSF implementation
  • Work on trunk has started for native JSF2 support (i.e. supporting the new view description language and features like f:ajax).

There is also a (very small) test project for the JSF2 components, check it out with:
svn co http://svn.flexive.org/repository/flexive/trunk/src/examples/jsf2-test

March 16, 2010

Maven archetype updated, Beta 3 released

Filed under: Development News,Releases,Using fleXive — Tags: , , , , , , — Daniel Lichtenberger @ 16:13

The Maven EAR archetype has been updated after the release of [fleXive] 3.1 Beta 3. It is of course based on beta 3, and includes a few minor changes and bugfixes that justified a new version.

The flexive backend is now always reached under the /flexive context (both from the embedded Jetty instance and from EAR deployments), the application itself always under /war. To get started:

  1. mvn archetype:generate -DarchetypeGroupId=com.flexive -DarchetypeArtifactId=flexive-archetype-ear -DarchetypeVersion=0.7 -DarchetypeRepository=http://repo.flexive.org/maven2/
  2. Enter the project name and group, e.g. test/test
  3. cd test
  4. mvn install
  5. cd war
  6. mvn jetty:run
  7. Open http://localhost:8080/flexive/ in your browser and complete the installation by logging in with supervisor/supervisor.

For more information on the Maven support, please refer to the reference documentation.

October 23, 2009

CMIS and WebDAV connector source released

Filed under: Development News — Daniel Lichtenberger @ 11:02

Yesterday I added the sources of our CMIS and WebDAV adapters to our main repository on svn.flexive.org. They are still under development, so no binary releases yet, but especially the WebDAV adapter is already quite useable. If you want to build them now, please follow these steps…

Get and build Chemistry

Chemistry is an incubating project at Apache and provides a generic implementation of a server-side CMIS connector. The idea is that the content repository only has to implement a modest set of backend methods, and Chemistry will provide the rest (like AtomPub and WebService bindings). Currently there are no releases of Chemistry yet, so we need to build it on our own (all instructions are for Unix, please adopt slightly when using Windows):

Update 2010-01-08: Flexive tracks the Chemistry trunk version again, so please checkout http://svn.apache.org/repos/asf/incubator/chemistry/trunk instead.

mkdir build
cd build
svn checkout http://svn.apache.org/repos/asf/incubator/chemistry/branches/0.62 chemistry-reactor
cd chemistry-reactor
mvn install
cd chemistry
mvn install

Get the CMIS/WebDAV modules

The CMIS and WebDAV modules of [fleXive] are also built with Maven 2. To build them, we don’t need the entire [fleXive] source tree, as the [fleXive] artifacts will be resolved from our Maven repository.

cd ../..
svn checkout http://svn.flexive.org/repository/flexive/trunk/modules/chemistry flexive-chemistry
cd flexive-chemistry
mvn install

The “mvn install” step will also run some tests with an embedded [fleXive] container, if you want to skip them pass “-DskipTests” on the command line.

Installation

The interesting artifacts produced by the build are two web applications:

  • flexive-webdav-webapp/target/flexive-webdav.war contains the WebDAV adapter
  • flexive-atompub-webapp/target/flexive-atompub.war is the CMIS AtomPub connector

To use them, add the WAR files to your flexive.ear (when using Maven, add a dependency to the WAR artifact, when using the flexive distribution, add them to the flexive-dist/applications directory, when building [fleXive] from source put them in the drop/ directory). Note that both adapters are under active development, and are not yet in a stable state. The CMIS adapter used to work against the CMIS Spaces and CMIS Explorer clients, but the clients have moved to newer versions of the standard since then. The WebDAV adapter is based on Milton and works quite well, although it’s also not recommended for production use. I tested it with KDE’s Dolphin, Gnome Nautilus (only works when it is bound to the root web context), cadaver (Linux command line client), and Windows XP. It also passes quite a few tests of the litmus WebDAV test suite, which of course is entirely to be attributed to the excellent Milton WebDAV library.

August 14, 2009

Maven EAR applications: new H2 version required

Filed under: Development News — Tags: , , , , , , , — Daniel Lichtenberger @ 15:18

The 0.6 version of our EAR archetype includes a hardcoded version number for the H2 database engine artifact. Recent changes in the [fleXive] trunk (i.e. 3.1-SNAPSHOT) require a newer version of H2, otherwise the initialization of the database will fail with a “Syntax error in SQL statement”.

The fix for existing projects is to fix the version number in your main module’s pom.xml: increase the h2.version property from 1.1.106 to 1.1.117.

To avoid this issue in the future, I moved the H2 dependency to the flexive-h2 artifact. The current snapshot version of the archetype (1.0-SNAPSHOT) therefore no longer includes a dependency on com.h2database.h2, and potential changes in the required H2 version number (always a possibility since H2 development is very active) won’t affect existing projects.

April 16, 2009

WAR deployment with EJB 3.1 and Glassfish v3 Preview

Filed under: Development News,Using fleXive — Tags: , , , , , , — Daniel Lichtenberger @ 15:32

Update 2009/07/15: address the Glassfish v3 Preview instead of the older Prelude release.

EJB 3.1 brings the deployment of EJBs as part of a WAR, ultimately removing any entry barriers to using EJBs with a container that supports EJB 3.1. This article will show how to deploy [fleXive] as part of a WAR application, using [fleXive]‘s WAR archetype for Maven and Glassfish v3 Preview.

Create the WAR project

To get started, create a new Maven project using our WAR archetype:
mvn archetype:generate -DarchetypeGroupId=com.flexive -DarchetypeArtifactId=flexive-archetype-war -DarchetypeVersion=1.0-SNAPSHOT -DarchetypeRepository=http://repo.flexive.org/maven2/ -DgroupId=my.group.test -DartifactId=webapp-test -Dversion=1.0-SNAPSHOT

This creates a basic WAR application with the following directory structure:

    webapp-test
    |-- pom.xml
    `-- src
        `-- main
            |-- java
            |   `-- my
            |       `-- group
            |           `-- test
            |               |-- EJBExampleBean.java
            |               `-- ExampleBean.java
            `-- webapp
                |-- WEB-INF
                |   |-- faces-config.xml
                |   `-- web.xml
                `-- index.xhtml

EJBExampleBean shows a prime feature of EJB 3.1: instead of having to declare an EJB interface and packaging the EJB class in a separate EJB JAR file, we just add our EJB to the web application and annotate it with @javax.ejb.Stateless (of course, you can still use explicit local and remote interfaces). This turns it into a fully-fledged EJB that can be injected into other managed beans using the @EJB annotation.

@Stateless(name = "EJBExample")
public class EJBExampleBean {

    public Map<FxType, Integer> getInstanceCounts() throws FxApplicationException {
        final Map<FxType, Integer> result = new HashMap<FxType, Integer>();
        final FxEnvironment environment = CacheAdmin.getEnvironment();
        // Invoke fleXive query through EJB and collect the results
        for (FxFoundType foundType : new SqlQueryBuilder().select("@pk").getResult().getContentTypes()) {
            result.put(environment.getType(foundType.getContentTypeId()), foundType.getFoundEntries());
        }
        return result;
    }
}
/**
 * Request-scoped JSF bean accessing the EJB.
 */
public class ExampleBean {
    @EJB EJBExampleBean exampleEJB;
    private Map<FxType, Integer> instanceCounts;

    public Map<FxType, Integer> getInstanceCounts() throws FxApplicationException {
        if (instanceCounts == null) {
            instanceCounts = exampleEJB.getInstanceCounts();
        }
        return instanceCounts;
    }
}

In our pom.xml we add the [fleXive] EJB and JSF artifacts, as well as Glassfish itself to provide the EJB 3.1 APIs during compilation. It seems that Glassfish v3 Preview does not bring Sun’s EL-1.0 implementation (which we need for Facelets), so we have to add this too.

<properties>
    <flexive.version>3.1-SNAPSHOT</flexive.version>
</properties>

<dependencies>
    <dependency>
        <groupId>com.flexive</groupId>
        <artifactId>flexive-ejb</artifactId>
        <type>ejb</type>
        <version>${flexive.version}</version>
    </dependency>

    <dependency>
        <groupId>com.flexive</groupId>
        <artifactId>flexive-plugin-jsf-core</artifactId>
        <version>${flexive.version}</version>
    </dependency>

    <dependency>
        <groupId>com.sun.el</groupId>
        <artifactId>el-ri</artifactId>
        <version>1.0</version>
    </dependency>

    <dependency>
        <groupId>org.glassfish</groupId>
        <artifactId>javax.javaee</artifactId>
        <version>3.0-Prelude-b28b</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

The pom.xml also expands the [fleXive] EJBs into the WEB-INF/classes folder of the web application, because Glassfish v3 Prelude Preview does not yet support EJB-JAR deployments:

<!--
    Unpack the flexive-ejb artifact and add it to WEB-INF/classes
    (Glassfish v3 Prelude does not support EJB-JAR deployment yet)
-->
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <executions>
        <!-- Copy the EJBs to target/flexive -->
        <execution>
            <id>copy-ejb</id>
            <phase>generate-resources</phase>
            <goals>
                <goal>unpack</goal>
            </goals>
            <configuration>
                <artifactItems>
                    <artifactItem>
                        <groupId>com.flexive</groupId>
                        <artifactId>flexive-ejb</artifactId>
                        <version>${flexive.version}</version>
                        <overWrite>true</overWrite>
                        <outputDirectory>target/flexive/WEB-INF/classes</outputDirectory>
                    </artifactItem>
                </artifactItems>
            </configuration>
        </execution>
    </executions>
</plugin>

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.1-beta-1</version>
    <configuration>
        <webResources>
            <resource>
                <directory>target/flexive</directory>
            </resource>
        </webResources>
    </configuration>
</plugin>

Invoke mvn package to compile and package the application into target/webapp-test.war.

Glassfish v3 Prelude Preview setup

Download and install Glassfish v3 Preview.

Before deploying a [fleXive] application, you need to perform additional setup steps described in the reference documentation:

  • Download the [fleXive] distribution
  • Install the required libraries to [glassfish-home]/glassfish/domains/domain1/lib/ext
  • Add the datasources
  • Initialize the database schema as described here

Deploying the WAR application to Glassfish

Finally, start Glassfish with bin/asadmin start-domain and deploy the WAR file from your project directory with [glassfish-home]/bin/asadmin deploy --force=true target/webapp-test.war. Deployment should only take a few seconds, and the application should be running and display the output from calling our EJB at http://localhost:8080/webapp-test/.

A note on JSF2

[fleXive] is a JSF 1.2 application. As such, it should work without changes in a JSF2 container. However, we ran into some issues, mostly due to RichFaces’ Ajax4JSF implementation. In the backend application, you need to force client-side state saving (through a config parameter in the web.xml), and some administration pages don’t work yet. The JSF components themselves appear to be working without problems, however they are still based on JSF 1.2 and Facelets – thus they cannot be used in a true JSF2 application.

April 8, 2009

Improved result preferences

Filed under: Development News,Using fleXive — Daniel Lichtenberger @ 14:07

2009_04_08-backend-resultpreferences-previewIn the [fleXive] backend administration, the user can define the columns of the search result view (click on the “result preferences” button in the search results page, or click on the gear icon in the toolbar). You can also use this in your own code by selecting the @* pseudo-column in FxSQL. Depending on the type of the search result items, the corresponding “result preferences” are used for determining the columns shown to the user.

The current snapshot versions (currently only available through the automated 3.1-SNAPSHOT Maven builds) include the following improvements:

  • Derived properties are listed under the first type that defined (or reused) them.
  • Group properties are available in the dropdown (as in “Address/…”)
  • If a derived type has no own result preferences defined for the current user, the settings from the parent type(s) are used first before using the main fallback (the “all types” setting)

These improvements make the backend search results a lot more usable when you’re working with type inheritance and groups.

March 31, 2009

Development build #1149 available

Filed under: Development News — Tags: , , , , , — Daniel Lichtenberger @ 14:39

A new snapshot from the development branch (3.1) is available: Download from SourceForge

The improvements include:

  • WebLogic support
  • Full Geronimo support
  • Backend: Improved content editor layout
  • Backend: Improved script editing and scripting console
  • Miscellaneous bugfixes

March 23, 2009

Tutorial application stands alone

Filed under: Development News,Using fleXive,documentation — Tags: , , — Daniel Lichtenberger @ 09:14

I reworked parts of the tutorials section of our reference documentation.  The tutorials are now offered as stand-alone source downloads that can be compiled with a current fleXive distribution. The chapter on the hello-world application also explains how to build this application “from scratch”. It should be possible to complete the application just by copy-and-pasting the source listings and following the instructions.

The previous version focused on explaining the source code itself, but it assumed that you’d only want to compile the example inside the main fleXive source tree (this still works, of course, it’s just not very useful for anybody developing a new application). You may also want to check out the chapter on Writing [fleXive] applications, which also explains how to use Maven for your own projects.

February 11, 2009

WebLogic 10.3 compatibility

Filed under: Development News — Tags: , , , , , , , , , , — Markus Plesser @ 09:46

Even though it did not take as long as expected, it was a bumpy road to get [fleXive] to run on WebLogic 10.3.

All Application Servers are equal and follow the Java EE specification … yeah, right ;-)

Ok, lets start with pure EJB3 connectivity and leave JSF 1.2 for later: The very first thing I stumbled upon when I tried to deploy [fleXive] was some strange and misleading message about WebLogic being unable to set the transaction attribute to a bean method signature. My first thought was that there was a problem in the way we use remote and local Interfaces: The @Remote Interface contains the method signature and the @Local Interface is just derived from the @Remote one without having to declare the signatures again. The Bean itself implements both the @Local and @Remote Interface.

After some trial and (only) errors – like adding signatures to the @Local Interfaces as well and removing @Local Interfaces at all – it turned out that WebLogic chokes on (although public) inner classes passed as Bean parameters!

Some refactorings later (which had to break the API by moving those inner classes to outer ones – the reason why WebLogic support is exclusive to the upcoming version 3.1 of [fleXive] and won’t be backported to the 3.0 branch) [fleXive] still didn’t deploy:
The reason was a rather old commons-lang version bundled with WebLogic that is visible to the applications ClassLoader which lead to ClassCastException’s.
To work around this, the EAR has to contain a custom WebLogic deployment descriptor (weblogic-application.xml) to override classloading behaviour:

<?xml version='1.0' encoding='UTF-8'?>
<weblogic-application>
    <library-ref>
        <library-name>jsf</library-name>
        <specification-version>1.2</specification-version>
        <implementation-version>1.2</implementation-version>
        <exact-match>false</exact-match>
    </library-ref>
    <prefer-application-packages>
        <package-name>org.apache.*</package-name>
    </prefer-application-packages>
</weblogic-application>

The library-ref tag in above file is needed to prevent patching the javax.jsf_1.2.0.0.jar with META-INF/services entries as described here. Now everything deployed fine …

Or so I thought … dependency injection using @Resource and @EJB worked, but manual JNDI lookups for the database connections and beans (needed by some core engines, scripts and on the web layer) failed. Two things had to be added: mappedName to the @Stateless Annotation in the enterprise beans and a lookup strategy using simpleName#complexName (e.g. ContentEngine#com.flexive.ejb.beans.ContentEngine).
MySQL DataSource lookups worked without any problems, but Supports Global Transactions had to be disabled. Without mappedName Annotation values WebLogic would create a binding involving the name of the deployed EAR which is unknown to the application. The downside is that beans can only be deployed once on a server.

EJB issues were solved and the application started without any further problems. Now came the hardest part: getting JSF 1.2 to work …
The good news is that WebLogic does support JSF, else it would not be certified. JSF 1.2 support is required by the Java EE 5 specification for the web container – the specification states that it must be provided by the container but unfortunately not how! – see table EE.6-1 in the Java EE 5 platform specification about required Java Optional Packages.
WebLogic provides different JSF implementations (Sun RI 1.2 dating back to 2007, Sun RI 1.1.1, MyFaces 1.1.1 and MyFaces 1.1.3) which have to be deployed as library. A good intention to give developers a choice but with the implication that the deployed library is only partially visible to the web application. I got a good hint from the JBoss Seam reference documentation:

For some reason, even with the steps above classes in the jsf-api.jar are not found during application deployment. The only way for this to work is to put the javax.jsf_1.2.0.0.jar (the jsf-api.jar) from jsf-1.2.war in the domains shared library. This requires a restart of the server.

In addition to the javax.jsf_1.2.0.0.jar I had to add glassfish.jsf_1.2.3.2.jar to the lib directory as well to get it to work.
So far no changes had to be made to the web applications deployment descriptor, but now JSF could still not be started. The remaining issue was to include a configuration listener for the RI in the web.xml deployment descriptor:

<listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>

Being forced to use this descriptor makes the web application incompatible with MyFaces! Therefor it is commented out by default and has to be enabled in [fleXive] if deployed on WebSphere …

A step by step instruction how to deploy [fleXive] can be found in the [fleXive] wiki.

Older Posts »

Blog at WordPress.com.