Recent Posts
Archives

Posts Tagged ‘Java’

PostHeaderIcon Tutorial: an Event Bus Handler for GWT / GXT

Overview

Introduction

Let’s consider a application, JonathanGwtApplication, divided in three main panels

  • a panel to select animal name name
  • a panel to display, expand and collapse trees of the animal ancestors
  • a panel of information to display many indicators (colors, ages, etc.).

An issue we encounter is: how to make the different panels communicate? In more technical terms, how to fire events from a panel to another one?

A first solution would be to declare each panel as listener to the other panels. Indeed, this principle may go further, and declare each component as listener to a list of other components…
Main drawbacks:

  • the code becomes hard to read
  • adding or removing a component requires to modify many parts of the code
  • we don’t follow GWT 2’s “philosophy”, which is to use Handlers rather than Listeners.

Hence, these reasons incited us to provide a global EventBusHandler.

The EventBusHandler concept

The EventBusHandler is a global bus which is aware of all events that should be shared between different panels, and fires them to the right components.
The EventBusHandler is a field of JonathanGwtApplicationContext.

Intrastructure

  • lalou.jonathan.application.web.gwt.animal.events.HandledEvent: generic interface for a event. Abstract method:
    [java]EventTypeEnum getEventEnum();[/java]
  • lalou.jonathan.application.web.gwt.animal.handler.EventHandler: generic interface for a component able to handle an event. Abstract method:
    [java]void handleEvent(HandledEvent handledEvent);[/java]
  • lalou.jonathan.application.web.gwt.animal.handler.EventHandlerBus: the actual bus. As a concrete class, it has two methods:
    [java]/**
    * Fires an event to all components declared as listening to this event
    * event type.
    *
    * @param baseEvent
    */
    public void fireEvent(HandledEvent baseEvent) {
    // …
    }

    /**
    * Adds an listener/handler for the event type given as parameter
    *
    * @param eventTypeEnum
    * @param eventHandler
    * @return The List of handlers for the key given as parameter. This list
    * contains the eventHandler that was given as second parameter
    */
    public List<EventHandler> put(EventTypeEnum eventTypeEnum,
    EventHandler eventHandler) {
    // …
    }[/java]

