Dienstag Mai 13, 2008

JavaOne 2008 Handson Lab Material available

Last week was a busy week in San Francisco. On Sunday we had the GlassFish unconference which was real fun. Monday the C1 event in Moscone Center and of course tuesday to friday JavaOne. I was proctoring all the Open ESB related labs and helped people succeeding in the labs. For those interested the material is now available online for all SDN members. The Open-ESB labs have been:
Blogged with the Flock Browser

Tags:

Mittwoch Apr 30, 2008

Domain Synchronisation in GlassFish

Wer schon immer mal wissen wollte wie in einer GlassFish v2 Domäne (gilt auch für Application Server 8.x) der Sync Vorgang zwischen Domain Admin Server, Node Agents und Instanzen läuft: Auf dem Blog von Kedar gibt es eine gute kurze Zusammenfassung hier . Wer sich informieren möchte, was für v3 in Bereich Admin Features geplant ist sollte im Wiki nachsehen.
Blogged with the Flock Browser

Tags:

Donnerstag Apr 24, 2008

GlassFish Präsentation von der JAX2008

Long time no blogging... Die letzten Tage war ich auf der JAX Konferenz in Wiesbaden.  Am Dienstag hatte ich dort eine sehr gut besuchte Session zum Thema "Advanced GlassFish". In der Session habe ich ein paar weiterführende Themen wie Monitoring, Comet, OpenSSO und Scripting mit GlassFish diskutiert. Für Interessierte - hier ist der Link auf die Praesentation. Heute läuft dort die Keynote unseres neuen Kollegen Dalibor Topic zum Thema OpenJDK.
Blogged with the Flock Browser

Montag Sep 17, 2007

GlassFish v2 released today!

I have been busy over the past months and didn't find the time to blog. But today is an important day for the GlassFish community which forced me to blog again:

GlassFish v2 - also known officially as Sun Java System Application Server 9.1 - is finally released today!

You can get from here or here

If you are new to GlassFish here are some of the feature highlights:


  • Full Java EE 5 Support

  • Profile support: Developer, Cluster and Enterprise Profiles

  • Clustering and failover support

  • New in memory replication for failover more

  • Java Business Integration support

  • Easy to use intuitive admin console

  • Performance!

  • and much more - See Eduardo's writeup

You can read more about this exciting release as usually on the
aquarium

Donnerstag Apr 26, 2007

Being at JAX07

I have been at JAX conference this week giving a session about GlassFish v2 (slides to be posted soon) and doing booth duty. It was fun staffing the booth together with Roman Strobl and demoing NetBeans as well as GlassFish. We were really surprised by the positive feedback we got from visitors and many adoption statements for both NB and GF. NetBeans also was honoured with the JAX innovation award from the audience for its Matisse GUI Builder!

 







Powered by ScribeFire.

Dienstag Apr 17, 2007

Clustering Web Applications with GlassFish V2

Here is a short tutorial on how to make your web apps highly available with GlassFish V2 and it's new in memory replication features.

Step 1: Setup a GlassFish V2 domain:
  • Download GlassFish V2 beta2 (eg build 41c) from here
  • Execute java -jar glassfish-installer-v2-<buildnumber>.jar
  • As we will have to use the cluster profile edit setup-cluster.xml as needed. If the default ports and passwords are ok for you there is no need to change anything. (I assume default settings for the next steps)
  • Execute ant -f setup-cluster.xml and a GlassFish domain with its domain administration server is created for you.
  • Start your domain admin server by executing asadmin start-domain --user admin and verify that its up and running by accessing the admin gui at http:<servername>:4848
  • Next you have to create a node-agent. Node agents are responsible for communication between you domain admin server and server instances or clusters. You create a node agent be executing asadmin create-node-agent <nodeagentname>. If you don't specify a node agent name the hostname if your system will be used. If you create your node agent on a different server you also have to specify host/port information for your domain admin server by giving --host <hostname> --port <portnumber> to asadmin
  • Fire up your node agent by asadmin start-node-agent <nodeagentname>
  • Next look at your admin console. Your node agent should show up as running.


Step 2: Setup a GlassFish V2 cluster

Setting up a cluster means that we are going to define a cluster configuration that is shared among multiple instances. To create a cluster proceed this way in the admin gui:
  • Select Clusters in the navigation tree
  • Click on new to create a cluster, give your cluster a name, select default config and add cluster nodes (at least 2 for now). For each cluster node select your node agents representing the machines where your cluster instances shall run. The following picture shows my test setup.

  • Click on OK and your cluster and its instances will be created (will take some time depending on your machine).
  • On the next page that will show up in the admin gui you can select the checkbox left to the clustername and click on the Start Cluster button to start up your cluster.
  • Now your cluster should be up and running and ready for application deployment!
