ZK 3.6.3 and ZK5.0rc with Glassfish V3 and EE6

15 11 2009

In my previous post I described how to get a EE6 web application using the ZK3.6.3 framework on Glassfish V3. I noted while redeploying or undeploying the web-application it made the GF instance plus the JVM crash (running Ubuntu 9.04,9.10 and JDK 1.6.b16).

This problem does NOT exist anymore with the latest build from last week. Make sure you update to build b72. Start the updatetool in glassfish-home/bin. (you might have to start it several times, I got several times time-out errors, or better click on the reminder if you choose the automatic update check feature).

SVH20091115_001

Glassfish V3b72





Glassfish V3 and Icefaces (2)

11 02 2009

Following Ted’s advice I de-installed Glassfish V3 (I already had installed JSF 2.0 update) and re-installed to get back the earlier version of JSF (1.2)

fdgh

Glassfish V3 with updated JSF 2.0

fghfgh

Initial installation of V3 prelude with JSF 1.2

This time I can place a couple of IceFaces components (without binding or any configuration) and run the project under V3 prelude.

fghfgh

Icefaces components

Now, I am going back to my CRUD sample project I initially wanted to explore. Placing a datatable on the JSF page. The datatable is shown.

dfg

Icefaces datatable

The problem start after I bind to a datasource (by dropping the table onto the datatable)

fghgfh

Drag and Drop table on datatable

Running the project gets me couple of errors, I need to sort out now.

ertet

Server Error


SEVERE: JSF1054: (Phase ID: RENDER_RESPONSE 6, View ID: /Page1.jsp) Exception thrown during phase execution: javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@498b0]
WARNING: JSF1053: (Listener: com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl.afterPhase(), Phase ID: RENDER_RESPONSE 6,  View ID: /Page1.jsp) Exception thrown during phase-listener execution: com.sun.rave.web.ui.appbase.ApplicationException: The cachedRowSet property is null
WARNING: com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl.cleanup(ViewHandlerImpl.java:537)
com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl.afterPhase(ViewHandlerImpl.java:424)
com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:175)




Glassfish V3 and Icefaces

10 02 2009

I started using Glassfish V3 prelude for development. By the time my development cycles nears production release, V3 should be officially released. I downloaded/activated the ICEFaces plugin for NB 6.5 and created and run the simple CRUD sample which fails, despite successful deployment.

init:
deps-module-jar:
deps-ear-jar:
deps-jar:
library-inclusion-in-archive:
library-inclusion-in-manifest:
compile:
compile-jsps:
Undeploying ...
undeploy?name=CollaborativeCRUD running on GlassFish V3
undeploy?name=CollaborativeCRUD completed on GlassFish V3
In-place deployment at X:\svn_NOTYET_JAVA_VAR\CollaborativeCRUD\build\web
Initializing...
deploy?path=X:\svn_NOTYET_JAVA_VAR\CollaborativeCRUD\build\web&name=CollaborativeCRUD&force=true&properties=keepSessions=true running on GlassFish V3
deploy?path=X:\svn_NOTYET_JAVA_VAR\CollaborativeCRUD\build\web&name=CollaborativeCRUD&force=true&properties=keepSessions=true completed on GlassFish V3
run-deploy:
BUILD SUCCESSFUL (total time: 7 seconds)

INFO:
ICEsoft Technologies, Inc.
ICEfaces 1.7.2 SP1b
Build number: 1
Revision: 18093

Creating this error when running the project

SEVERE: StandardWrapperValve[Persistent Faces Servlet]: PWC1406: Servlet.service() for servlet Persistent Faces Servlet threw exception
java.lang.UnsupportedOperationException
        at javax.faces.context.FacesContext.setCurrentPhaseId(FacesContext.java:644)
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:87)
        at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:107)

I dont have a solution yet, but to continue with V2 and wait for the production release 1.8 of ICEFaces which will support V3 fully (planned for this February).





Application Framework

9 02 2009

Looking around for a nice browser based application framework I stumbled upon 3 opensource products that are somehow integrated into the Netbeans and Glassfish world.

  • Icefaces (Woodstock migrated here) | link
  • ZK direct RIA | link
  • JMaki / Dojo | link | link

I will evaluate these 3 and report about the results here. While Icefaces and ZK are clearly enterprise enabled frameworks, JMaki is a rather consumer application orientated framework. I might be wrong with this statement, but this is my first tast bitting on it. ZK seems closer to Spring and Tomcat than Netbeans and Glassfish.





Install Glassfish on a virtual server (Part 2)

18 01 2009

Using the same virtual server I tried to install Glassfish V3 (prelude) which comes in a 26MB zip-file. At least I would avoid the installer complaining about not enough memory available. After unzipping the server and with proper JAVA_HOME path all we need to do is to start the server with /glassfishv3-prelude/glassfish/bin/asadmin start-domain

Starting: java -jar -Xmx128m admin-cli.jar start-domain (here with 128MB setting)

I would get the same error in the logfile in domain1/logs/jvm.log

<tty>
<writer thread='-1209660528'/>
Error occurred during initialization of VM
Could not reserve enough space for object heap
<tty_done stamp='0.013'/>
</tty>
<hotspot_log_done stamp='0.013'/>
</hotspot_log>