How to use the bus?

  1. Define an event: in JonathanGwtApplication, an event is decribed by two elements:
    • a functionnal entity: eg: “animal”, “food”, “tree node”. The functionnal entity must be isomorph to a technical DTO, eg: AnimalDTO for an entity Animal.(in the scope of this turoriel we assume to have DTOs, even though the entities may ne sufficient)
    • a technical description of the event: “selection changed”, “is expanded”
  2. Add an entry in the enum EventTypeEnum. Eg: “ANIMAL_SELECTION_CHANGED
  3. in lalou.jonathan.application.web.gwt.animal.events, create an event, implementing HandledEvent and its method getEventEnum(). The match between EventTypeEnum and DTO is achieved here. Eg:
    [java]public class AnimalSelectionChangedEvent extends
    SelectionChangedEvent<AnimalDTO> implements HandledEvent {

    public AnimalSelectionChangedEvent(
    SelectionProvider<AnimalDTO> provider,
    List<AnimalDTO> selection) {
    super(provider, selection);
    }

    public EventTypeEnum getEventEnum() {
    return EventTypeEnum.ANIMAL_SELECTION_CHANGED;
    }

    }[/java]

  • When an event that should interest other component is fired, simply call the bus. The bus will identify the event type and dispatch it to the relevant handlers. eg:
    [java]animalComboBox.addSelectionChangedListener(new SelectionChangedListener<AnimalDTO>() {

    @Override
    public void selectionChanged(SelectionChangedEvent<AnimalDTO> se) {
    final AnimalDTO selectedAnimalVersion;
    selectedAnimalVersion= se.getSelectedItem();
    JonathanGwtApplicationContext.setSelectedAnimal(selectedAnimal);

    final AnimalSelectionChangedEvent baseEvent = new AnimalSelectionChangedEvent(
    se.getSelectionProvider(), se.getSelection());
    JonathanGwtApplicationContext.getEventHandlerBus()
    .fireEvent(baseEvent);

    }
    });[/java]

  • Handlers:
    • easy case: the component handles only one type of event: this handler must implement the right interface (eg: AnimalSelectionChangedEventHandler) and its method, eg:
      [java]protected void handleAnimalSelectionChangedEvent(HandledEvent handledEvent) {
      return;
      }[/java]
    • frequent case: the component handles two or more event types. No matter, make the component implement all the needed interfaces (eg: AnimalSelectionChangedEventHandler, FoodSelectionChangedEventHandler). Provide a unique entry point for the method to implement, which is common to both interfaces. Retrieve the event type, and handle it with ad hoc methods. Eg:
      [java]public void handleEvent(HandledEvent handledEvent) {
      final EventTypeEnum eventTypeEnum;

      eventTypeEnum = handledEvent.getEventEnum();

      switch (eventTypeEnum) {
      case ANIMAL_SELECTION_CHANGED:
      handleAnimalSelectionChangedEvent(handledEvent);
      return;
      case FOOD_SELECTION_CHANGED:
      handleFoodSelectionChangedEvent(handledEvent);
      return;
      default:
      break;
      }
      }

      protected void handleAnimalSelectionChangedEvent(HandledEvent handledEvent) {
      // do something
      }
      protected void handleFoodSelectionChangedEvent(HandledEvent handledEvent) {
      // do something else
      }[/java]

  • PostHeaderIcon org.hibernate.HibernateException: identifier of an instance of … was altered from … to 0

    Case

    Stracktrace

    org.hibernate.HibernateException: identifier of an instance of lalou.jonathan.domain.Foo was altered from 183740934 to 0

    Sometimes, the error is slightly different: was altered from XXXX to null

    Here is a part of Hibernate mapping:

    [xml]<id name="fooId" column="fooId">
    <generator class="seqhilo">
    <param name="sequence">JL_Foo_SEQ</param>
    <param name="max_lo">10</param>
    </generator>
    </id>[/xml]

    Here is the Java code:

    [java]Foo sourceFoo = FooDAO.findById(xxxx);
    Foo foo = new Foo();
    foo = BeanUtils.copyProperties(sourceFoo);
    foo.setFooId(null);
    FooDAO.createFoo(foo);[/java]

    Explanation

    Using new Foo() instantiates an object of type Foo, with all its fields initialized at null (or zero for ints, floats, etc.). Writing explicitly foo.setFooId(null) removes the object from Hibernate current session.

    Fix

    Don’t set explicitly the fooId! Leave Hibernate initialize default values, and set handly other values, without using BeanUtils.

    PostHeaderIcon WebLogic Deployment with Maven: Dynamic Property Settings

    Case

    You have to deploy a WAR archive on a WebLogic server. To simplify the deployment process, you use weblogic-maven-plugin. Then, you only have to launch a mvn clean install weblogic:deploy to compile and deploy the WAR.

    Actually, the plugin configuration expects you to hard write the settings in the pom.xml, such as:

    [xml]<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>weblogic-maven-plugin</artifactId>
    <version>2.9.1</version>
    <configuration>
    <name>myWebApplication-web</name>
    <adminServerHostName>localhost</adminServerHostName>
    <adminServerPort>7001</adminServerPort>
    <adminServerProtocol>t3</adminServerProtocol>
    <targetNames>myTargetServer</targetNames>
    <userId>myUserId</userId>
    <password>myPassword</password>
    <securitymodel>Advanced</securitymodel>
    <artifactPath>${project.build.directory}/myWebApplication-web.war</artifactPath>
    </configuration>
    </plugin>[/xml]

    Yet, when you work on a multi-environment / multi-developper platform, hard writing the properties bothers. Production teams are not pleased, and, above all, it’s not safe.

    Unworking fix

    At first glance, I tried to use Maven filtering mechanisms. Anyway, this features was designed for compilation phase: properties are recopied from a property file to the actual one, and then included in the archive generated (may it be JAR, EAR or WAR); in a deployment phase, properties are not taken in account.
    http://maven.apache.org/guides/getting-started/index.html#How_do_I_filter_resource_files

    Unelegant fix

    Another solution is to set properties by profile. This works, but is not elegant at all: the password for production environment has to reason to be readable in the pom.xml used by a developper!

    Fix

    WebLogic / Maven plugin

    Add the following block:

    [xml]<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>weblogic-maven-plugin</artifactId>
    <version>2.9.1</version>
    <configuration>
    <name>myWebApplication-web</name>
    <adminServerHostName>${weblogic.server.name}</adminServerHostName>
    <adminServerPort>${weblogic.server.port}</adminServerPort>
    <adminServerProtocol>${weblogic.server.protocol}
    </adminServerProtocol>
    <targetNames>${weblogic.target}</targetNames>
    <userId>${weblogic.user}</userId>
    <password>${weblogic.password}</password>
    <securitymodel>${weblogic.security}</securitymodel>
    <artifactPath>${project.build.directory}/myWebApplication-web.war
    </artifactPath>
    </configuration>
    </plugin>[/xml]

    Properties / Maven plugin

    Under the tag, add the block:

    [xml]<properties>
    <weblogic.server.name>${myTargetServer.server.name}</weblogic.server.name>
    <weblogic.server.port>${myTargetServer.server.port}</weblogic.server.port>
    <weblogic.server.protocol>${myTargetServer.server.protocol}</weblogic.server.protocol>
    <weblogic.user>${myTargetServer.user}</weblogic.user>
    <weblogic.password>${myTargetServer.password}</weblogic.password>
    <weblogic.target>${myTargetServer.target}</weblogic.target>
    <weblogic.security>${myTargetServer.security}</weblogic.security>
    </properties>[/xml]

    Within the block, add the the following block:

    [xml]
    <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>properties-maven-plugin</artifactId>
    <version>1.0-alpha-2</version>
    <executions>
    <execution>
    <phase>initialize</phase>
    <goals>
    <goal>read-project-properties</goal>
    </goals>
    <configuration>
    <files>
    <file>conf/${maven.user}.myTargetServer.properties</file>
    </files>
    </configuration>
    </execution>
    </executions>
    </plugin>[/xml]

    Settings.xml

    Optionnaly, in your settings.xml, in your default profile, set the following property:

    [xml]<profile></pre>
    <id>myDefaultProfile</id>
    <properties>
    <maven.user>jonathan_lalou</maven.user>
    </properties>
    </profile>[/xml]

    You can decide to bypass this step. In this case, you will have to add the following parameter on launching Maven:
    -Dmaven.user=jonathan_lalou

    Property file

    Create a property file, with a name corresponding to the one you specified in maven.user property.

    [java]
    myTargetServer.server.name=localhost
    myTargetServer.server.port=7001
    myTargetServer.server.protocol=t3
    myTargetServer.user=myUserId
    myTargetServer.password=myPassword
    myTargetServer.target=myTargetServer
    myTargetServer.security=Advanced[/java]

    Now, you can launch mvn package weblogic:deploy. The WAR will be deployed on the right server.

    PostHeaderIcon Dynamic serviceUrl with Spring’s HttpInvokerProxyFactoryBean

    Abstract

    How to set dynamically the URL used by a HttpInvokerProxyFactoryBean in a Spring-deployed WAR?

    Detailed Case

    I have to deploy a GWT/GXT application, calling two distant services:
    a remote EJB
    a service accessed through Spring Remoting

    Here is the Spring configuration file I firstly used:

    [xml]
    <util:properties id="jndiProperties" location="classpath:jndi.properties"/>
    <jee:remote-slsb id="myRemoteEJBService" jndi-name="ejb.remote.myRemoteService"
    business-interface="lalou.jonathan.myRemoteEJBService"
    environment-ref="jndiProperties" cache-home="false"
    lookup-home-on-startup="false" refresh-home-on-connect-failure="true" />

    <bean id="mySpringRemoteService"
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
    <property name="serviceInterface"
    value="lalou.jonathan.services.mySpringRemoteService" />
    <property name="serviceUrl" value="${spring.remote.service.url}"/>
    </bean>
    [/xml]

    Unhappily, even though the remote EJB is retrieved (which proves that the jndi file is available in the classpath and rightly loaded), the Spring Remote service is not. I had to write the URL in hard in the configuration file… This is not very efficient when you work in a large team, with different production and testings environments!

    This is the log when myRemoteEJBService bean is loaded:
    [java]2010-08-17 16:05:42,937 DEBUG support.DefaultListableBeanFactory – Creating shared instance of singleton bean ‘myRemoteEJBService’
    2010-08-17 16:05:42,937 DEBUG support.DefaultListableBeanFactory – Creating instance of bean ‘myRemoteEJBService’
    2010-08-17 16:05:42,937 DEBUG support.DefaultListableBeanFactory – Eagerly caching bean ‘myRemoteEJBService’ to allow for resolving potential circular references
    2010-08-17 16:05:42,937 DEBUG support.DefaultListableBeanFactory – Returning cached instance of singleton bean ‘jndiProperties’
    2010-08-17 16:05:42,937 DEBUG support.DefaultListableBeanFactory – Invoking afterPropertiesSet() on bean with name ‘myRemoteEJBService’
    2010-08-17 16:05:42,937 DEBUG framework.JdkDynamicAopProxy – Creating JDK dynamic proxy: target source is EmptyTargetSource: no target class, static
    2010-08-17 16:05:42,953 DEBUG support.DefaultListableBeanFactory – Finished creating instance of bean ‘myRemoteEJBService'[/java]

    That is the log when mySpringRemoteService is loaded:
    [java]2010-08-17 16:05:42,968 DEBUG support.DefaultListableBeanFactory – Creating shared instance of singleton bean ‘mySpringRemoteService’
    2010-08-17 16:05:42,968 DEBUG support.DefaultListableBeanFactory – Creating instance of bean ‘mySpringRemoteService’
    2010-08-17 16:05:42,984 DEBUG support.DefaultListableBeanFactory – Eagerly caching bean ‘mySpringRemoteService’ to allow for resolving potential circular references
    2010-08-17 16:05:43,234 DEBUG support.DefaultListableBeanFactory – Invoking afterPropertiesSet() on bean with name ‘mySpringRemoteService’
    2010-08-17 16:05:43,250 DEBUG framework.JdkDynamicAopProxy – Creating JDK dynamic proxy: target source is EmptyTargetSource: no target class, static
    2010-08-17 16:05:43,250 DEBUG support.DefaultListableBeanFactory – Finished creating instance of bean ‘mySpringRemoteService'[/java]

    You can notice that no mention to jndiProperties appears. Here is the key of the problem: jndiProperties is considered as a bean among others, which cannot be accessed easyly from the HttpInvokerProxyFactoryBean.

    Fix

    To fix the issue, you have to add an actual property holder in Spring XML configuration file, ie after:

    [xml]<util:properties id="jndiProperties" location="classpath:jndi.properties"/>[/xml]

    add an instanciation of PropertyPlaceholderConfigurer:

    [xml]<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location" value="classpath:jndi.properties"/>
    </bean>[/xml]

    PostHeaderIcon Deploy a webservice under Mule ESB using CXF

    This short tutorial is aimed at showing the main steps allowing to deploy a WebService, using CXF framework, under a Mule ESB instance.

    Java code

    Declare an interface:

    [java]@WebService
    public interface BasicExampleServices {
    @WebResult(name = "myReturnedInteger")
    Integer getInteger(@WebParam(name="myInteger") Integer myInteger);
    }[/java]

    Implement this interface:

    [java]@WebService(endpointInterface = "com.lalou.jonathan.services.BasicExampleServices", serviceName = "basicExampleServices")
    public class WSBasicExampleServices implements BasicExampleServices {

    public Integer getInteger(Integer param) {
    return 12345;
    }
    }[/java]

    XML files

    Create a Spring config file ws-basicExample.xml:

    [xml]<?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

    <bean id="basicExampleService" scope="singleton"/>
    </beans>[/xml]

    Create a Mule configuration file ws-basicExample-config.xml:

    [xml]<?xml version="1.0" encoding="UTF-8" ?>
    <mule xmlns="http://www.mulesource.org/schema/mule/core/2.2"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:spring="http://www.springframework.org/schema/beans"
    xmlns:management="http://www.mulesource.org/schema/mule/management/2.2"
    xmlns:stdio="http://www.mulesource.org/schema/mule/stdio/2.2"
    xmlns:cxf="http://www.mulesource.org/schema/mule/cxf/2.2"
    xmlns:jetty="http://www.mulesource.org/schema/mule/jetty/2.2"
    xsi:schemaLocation="http://www.mulesource.org/schema/mule/management/2.2
    http://www.mulesource.org/schema/mule/management/2.2/mule-management.xsd
    http://www.mulesource.org/schema/mule/core/2.2
    http://www.mulesource.org/schema/mule/core/2.2/mule.xsd
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    http://www.mulesource.org/schema/mule/vm/2.2
    http://www.mulesource.org/schema/mule/vm/2.2/mule-vm.xsd
    http://www.mulesource.org/schema/mule/cxf/2.2
    http://www.mulesource.org/schema/mule/cxf/2.2/mule-cxf.xsd
    http://www.mulesource.org/schema/mule/stdio/2.2
    http://www.mulesource.org/schema/mule/stdio/2.2/mule-stdio.xsd">

    <spring:beans>
    <spring:import resource="ws-basicExample.xml"/>
    </spring:beans>

    <model name="wsBasicExampleModel">
    <service name="wsBasicExampleService">
    <inbound>
    <cxf:inbound-endpoint address="http://localhost:8282/services/basicExampleServices"/>
    </inbound>
    <component>
    <spring-object bean="basicExampleService"/>
    </component>
    </service>
    </model>
    </mule>

    [/xml]

    Checks

    • Run the Mule, pointing your config file.
    • In your favorite webbrowser, open the URL:
      [xml]http://localhost:8282/services/basicExampleServices?wsdl[/xml]
    • The webservice contract is expected to be displayed.

    • You can also execute a runtime test:

      [java]public class WSBasicExampleServicesRuntimeTest {

      private BasicExampleServices basicExampleServices;

      @Before
      public void setup() {
      JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
      factory.getInInterceptors().add(new LoggingInInterceptor());
      factory.getOutInterceptors().add(new LoggingOutInterceptor());
      factory.setServiceClass(BasicExampleServices.class);
      factory.setAddress("http://localhost:8282/services/basicExampleServices");
      basicExampleServices = (BasicExampleServices) factory.create();
      }

      @Test
      public void testGetInteger() {
      final Integer expectedAnswer = 12345;
      final Integer actualAnswer;
      final Integer param = 912354;

      actualAnswer = basicExampleServices.getInteger(param);

      assertNotNull(actualAnswer);
      assertEquals(expectedAnswer, actualAnswer);
      }

      }[/java]

    PostHeaderIcon No source code is available for type org.junit.Assert; did you forget to inherit a required module?

    Case

    You run a GWT application, with a a service layer. Those services are tested through unit tests, which may use EasyMock, among other frameworks. Of course, you hinted at related jars, such us JUnit, by a <scope>test</scope> in your pom.xml.

    Yet, when you run the GWT application with a Jetty light container, you get the following message:

    Compiling module lalou.jonathan.gwt.client.MyModule

    Validating newly compiled units

    [java][ERROR] Errors in ‘file:/C:/eclipse/workspace/…/test/unit/lalou/jonathan/gwt/client//MyServiceUnitTest.java’
    [ERROR] Line 26: No source code is available for type org.easymock.MockControl; did you forget to inherit a required module?
    [ERROR] Line 76: No source code is available for type org.junit.Assert; did you forget to inherit a required module?[/java]

    Fix

    Since Maven2 and GWT scopes are fully independant, you have to modify you *.gwt.xml. Replace:

    [xml] &lt;source path=’client’/&gt;[/xml]

    with:

    [xml]&lt;source path=’client’ excludes=&quot;**/*UnitTest.java,**/*RuntimeTest.java&quot;/&gt;[/xml]

    NB: Never forget that Google teams work with Ant, and not with Maven!

    PostHeaderIcon No source code is available for type … ; did you forget to inherit a required module?

    Context

    In a GWT application, you have to use RPC calls, using entities which are package in external jar archives. With Eclipse, no error appears ; yet when you build the project with Maven2, you get this message:

    [java][INFO] [ERROR] Errors in ‘file:/C:/eclipse/workspace/myGwtProject/src/java/com/lalou/jonathan/web/gwt/client/component/JonathanPanel.java’
    (…)
    [INFO] [ERROR] Line 24: No source code is available for type com.lalou.jonathan.domain.MyEntity; did you forget to inherit a required module?
    (…)
    [INFO] Finding entry point classes[/java]

    Fix

    In related jar

    In the project to which MyEntity belongs to (here: my/depended/project):

    • create a file com/lalou/jonathan/MyDependedProject.gwt.xml, with as content:

      [xml]<module>
      <source path="">
      <include name="**/MyEntity.java"/>
      </source>
      </module>[/xml]

    • In the pom.xml:
      • Add the source MyEntity.java in built jar. This way, the Java file itself will be considered as a resource, like an XML or property file. To perform this, the quickest manner is to add the following block in the pom.xml:
        [xml]<resources>
        <resource>
        <directory>${basedir}/src/java</directory>
        <includes>
        <include>**/MyEntity.java</include>
        </includes>
        </resource>
        </resources>[/xml]
      • Add an <include>**/*.gwt.xml</include> so that to have to MyDependedProject.gwt.xml file in the built jar.

      In GWT project

      In your *.gwt.xml file, add the dependency:

      [xml]<inherits name=’com.lalou.jonathan.MyDependedProject’ />[/xml]

      Caution!

      All these operations need be done on all dependencies -either direct or indirect-. Therefore, possibly you may have a huge amount of code to be got.
      Another issue appears when you use a jar of which you do not have the source code, such as in the case of tiers API for instance.

    PostHeaderIcon Basic RPC call with GWT

    Let’s assume you have a “Hello World” GWT application. You need emulate a basic RPC call (RMI, EJB, etc.). Here is the program:

    Under the *.gwt.client folder:

    Create an service interface:

    [java]@RemoteServiceRelativePath("fooService")
    public interface FooService extends RemoteService {
    public String getHelloFoo(String totoName);
    }[/java]

    Create another interface for asynchronous call. You can notice the method name differs lightly from the one in the other interface:

    [java]public interface FooServiceAsync {
    void getHelloFoo(String fooName, AsyncCallback<String> callback);
    }[/java]

    Under the *.gwt.server folder, create an implementation for service interface:

    [java]public class FooServiceImpl extends RemoteServiceServlet implements FooService {
    public FooServiceImpl() {
    // TODO init
    }

    public String getHelloFoo(String fooName) {
    // TODO call actual service
    return "hello world!";
    }
    }[/java]

    In the web.xml file, add the following blocks:

    [xml] <!– Servlets –>
    <servlet>
    <servlet-name>fooService</servlet-name>
    <servlet-class>com…….server.FooServiceImpl</servlet-class>
    </servlet>

    <servlet-mapping>
    <servlet-name>fooService</servlet-name>
    <url-pattern>/ivargwt/fooService</url-pattern>
    </servlet-mapping>
    [/xml]

    The tags content match the argument given as parameter to RemoteServiceRelativePath annotation above.

    From then, in your concrete code, you can instantiate the service and call remote method:

    [java]FooServiceAsync fooService = GWT.create(FooService.class);
    fooService.getHelloFoo("how are you?", new AsyncCallback<String>() {

    public void onSuccess(String result) {
    MessageBox.alert("OK", result, null);
    }

    public void onFailure(Throwable caught) {
    MessageBox.alert("ERROR", "rpc call error-" + caught.getLocalizedMessage(), null);
    }
    });
    [/java]

    Now you can compile, package your war and deploy under Tomcat or WebLogic.

    NB: special to “black-belt GWT guy” David Chau from SFEIR.

    PostHeaderIcon GWT to GXT migration

    These days, I am discovering GWT, and more accurately ExtGWT, aka GXT.

    Case

    I have to write a “Hello World” application based on GXT.

    Steps

    • Firstly, follow Lars Vogel’s tutorial to have a “Hello World” in GWT.
    • In Eclipse, add a dependancy from your project to extjs-gxt-lib-2.1.1.jar (version compatible with your GWT version: 1.7 or 2.0), available at this link.
    • In your *.gwt.xml file, remove:
      [xml]<inherits name=’com.google.gwt.user.theme.standard.Standard’/>[/xml]

      and add:

      [xml]<inherits name=’com.extjs.gxt.ui.GXT’/>[/xml]

    • Get the gxt-all.css file, copy it into war/css/ folder
    • In your *.html file, add the lines:
      [xml]<link rel="stylesheet" type="text/css" href="css/gxt-all.css" />[/xml]
    • Now, adapt your Java entry point source class, replacing GWT widgets with GXT ones.
    • Restart your server and refresh the page in your browser. You have your “Hello World” in GXT!

    PostHeaderIcon WebLogic 10.x new features

    Recent history

    BEA WebLogic 9.0, 9.1 and 9.2 were released from 2007: the main features were: a new console, WLST (WebLogic ScriptingTool), deployment plans, WebLogic Diagnostic Framework (WLDF), new security providers (RDBMS, SAML 1.1, etc.), JMS performance improvements, support of Java EE 4, JDK 5, Spring, OpenJPA, Kodo, etc.

    Since this date, some events happened:

    • Oracle bought Sun (2009)
    • Oracle released WebLogic 10.3 (2008)
    • Oracle bought BEA (2008)

    WebLogic Server 10 General Features

    • Developer productivity ehancements
      • JDK 6, Java EE 5
      • Support of EJB3 and JPA
      • BEA enhancements
    • Web Services: more annotations, less XML
      • JAX-RPC Web Services Enhancements
      • JAX-WS 2.0 Web Services Implementation
    • Misc:
      • Better administration console
      • Auto-Record of Admin Console actions as WLST scripts
      • Automatic JTA Transaction Recovery Service (TRS) migration
      • SNMP 3.0
      • Production Application Redeployment enhancements
      • Clustering – Unicast messaging (in addition to Multicast)

    Programmer Perspective

    • New persistence engine: TopLink
    • OEPE (Oracle Entreprise Pack for Eclipse): sequence of tools and plugins for Eclipse: remote deployment, debugging,  editors for weblogic.xml and weblogic-application.xml, wizards, facets, Weblogic ClientGen, WSDLC and JAXB wizards
    • Optimizations for Spring integration and certication
    • Web 2.0:
      • Ajax / Dojo client support
      • Http publish / submit engine for collaborative applications:
        • Bayeux protocol
        • data exchange within applications over persistent connections
        • scalability for Dojo clients
    • Ad-hoc tools for:
      • Oracle Database
      • Spring
      • JAX-WS webservices

    Lightweight WebLogic Server

    WebLogic 10 offers a light weight server:

    • Install only “core” WebLogic server
    • Optionally, startup other services (JDBC, EJB, JMS, etc.)
    • FastSwap: modify classes without requiring redeployment.

    Architect Perspective

    Architects have to consider WebLogic as a complete suite, and not only WebLogic Server:

    • Oracle RAC integration: Connectivity to RAC with load balancing, failover, transactions
    • Enterprise Messaging with JMS: High performance and reliable JMS messaging engine “built-in”
    • ActiveCache with Coherence*Web and EJB/JPA: Coherence Data Grid caching included and integrated
    • Operations Automation: Tools for automating management of applications and servers
    • Operations Insight: Tools for diagnosing problems in development and production
    • Other features
      • Development tools: Choice of tools for developer productivity
      • Web Services: Enterprise Web Services for SOA
      • TopLink: Persist application data to stores with performance and productivity. It works in a way similar to Hibernate L2 cache.
      • Spring: Enable flexible choice of dev frameworks with same WebLogic QOS

    Production and Support Perspective

    WebLogic 10 provides a tool: JRockit Mission Control

    • monitors more than 150 parameters:
    • CPU
      • memory
      • leaks
      • latency spikes
      • threads
      • object references
      • JDBC connections
      • JMS
      • pools
      • clusters
      • configuration files
      • etc.
    • allows to compare WebLogic domains
    • Runtime Analyzer: runtime capture for offline analysis, Garbage Collector analysis, etc.

    Coherence – ActiveCache

    Coherence is the Data Grid offered by Oracle. It allows to store Java objects in memory, and share them between all instances. From a certain viewpoint, Coherence looks like the GigaSpaces.

    Roadmap for Future WebLogic Releases

    • Support of Java EE 6 (ratified by the community in last December)
    • OSGi deployment
    • More native integration for WebLogic Server – Coherence – Oracle Database
    • JRockit Flight Recorder for constant record
    • Virtualization
    • More integration with Maven, Hudson and Cruise Control
    • Shared Library: use the same JAR for many applications, rather than packing the same JAR in different EARs.
    • On long term:
      • IDE
        • NetBeans to be oriented onto J2ME development
        • JDevelopper to remain Oracle strategic IDE
        • Contributions to Eclipse to go on
      • JRockit and Sun HotSpot JVMs to be merged.