If you prefer cluster creation using command line tools you can do it with asadmin this way:
  • <glassfish-install-dir>/bin/asadmin create-cluster --user admin <clustername>
  • <glassfish-install-dir>/bin/asadmin create-instance --user admin --nodeagent <nodeagentname> --cluster <clustername> <instancename1>
  • <glassfish-install-dir>/bin/asadmin create-instance --user admin --nodeagent <nodeagentname> --cluster <clustername> <instancename2>
  • <glassfish-install-dir>/bin/asadmin start-cluster <clustername>

Step 3: Deploy an application to your cluster

Now we can finally deploy an application to our new cluster environment. In order for a web application to make use of session failover in a cluster some preconditions must be met:
  • The group membership service in your cluster must be running as it provides some hearbeat information about the health of your instances. Normally this service is enabled by default. You can doublecheck by selecting your cluster and look at the general tab - the checkbox Heartbeat should show enabled.
  • The deployment descriptor of your web app - web-inf/web.xml must contain the <distributable/> element:
      <web-app version="2.5" ....... >  
    <display-name>myclusterable webapp</display-name>
    <distributable/>
  • And also your application must provide a web-inf/sun-web.xml that contains properties for the session manager:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0
    Servlet 2.5//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd">


    <sun-web-app>
    <session-config>
    <session-manager persistence-type="replicated">
    <manager-properties>
    <property name="persistenceFrequency" value="web-method"/>
    </manager-properties>
    <store-properties>
    <property name="persistenceScope" value="session"/>
    </store-properties>
    </session-manager>
    <session-properties/>
    <cookie-properties/>
    </session-config>
  • In aboves extract of a sun-web.xml the session manager has to specify persistence-type="replicated" to use the in memory replication of your cluster. The persistenceFrequency property with value web-method means that after each request the session gets replicated. A different setting would be time-based replication. The persistenceScope property with a value of session means that on each request the whole HTTPSession gets replicated. Other potential settings are modified-session and modified-attribute.
  • If you have changed your apps web.xml and sun-web.xml you are ready to deploy to your cluster. In the admin gui you can simply select your cluster as target. Usually only "server" is shown as selected Target which means that its deployed to the domain admin server. Just select your cluster and add it to the targets list.
  • Before you click on the OK button for deployment make sure to select the Availability Enabled checkbox for your application!
  • If things went fine the server.log of your instances should have an entry like this:
    [#|2007-04-17T10:31:11.255+0200|INFO|sun-appserver9.1|javax.enterprise.system.container.web|
    _ThreadID=24;_ThreadName=RMI TCP connection(19)-<ip-address>/clusterjsp;replicated;
    web-method;session;|WEB0130: Enabling ha-based persistence for web module [/clusterjsp]'s
    sessions: persistence-type = [replicated] / persistenceFrequency = [web-method] /
    persistenceScope = [session]|#]
Now you can access your application on both of your cluster instances by directly pointing your browser to each server instances. (eg <host1>:<httpport> and <host2>:<httpport>). If your application changes attributes in the HTTPSession you should see those changes getting replicated to the other server in your cluster.

Thats all for now about clustering with session failover for GlassFish V2. Of course you also want to use load balancing in front of your cluster. Do do this you can use either the Sun Web Server with GlassFish or use Apache+mod_jk with GlassFish V2.

Update: Shreedhar (check his excellent blog about Shoal) pointed out that 2 things should be considered when using in memory replication:
  • The cluster instances should be located on the same subnet
  • Clock times on all machines in the cluster should be time syncd to be as close as possible



Powered by ScribeFire.

Freitag Feb 09, 2007

Standalone IIOP Clients with GlassFish

I often get asked how a standalone client can be used to connect to EJBs deployed on GlassFish or Sun Appserver 8.x. Here are the choices:

  • Set system properties org.omg.CORBA\*
    You can do this either in your application code or as jvm start parameters
    System.setProperty("org.omg.CORBA.ORBInitialPort",""); System.setProperty("org.omg.CORBA.ORBInitialHost","");
    or set it as JVM property like this: java -Dorg.omg.CORBA.ORBInitialHost=host -Dorg.omg.CORBA.ORBInitialPort=3700

  • Set System property com.sun.appserv.iiop.endpoints:
    You can also use the JVM system property com.sun.appserv.iiop.endpoint=host:port to specify the endpoint address. Also this property supports multiple endpoints to support load balancing. For example setting java -Dcom.sun.appserv.iiop.endpoints=host1:port1,host2:port2 ... specifies host2 as failover endpoint if host1 crashes.

  • Set InitialContext Properties
    The last approach that may be used is to set ORBInitialHost/ORBInitialPort as properties for the InitialContext like this:
    Properties p = new Properties();
    p.put("org.omg.CORBA.ORBInitialHost","localhost");
    p.put("org.omg.CORBA.ORBInitialPort","33700");
    InitialContext ctx = new InitialContext(p);
    //... do the lookups...
    
    To make the standalone client run you also have to setup your classpath correct. You have to put appserv-rt.jar, appserv-admin.jar and javaee.jar in your client classpath in addition to the EJB interfaces. Additional parameters are not needed as more properties are picked from the jndi.properties file that is contained in above jars. More information can also be found in the GlassFish EJB FAQ: https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html
  • Montag Dez 04, 2006

    Loadbalancing with mod_jk and GlassFish

    In addition to jfarcands blog about mod_jk and GlassFish I also wanted to try out mod_jk loadbalancing with GlassFish. Here is the cookbook on how to get a simple load balancing scenario set up:


    Software needed:

  • Apache 2.0.x
  • Apache Tomcat Connectors link
  • Apache Tomcat 5.5.16 (needed for just one jar File)
  • Apache Commons Logging 1.0.4 link
  • Apache Commons Modeler 1.1 link
  • And of course you need at least two running installations of GlassFish V1/V2.


    Steps to setup load balancing:

  • Install mod_jk into your Apache config (copy mod_jk.so to your Apache modules directory)
  • Configure your Apache httpd to include mod_jk.so by editing your httpd.conf to include the following:

    LoadModule jk_module modules/mod_jk.so
    JkWorkersFile path_to_your_config/conf/workers.properties
    JkLogFile path_to_your_log_dir/mod_jk.log
    JkLogLevel info
    JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
    JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
    JkRequestLogFormat "%w %V %T"
    #Mount your webapps eg WebApplication1 using JkMount
    JkMount /WebApplication1/\* loadbalancer

  • Create a worker.properties File for the mod_jk connector. In the example shown below a load balancing worker for two local GlassFish instances (listening on jk port 8009/8010) is provided.

    worker.list=loadbalancer
    worker.worker1.type=ajp13
    worker.worker1.host=localhost
    worker.worker1.port=8009
    worker.worker1.lbfactor=1
    worker.worker1.socket_keepalive=1
    worker.worker1.socket_timeout=300
    worker.worker2.type=ajp13
    worker.worker2.host=localhost
    worker.worker2.port=8010
    worker.worker2.lbfactor=1
    worker.worker2.socket_keepalive=1
    worker.worker2.socket_timeout=300
    worker.loadbalancer.type=lb
    worker.loadbalancer.balance_workers=worker1,worker2


  • Enable the jk connector in each GlassFish instance by adding a JVM Option with asadmin. If your instances run on the same box you have to choose different JK ports. The ports must also match your worker.workerX.port definitions in your worker.properties files.
    $GLASSFISH_HOME/bin/asadmin create-jvm-options 
    -Dcom.sun.enterprise.web.connector.enableJK=8009

  • Copy the following jar archives to your GlassFish Installations lib directory ($GLASSFISH_HOME/lib): tomcat-ajp.jar (from Tomcat 5.5.16 /server/lib dir), commons-logging.jar and commons-modeler.jar.
  • Next restart your apache httpd and your glassfish instances.
  • If JK connector was enabled successfully in glassfish you should see a log entry in your server log as for example:
    [#|2006-12-01T11:33:14.667+0100|INFO|sun-appserver-pe9.0|
    org.apache.jk.common.ChannelSocket|_ThreadID=11;_ThreadName=Thread-5;|JK: ajp13 listening on /0.0.0.0:8009|#]

    Now all web applications that are deployed to your GlassFish instances and that are mounted in your httpd.conf through JkMount commands should be loadbalanced equally.

    More advanced jk configuration properties may be found in the Tomcat connectors documentation

  • About

    Daniel Adelhardt

    Search

    Archives
    « April 2014
    MoDiMiDoFrSaSo
     
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
        
           
    Heute