Conclusion (again): You need more than the 256MB priced virtual server.

Links:
Glassfish V3 prelude
SUN Quickstart Guide





Install Glassfish on a virtual server

11 01 2009

If you happen to rent a virtual server, you might want to check the mem limits first before starting an endeavour to install Glassfish on it. The installer requires more than 256MB which is the confirmed available memory of my virtual box. I get this straight away:

h000000:/opt # sudo java -Xmx256m -jar glassfish-installer-v2ur2-b04-linux.jar
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

Doesnt matter what mem value I assign, I get the same answer. I gave up on this and move on to another (bigger) V server.

Some Links:

  • SUN Installation Doc (link)
  • Plasticboy Blog (link)
  • Plugin Smithy Software Blog (link)




Tutorial: Starting with Glassfish and JMS (Part 2)

9 01 2009

Today we proceed with last weeks JMS tutorial and create a standalone java application that sends a message to a topic.

It puzzles me to have a client application that I need to start “from within”. Lets find out how an application looks like that can run by itself, connect to a JNDI server and sends a message to topic. The key information I took from this discussion (link, Thanks to Foli and TravelEntity) at forums.sun.com.

Using: Netbeans 6.5 and a local Glassfish V2

1. Lets create a standard SE java project. We call it “JMSClient”

tut09010005_new_java_application

JMSClient: New Java SE project

2. Import the necessary libraries

Applicationserver JNDI Lookup
/lib/appserv-rt.jar
/lib/appserv-admin.jar
/lib/javaee.jar
/lib/j2ee.jar

Client Lib
/imq/lib/jms.jar
/imq/lib/imq.jar
/imq/lib/imqutil.jar
/lib/install/applications/jmsra/jmsra.jar

(You find them in your glassfish home directory)

Libraries

JMSClient: Libraries

3. The complete source


package jmsclient;

import java.util.Hashtable;
import java.util.Queue;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
import javax.jms.MapMessage;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.Topic;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class Main {

    public static void main(String[] args) {

        Context jndiContext = null;
        ConnectionFactory connectionFactory = null;
        Connection connection = null;
        Session session = null;
        // ---- Same sample with a queue ----
        // Queue queue = null;
        Topic topic = null;
        MessageProducer messageProducer = null;
        MapMessage message = null;

        Hashtable properties = new Hashtable(2);
        properties.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.appserv.naming.S1ASCtxFactory");
        properties.put(Context.PROVIDER_URL, "iiop://localhost:3700");

        try {
            jndiContext = new InitialContext(properties);
            connectionFactory = (ConnectionFactory)jndiContext.lookup("jms/ConnectionFactory");
            // ---- Same sample with a queue ----
            //queue = (Queue)jndiContext.lookup("jms/Queue");
            topic = (Topic)jndiContext.lookup("jms/Topic");

            connection = connectionFactory.createConnection();
            session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            // ---- Same sample with a queue ----
            //messageProducer = session.createProducer(queue);
            messageProducer = session.createProducer(topic);
            message = session.createMapMessage();

            // ---- Preparing Mapped Message ----
            message.setString("lastname", "Myer");
            message.setString("firstname", "Fred");
            message.setString("id", "0200");

            messageProducer.send(message);

            connection.close();

        } catch (NamingException e) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, e);
        }
        catch (JMSException e) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, e);
        }
        finally {
            System.out.println("ENDED.");
            System.exit(0);
        }
    }
}

Remarks:

  • The tutorial is looking for a local server. Change (Context.PROVIDER_URL, “iiop://localhost:3700″) to the relevant server and port info.
  • We use a topic (publish/subscribe) in this sample. If you want to use a queue instead, change to the lines which are commented out and remove the topic related lines.




Tutorial: Starting with Glassfish and JMS

3 01 2009

Despite tons of material, downloads and websites on JAVA enterprise applications, tools and features, there are few sources only for “Let’s get started” styled tutorials. The Netbeans tutorial is often the best starting point (link).

I was reading about the background of JMS, some of the material is of a very theoretical nature and I tried to find some simple sample to get my hands dirty. A good short article on JMS in the glassfish context you can find at java.net (link)

This tutorial describes the steps to get a most simple messaging application up and running implementing a one-to-many communication using topics, also called publish-subscribe. A enterprise client creates a message put it on a topic and a message-driven bean (MDB) retrieves the message.

Using: Netbeans 6.5 with installed Glassfish V2.

1. Creating a new JAVA EE project.

MyJMS Project

MyJMS Project: New Project

2. We call it MyJMS. Disable the web-application and enable application-client

My

MyJMS Project: New EE Application

3. We will have a project window with 2 subprojects for the EJB and the application client.

d

MyJMS Project

4. Before we start with the coding of the EJB and the client, we configure the applicationserver. Open the admin console via right click on the application server under services (Start the server first, if not done yet). You remember the default admin password for glassfish ? “adminadmin”.You better change if your box is open to outside world.

tut09010003_

MyJMS: View Admin Console

In the admin console we create the ressources for the JMS topic.

tut09010006_

MyJMS: Add Resources

Create a destination resource with JNDI name “jms/topic” and Resource type “javax.jms.topic” (rest default settings).
Create a connection factory with the JNDI name “jms/TopicFactory” (rest default settings, but remove username and password).

Read the rest of this entry »