Showing posts with label Glassfish. Show all posts
Showing posts with label Glassfish. Show all posts

Wednesday, 3 February 2010

GlassFish v3 and Java EE 6 Sun-Oracle roadshow - key notes

GlassFish Roadshow 2010 - London 03-02-2010

The following is some notes I took down during the above event.

In brief summary of GlassFish v3 and Java EE 6, here are some of the key takeaways:

  • GlassFish v3 continues to be developed and supported, as the Java EE 5 & 6 RI app server
  • GlassFish v3 currently has no clustering, but offers OSGi modularization and extensibility
  • Supports and takes advantage of new Java EE 6 specifications
  • Big push on modularity and flexibility in both GlassFish and Java EE 6
  • Java EE 6 supports annotation based EJBs, RESTful web services
  • Java EE 6 greatly simplified configuration, optional web-inf.xml etc
  • Java EE 6 simplied simple class EJBs and improved JPA specification
  • Ongoing road-map for GlassFish, details TBA later this year


Java EE 6 (Roberto Chinnici):

Released Dec 10 2009

Key new features: New API, Web profiles, Pluggabiliy, dependancy injection

New technologies:
  • Jax-RS 1.1
  • Bean validation 1.0
  • DI 1.0
  • CDI 1.0
  • Managed beans 1.0
Closed down gap between EJB and POJO with unification and annotations

CDI works with POJO and EJB classes

Unification of platform types, more uniform programming model

  • EJB 3.1
  • JPA 2.0
  • Servlet 3.0
  • JSF 2.0
  • Connectors 1.6
  • Interceptors 1.1
  • JAX-WS 2.2
  • JSR-109 1.3
  • JSP 2.2
  • JSR-250 1.1
  • JACC 1.4
  • JASPIC 1.1

Key goal in Java EE 6 - flexibility, pruning, extensibility and web profiles


Profiles:

Bundles of technologies targeting specific classes of applications
Decoupled from each other and the platform
Guarantees compatibility of required technologies, individually and in combination - must satisfy all joint requirements


Web Profile:

Modern Java web application stack
First profile to be definite
Mid sized, fully functional (expected 80% web-app coverage), add additional components via extensibility (such as web services API, 3rd party frameworks)


Web profile contents:

Servlet, JSP/EL, JSTL, JSF, Bean Validation, EJB Lite, JPA, JTA, Di, CDI, Managed beans, Interceptors, JSR-250


Pruning:

Goal - to address bloat concerns

2 step process:
Declare components as "Proposed optional"
The make fully optional for the next release

Proposed optional technologies:

JAX-RPC (JAX-WS)
EJB 2.x Entity beans (JPA entity classes)
JAXR (little use)
JSR-88 (deployment, tools API - not used)

* Don't use - use replacements / alternatives


Pluggability / extensibility:

Focus on web tier
Level playing field for 3-rd party libraries and frameworks
Two major extensibility points: Servlets and CDI
Simplify packaging of web-apps
Zero-configuration!


Modular Web applications:

Libraries can contain web-fragment.xml descriptor
web.xml is now optional
Can server resources out of jars with: /META-INF/resources

e.g.
/WEB-INF/lib/catalog.jar
/META-INF/resources/catalog/books.html

e.g. Dojo jar in resources


Web fragments in servlet 3.0:

META-INF.web-fragment.xml

same structure as web.xml, can override in web.xml


Servlet container pluggability:

ServletContainerInitializer interface implements by extensions

@HandlesTypes to declare interest in on or more annotation types

ServletContext now contains method to dynamically register servlets and filters
i.e. ServletContext API has been extended

Registered using META-INF/services


onStartup method gets called with a Set of classes available

** Can only add services at startup, not dynamically once running


Asynchronous HTTP processing:

New programming model for async request processing
e.g. Comet, char, push apps
Opt-in model
Threads are managed by the container

@WebServlet(asyncSupported=true)
public class MyServlet extends HTTPServlet {

}

Goal - Decouple requests from threads

* Changes to the way filters work - thread not attached to the socket, response not written. Filters modified to make safe - option than can be turned on to identify asyncSupported=true
- do this on servlet and any filter involved in the chain

Ideal when waiting for some external resource etc.
Low level API - not very elegant
Idea is that frameworks will use this - see for example Atmosphere framework which is based on annotations - under the hood this async API is used.


JSF 2.0:

Facelet as a standard view declaration language
Composite components
Ajax (declarative and programmatic) e.g. f:ajax tag
Partial state saving (track deltas and sends changes in response, previously all would have been sent even if not changed!)
System events e.g. f:event tag
Resources
Validation e.g. new f:validateBean tag (better integration, validation API. can handle multiple errors, not first one at a time!)


EJB 3.1:

@Singleton beans
@Startup beans (invoked at app startup, works well with Singleton pattern)
@Asynchronous invocations (biggest change, allows non-blocking sync EJB invocations as first class call. Method must be either void or return a Future object)
No interface view (bean impl does not need an interface anymore, now 1 class = 1 EJB!)
Define EJBs directly inside a web app, inside a war file
New API - EJBContainer API works on Java SE, can bootstrap an EJB container in a Java SE application (ideal for testing/development, could be useful in client applications)


Simplified packaging:

EJB class directly into the war file
Previously must built an EJB jar to be included


EJB 3.1 lite:

A subset of EJB 3.1
All types of session beans (stageful, stateless, singleton) - other bean types not supported (timer, entity etc)
Declarative transactions and security
Interceptors
ejb-jar.xml descriptor allows (is optional, probably not useful)

* Class loading, new visibility rules in Java EE spec

Slight differences in class loading rules - if in doubt check the specs


New JNDI Namespaces:

Until now - only java:comp
Now added:
java:module - a module (war, ejb, jar)
java:app - an application
java:global the whole server / cluster

e.g. @Resource(lookup="java:app/CustomerDB") DataSource db;

EJB components have global names now:

e.g. java:global/app1/module2/SomeBeanIcom.acme.Foo

Helps solve problem of remote EJB communication in same app server


Dependency injection (DI):

Combination of DI 1.0 / CDI 1.0
New @Inject annotation
@Inject @LoggedIn User user; (@LoggedIn = "Which one", User = "What")
Beans auto-discovered at start-up
Extensible
Injection metamodel (BeanManager API)
@Resource still available for container resources

* Identified by type and qualifiers (no longer just a string name alone)

* No bean declaration as per Spring declaration, bean discovery at startup
* Injection errors all reported at startup, rather than on use at runtime

Beans can be associated with session - i.e. loggedIn
Beans can be more ephemeral, i.e. for request
Beans can be more long lived, i.e. shopping cart conversation flows
Can add class for beans on the fly, via APIs at runtime

Example of DI annotation:

@Inject
CheckoutHandler(
@LoggedIn User user,
@Reliable @PayBy(CREDIT_CARD)
PaymentProcessor processor,
@Default Cart cart)

* Note that constructor injection is possible
* Note different scopes, PaymentProcessor is probably conversation scope, LoggedIn is session, PaymentProcessor is probably application scope singleton

* Instance and state management handled "for free" by framework/APIs

JAX-RS 1.1:
Already widely adoped
Really a high level HTTP API
Annotation-based programming model
Programmatic API when needed

* think of it as the new HTTP level API (higher level than HTTPServlets, remove low level detail and tedium)

Jax-RS resource class, example:

Identified by the @Path annotation

@Path("widgets./{id}")
@Produces("application/widgets+xml")
public class WidgetResource {
pubic WidgetResource(@PathParam("id") String id { … }

@GET
Widget getWidget() { … }
}

Provides higher level HTTP handling, more declarative, better match with conceptual needs of developer


Bean Validation 1.0:

Integrated with JSF, JPA
Constraints represented by annotations

e.g.

@NotNull
@Size(max=40)
String address;

Fully extensible
@Email
String recipient;

Validation API's for validation directly, create a new validation object etc
Validation of trees of objects is possible (including loops)


JPA 2.0:

Supported for collections of basic types and embeddable objects
JPQL enhancements e.g. CASE WHEN, NULLIF
Pessimistic locking added (annotations added)
Criteria API for dynamic query construction

Criteria API: Uses the canonical metamodel classes

CriteriaBuilder, create criteria
CriterialQuery, typed criteria

Strongly types checking, type parasitised equals checking, compiler errors generated if query does not have the right types etc, so robust and safe query (rather than say String SQL construction directly).

Connectors 1.6 added too (not covered in any detail)


Summary overview:

Improved, more powerful, more flexible, more extensible, easier to use

http://java.sun.com/javaee


--

GlassFish V3 (Alexis Moussine-Pouchkine):

Java EE 6 Reference Implementation (RI)

Geographic download map:

http://maps.glassfish.org/server

Healthy increase in downloads and usage over time

GlassFish V1 first shipped 2006, reusing much from Tomcat

V2.1.1 Nov 2009, V3 (Java EE 6) Dec 10th 2009

GlassFish V3 Open Source CDDL, GPL (with 'classpath exception') licensing

Java EE 5 & 6, enterprise quality - full support is available.

Sub projects:
  • Jersey (JAX-RS)
  • Metro (JAX-WS)
  • Grizzly (NIO)
  • Atmosphere (Comet)
  • OpenMQ (JMS)
  • and scripting jRoR Grails and now Django (python)

Main difference from Tomcat - Grizzly core (rewritten)

Netbeans 6.8 tooling
Support available in Eclipse too

GlassFish development continues
Support contracts through to 2017+ unlimited
Remains the Java EE reference implementation
Now also sold with WebLogic and standalone

Roadmap -> expected soon for remaining year

Don't have to deliver as much standard runtime / frameworks jars as part of the application jar

Netbeans in-place edit of classes, incremental compilation, deploy on save, GF v3 preserves session across redeployments(!)

Session retention:
Deployment option to maintain statefull sessions across re-deployments!


GlassFish v3 key goals:

Modular and dynamic
Modular: Apache Felix (OSGi)
Extensible: HK2 (100k kernel)
Still very fast!

Centralized configuration, modules configured through centralised control


Key Features:

No ejbjar.xml needed, no web.xml, annotation driven, EJB's as single classes

Declarative annotations:

@Stateless annotation for class stateless bean
@Schedule annotation for timers

Eclipse - GlassFish tool bundle for eclipse (contains everything!)

Ultra fast auto-deploy of all Java EE and static artefacts

Maven support: mvn gf:run gf:start gf-deploy

Containers can be added / removed dynamically


New API for EJB testing (EJBContainer):

Example:

EJBContainer c = EJBContainer.createEJBContainer();
Context ice = c.getContext();
SimpleEjb ejb (SImpleEjb)ic.lookup("java:global/sample/SimpleEjb");
ejb.sayHello();


GlassFish "Embedded" - allows all features of GlassFish to be automated

org.glassfish.api.embedded.Server server;
Server.Build builder = new Server.Builder();
server = builder.build();
ContainerBuilder b = server.createConfig(ContainerBuilder.Type.web);
server.addContainer(b);

File archive = new File("hello.war");
server.getDeployer().deply(archive);

i.e. Ship app server inside an application!


OSGi:

GlassFish runs on top of OSGi (Felix by default)
Also runs unmodified on Knopflerfish and Equinox
GlassFish ships with 200+ bundles
Can run without OSGi (static mode based on HK2)
Can use OSGi management tools (CLI or Web)

Any OSGi bundles will run in GlassFish v3
Drop it in glassfish/modules

Servlets can get hold of OSGi bundles (using @Resource DI)


Update centre:

Graphical tool (GlassFish does not need to be started), available in web admin console
CLI version available
Was in v2.x but not from admin console


RESTful admin API:

JAX-RS/Jersey + Grizzly to provide REST interfaces to
Configure runtime (via GET, POST, DELETE)
Invoke commands (restart, stop, deploy, etc)
Monitoring (GET only)
Log rotation etc

e.g. Available from:
localhost:4848/management/domain
localhost:4848/monitoring/domain


Further advantages:

Dynamic language support via modules:
Rails, Grails, Django, Scala/Lift


Comet:
Cometd/Bayeux
Atmosphere

Full support for:
mod_jk
WebDAV, CGI, SSI

OpenMQ 4.4

Web Services Metro 1.4
.NET 3.5 interoperability


v3 Clustering:
Lower priority after Java EE 6 and modularity, so not yet...
Clustering is not built in as per v2
More similar to v1, single instance
Have to take on own clustering (load balancing, deployment)
See roadmap for details...


Doing More with GlassFish (Steve Elliott):

GlassFish v3 - Management and monitoring

Management:

User Friendly, pluggable and extensible for administration
Feature rich Admin console (GUI)
Easy to use Command Line Interface (CLI)
RESTful management and monitoring API
Fully documented AMX API (app server management API)
All management features built on AMX API

OSGi, load on demand = fast initial start up

v3 AdminConsole:
Frame-set removed, now Ajax based pages
Pluggable console (admin panes, trees etc loaded on demand)


Monitoring:

Lightweight prode architecture
Ad hoc monitoring in Production
Client-scripting (JavaScript)
DTrace integration on Solaris (similar to OS probes, uniform tracing experience with MySQL etc)
Extensibility / Pluggability

No overhead when there is no monitoring
Allows Monitoring to be turned on in a production environment with minimal impact
Generate and listen to only interested
Turn on monitoring when needed
BTrace integration
Portable and dynamic


Instrumentation:

Modules expose probes
POJO with annotations
XML

Modules register probe listeners

In code, POJO annotations can be used

@ProbeProvider(providername="glassfish", modulename="web")

ProbeProvider XML configuration also possible

ProbeListeners
JMX exposed

@ManagedAttribute(id="jspcount")


OSGi:

big move to OSGi technology
Big move to more modular development approach

Demands and enforces stronger modularity

OSGi is largely under the covers
Visible to GlassFish developers, but not to GlassFish users


Service based architecture:

Core modules loaded on app startup
Rest loaded on demand

Module Management:
add, remove, update installed modules

OSGi as a container


Web services - Metro : JAX-WS / Jersey : JAX-RS

Metro - SOAP-based web services stack
Built into GlassFish
Works with any servlet 2.5 compliant web container
WebLogic, WebSphere, JBoss, Tomcat
Also standalone
Advances interoperability with .NET 3.x/4.0

Project Tango - focused on interoperability with .NET

JAXB based XML Data Binding (XSD, XPATH)

SOAP Messaging MTOM etc

Bi-directional interoperability with .NET (Java or .NET as client or server)


Standards:

JCP: JAX-WS 2.2 & JAXB 2.2
W3C SPAP 1.1/1.2 WSDL 1.1, WS-Addressing
… etc


JAX-RS:

JAX-RS 1.1 is final and part of EE6

Not a web profile
but included with GlassFish v3 web profile
JCP 311
Spec - JSR 311

http://www.oracle.com/java
Contains links to GlassFish etc


.

Thursday, 4 June 2009

GlassFish v2.1 b60e crib sheet / installation notes

Recently, having been working on a project that's migrated from JBoss 4.2.2 to GlassFish v2.1, I needed to hand over a crib sheet / quick guide to people supporting the live system, so as it might be useful in general. Only really covering the basics, but here it is anyway:

GlassFish AS Basic Crib / notes:

Prerequisites:

  • Java JDK 6.x latest

GlassFish AS version V2.1 b60e Final Release

Download jar here http://java.net/download/javaee5/v2.1_branch/promoted/Linux/glassfish-installer-v2.1-b60e-linux.jar

For RHEL derived CentOS, recommended installation would be something like /usr/local/projectname/glassfish


Installation:

java -Xmx256m -jar glassfish-installer-v2.1-b60e-linux.jar

cd glassfish

chmod -R +x lib/ant/bin

lib/ant/bin/ant -f setup.xml

Follow the installer instructions, accepting EULA and any defaults presented...

This will unpack and install the server, creating a default domain called "domain1"

A domain is an administrative "unit" - possibly related to, but not the same as an actual domain.

All domains live in: {glassfish_home}/domains/

We need just one for now, so all our stuff will be in:

{glassfish_home}/domains/domain1/

the installation process will create a default empty domain, domain1 with a default config file, the main configuration file is called domain.xml

e.g. {glassfish_home}/domains/domain1/config.xml

This file may contain some host /installation specific information, as well as stuff specific to our application.


Starting and stopping GlassFish AS:

{glassfish_home}/bin/asadmin start-domain domain1

{glassfish_home}/bin/asadmin stop-domain domain1

If all is good you will see confirmation on the command prompt when started, such as:

Domain domain1 started


Managing GlassFish AS:

By default, the web based management console is available on port :4848

The default admin account is username = admin, password = adminadmin

URL is: http://{hostname}:4848


Web-app deployment options:

There are a few options, the main two are:

Manually, using autodeploy directory

Simply copy .war file to: {glassfish_home}/domains/domain1/autodeploy

Deploying via the admin console:

On main menu on left, click on and expand the Web Applications menu entry

Click on the Deploy button, typically when deploying from a local file, use the "Packaged file to be uploaded to the server" browse button to locate the local war file. Browse for the war file, select it and click Ok

When completed, the web app will appear in the application list (if all is well)

The other settings can be left as defaults. Optionally we can chose to pre-compile JSPs here etc.


Server Logs:

The main server logs appear in the domain under logs, i.e.

{glassfish_home}/domains/domain1/logs/server.log

Logs can also be viewed (and configured, including log rotation) via the admin console, under the Application Server menu entry


Monitoring and management:

JConsole:

GlassFish is a JMX compliant app server (listening by default to port 8686)

Using jconsole, remote connect to: http://{hostname}:8686

Using the same default account: admin/adminadmin

Admin console:

Under the Application Server in the main menu - there are entries for server Monitoring.

This includes a built in chart and call flow logging - which is potentially very useful for diagnostics and monitoring…


HTTPS / SSL:

GlassFish AS will do HTTPS out of the box (using a default Sun Microsystems certificate).

HTTPS is served by default on port :8181


Hopefully in the near future I'll but together something to cover clustering and load balancing too.



.

Saturday, 16 May 2009

Quick notes on OpenSolaris 111a & GlassFish clustering

Some quick notes on upgrading 111 to 111a and preparing for GlassFish v2.1 clustering and load balancing tests:

(Note: This is really a scratch-pad of notes and resources for my own benefit, rather than a structured Blog for others to follow, however some of the resources might be useful for someone, somewhere)

OpenSolaris upgrade problems:

Graphical login failed to start

Simply restarting gdm fixed this problem!

svcadm disable gdm
svcadm enable gdm


Installing GlassFish v2.1 - problems:

Running java -Xmx256m -jar glassfish_xxx.jar reported "Not Enough Space Available"

zfs list showed 8gig space available

check for large files in swap directories:

pfexec du -k /tmp|sort -n
pfexec du -k /etc/svc/volatile|sort -n

Increasing swap space, adding a second swap file:

zfs create -V2G rpool/swap2 ; swap -a /dev/zvol/dsk/rpool/swap2


GlassFish clustering:

Steps for setting up GlassFish clustering:

Setup default clustering profile;

lib/ant/bin/ant -f setup-cluster.xml

Start the DAS;

bin/asadmin start-domain --user admin


Create the node agent;

bin/asadmin create-node-agent

Start the node agent;

bin/asadmin start-node-agent

Create cluster and instances (for node agent) in GlassFish admin console.

Download Load Balancer plug-in according to platform

http://download.java.net/javaee5/external/


Guide to setting up GlassFish clustering:

http://blogs.sun.com/dadelhardt/entry/clustering_web_applications_with_glassfish1



Guide to setting up GlassFish with Load Balancer plugin:

https://glassfish.dev.java.net/javaee5/build/GlassFish_LB_Cluster.html

Further resources:

Clustering with Apache HTTPd:

http://blogs.sun.com/jluehe/entry/supporting_apache_loadbalancer_with_glassfish


Interesting thread about clustering problems:

http://www.nabble.com/Cluster-session-replication-not-working-td20691318.html


GlassFish V2 Clustering presentation:

http://blogs.sun.com/stripathi/resource/Preso/GlassFishv2Clustering.pdf

Sun Clustering with GlassFish v2:

http://developers.sun.com/appserver/reference/techart/glassfishcluster/


Setting up GlassFish SSL support:

http://java.sun.com/mailers/techtips/enterprise/2007/TechTips2_Nov07.html


GlassFish JMX / JConsole:

http://docs.sun.com/app/docs/doc/820-4335/ablwi?a=view


Sun Java web server (for load balancing):

https://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_SMI-Site/en_US/-/USD/ViewProductDetail-Start?ProductRef=SJWS6.1SP5-OTH-G-F@CDS-CDS_SMI

Monday, 30 March 2009

Some notes from Sun GlassFish portfolio tech talk, London

Sun GlassFish and GlassFish portfolio - Sun talk London, Regis House 25-03-2009

Some notes that I managed to take whilst at the talk.

www.glassfish.org

Claimed to be the fastest Java EE AS

V2.0 -> reference implementation for Java EE 5
V3.x -> reference implementation for Java EE 6

Java EE standard 10 years old

Metro -> Interop between MS and Java WS.* standards

GlassFish is Open Source under CDDL and GPL 2 license

java.sun.com/javaee

Transparent development

Organic growth into middleware areas

First appearance 2005
V2 in 2007
Current v2.1 in Feb 2009

www.beta.glassfish.java.net:81/maps

6-700 downloads per month, 8 million in the last year / ~28k per day

GlassFish portfolio is a set of related technologies including the AS
  • Enterprise server (including support for SNMP)
  • Web space server (joined with Life Ray - social networking & portal technologies)
  • Web sack (a complete (L)(S)(?)AMP stack)
  • GlassFish ESB (SOA platform) for integration, connectors, adaptors

Java EE + Ruby on Rails, PHP and other frameworks

(note - what is SFA?)

Enterprise version adds:
  • Performance advisor, performance monitor, SNMP, self management and alert manager
  • Update center

Example / reference sites:
  • wotif.com - Glassfish & OpenMQ
  • www.travelmuse.com GlassFish, message queue and mysql (started by using community edition)
  • North american Nationwide Health Information Network - connect (NHIN- Connect)
  • OpenESB
  • ESB.SOA framework
  • Facebook - large mysql based system ~70million users

GlassFish has same levels and structure in terms of support and licensing as MySQL


Web Services: WS.*
  • Metro is core in GlassFish AS
  • Project Metro Web services stack provides high level WS stack with security, reliability etc -> .NET 3 interoperability (incorporates project tango - MS .NET interop)

REST

  • JAX-RS JSR-311 Java API for RESTFul Web Services
  • Annotation based server side API
  • HTTP Centric
  • Server Side only
  • Servlet or SE deployment

Jersey project provides implementation for JSR-311

Performance:

Similar / faster than Weblogic and Websphere


GlassFish V3:
  • OSGi: Apache Felix as default (origins in JSR-8)
  • 1 sec startup
  • 21Mb download
  • admin and update tool downloaded on demand

Add-ons, modules available from update center:
  • EJB 3.1 (preview
  • jRuby on Rails (new WAR packaging required)
  • Grails (also on GFv2)
  • Jersey and Metro (Web services)
  • jMaki (AJAX)

Tools:
  • NetBeans and Eclipse
  • Embedded GlassFish API

MicroKernel approach - modularity - base App server + on demand module loading, extensible and customizable

("Eclipse Con" -> announces GlassFiish bundle available)

Db connection pooling and connection (connector) pooling (JCA)

V3 Prelude
  • available from http://glassfish.org -> using modular (microkernel) v3 ideas with existing EE5 technologies -> this version is supported!
  • v3 prelude is Java EE Web layer only (i.e. servlets, JSPs etc but no Enterprise beans etc)

Compile / Deploy on Change support, dynamic debug loop (netbeans & eclipse), incremental compile of all Java EE artifacts. Auto-deply of all Java EE and static artifacts

Support for: JRuby, Ruby, Groovy, Grails, Python, jython, django, jmaki, JavaScript phobos

Ruby / jRuby and rails can be run on 2.1 today (by packaging up dependancies), on v3 available as OSGi jRuby container


PHP
  • Quercis (Caucho) opensource GPL php 5 implementation in Java
  • War Packaging
  • Java Bridge

V2 -> ee 5
V3 -> prelude with EE5 support
V3 -> early access is EE6 spec (but not supported)


GF Web Stack:
  • Apache HTTPd
  • Sun web server 7 (most scalable web server - now open sourced!) optimized for multi-core CMT (chip-based Multithreaded) systems - 2x scaling vs. Apache & Tomcat
  • lightpd
  • memcached
  • mod_jk, perl, ruby, PHP Ruby, Python, Squid, Tomcat

Current GF web stack is 1.4 (Python 2.5.2, Squid 2.6, Tomcat 5.5.27, memcached 1.2.5, mysql 5.0.67)


GF ESB:
  • JSR 208 JBI (Java business Integration)
  • Plug-able integration into backbone
  • "Metacontainer" - add new containers within the container, extend the AS
  • BPEL, WS-*, XSLT, FTP, LDAP, HTTP, DB service and binding
  • Based on OpnESB -> http://openesb.org / community open-esb.dev.java.net/Components.html
  • Maybe engines and connectors to things like Corba etc

What's next -> http://fuji.dev.java.net -> OpenESB V3 - next gen of SOA

(JBI and SCA stated as "complimentary, not conflicting")


GF: Web Space server (project web synergy)
  • Portlet spec JSR-268 and more (social networking, communities)
  • OpenSSO, identify mechanisms
  • Compelling web UIs

GF enterprise manager:
  • Performance advisor
  • Alerts
  • JDBC pool management - automatically tunes JDBC connection pool to optimize performance etc

Sailfin (Ericson contribution) telco, SIP, VOIP, Instant messaging

dtrace etends into Apache and PHP

Revamped PetStore 4 part tutorial - developer.sun.com

OpenSSO -> new concept "express builds" - milestone interim builds from Open Source community in between main supported releases

WhitePapers:

New White-papers on GlassFish portfolio launch:
  • Comparison with Tomcat
  • Performance optimization
  • GF with identify and MySQL

Training available in Camberly, BSG in London etc

www.javapassion.com

Books:
  • GlassFish
  • Database-driven application development
  • Others available (I didn't get time to note them down)

blogs.sun.com/theaquarium -> god launch pad for developer information

blogs.sun.com/stories -> gives examples and real usage info

Migration tools:

migrate2glassfish.dev.java.net/blogs/blogs.html

built in tools to detect and advise on code usage (for EE standards and vendor specific code dependancies)

--

Examples:

JavaFX mobile - answer to J2ME shortcomings

www.javafx.com -> many tutorials and demos

GlassFish profiles - Developer mode (no clustering etc) but fast start up and change deployment


Clustering:

DAS - Domain Administration server looks after a cluster, deploy to the domain administration server and it deploys to the cluster nodes.

Session replication between cluster nodes, zero down time when switching between nodes

install with -cluster switch

Cluster elements run "node-agents" to talk to the DAS

Extra sections in the admin console -> shows cluster nodes

GlassFish performance monitor - enterprise only (TBC)?

V3 Prelude - web tier only (web apps) but fully functional


Presentation has now been published here: http://uk.sun.com/sunnews/events/2009/mar/glassfish/pdf/UK-GlassFish-Portfolio-Launch-mar09.pdf


.

Sunday, 16 November 2008

Apache httpd 2.x -> Glassfish 2.x mod_jk installation


Configure Apache Httpd to Glassfish using mod_jk.


Note
, for Glassfish 3.x this process has been simplified, I'll probably add a blog entry about that sometime soon.

In this particular scenario, Apache 2.2.3 is running on Centos 5.2 x86_64 and Glassfish 2ur2 is running on OpenSolaris 10 b101, althought the process should be essentiually the same for any Operating system(s), the paths etc might change.


Apache httpd setup:


Get the Apache mod_jk connector.

http://tomcat.apache.org/connectors-doc/

Binary distribution:

http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/

Install into modules directory: e.g. /etc/httpd/modules (RH/Centos)

Configure Apache httpd:

e.g. for RH/Centos in - /etc/httpd/conf.d/

Add ajp worker mapping to httpd.conf (e.g. in /etc/httpd/conf/), in this example using virtual host entries, e.g.



# Virtual host chillipower.com
[VirtualHost 192.168.0.200]

DocumentRoot /var/www/mywebs/chillipower.com

ServerName www.chillipower.com

ServerAlias chillipower.com

DirectoryIndex index.html index.php index.htm index.shtml

JkMount /chillipower*/* worker1

[/VirtualHost]



Note in the above, the url to the glassfish context would be reached using http://mydomain.com/chillipower/ where in this instance the trailing / is important.

Load and configure the module (e.g. place this in /etc/httpd/conf.d/mod_jk.conf)

(all *.conf files are loaded by httpd.conf (before any virtual hosts etc) from the /conf.d directory in typical setups, so we can add a new mod_jk.conf and it will be loaded automatically)


LoadModule jk_module /etc/httpd/modules/mod_jk.so
JkWorkersFile /etc/httpd/conf.d/worker.properties
# Where to put jk logs
JkLogFile /var/log/httpd/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel debug
# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"
# Send all jsp requests to GlassFish
JkMount /*.jsp worker1
# Send all glassfish-test requests to GlassFish
JkMount /chillipower/* worker1



Add worker.properties file to configure the ajp worker, /etc/httpd/conf.d/worker.properties




# Define 1 real worker using ajp13
worker.list=worker1
# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
#worker.worker1.host=localhost.localdomain
worker.worker1.host=192.168.3.101
worker.worker1.port=8009
worker.worker1.lbfactor=50
worker.worker1.cachesize=10
worker.worker1.cache_timeout=600
worker.worker1.socket_keepalive=1
worker.worker1.socket_timeout=300




Glashfish setup:

Download Apace Tomcat 5.5.16 -> http://archive.apache.org/dist/tomcat/tomcat-5/

copy the tomcat-ajp.jar to the glassfish lib folder. e.g.

cp $CATALINA_HOME/server/lib/tomcat-ajp.jar
$GLASSFISH_HOME/lib/.

Also, download and copy the commons logging and commons modeller jar files to $GLASSFISH_HOME/lib

Commons logger -> commons-logging-1.1.1.jar from http://commons.apache.org/downloads/download_logging.cgi

Commons modeler -> commons-modeler-2.0.1.jar from http://commons.apache.org/downloads/download_modeler.cgi

Restart Glassfish...


References:

http://weblogs.java.net/blog/jfarcand/archive/2006/03/running_glassfi_1.html

.

Wednesday, 23 April 2008

Some quick notes on Db Connection pooling in Glassfish

To set up a Glassfish connection pooling and JNDI datasource, accessible in your web app, the following things need to be done (tried with Glassfish v2):

Db drivers:

Ensure the relevant JDBC driver is in the Glassfish classpath. I ensured the <glassfish_home>/lib directory contained the latest MySQL J connector. You may need to restart Glassfish (you probably will if you change the classpath).

Configuration:

Connection Pool:

Set up a connection pool in the Glassfish admin interface (under Resources\JDBC\Connection Pools). In my case for MySQL I was happy to use the defaults initially, which includes:

  • Datasource classname: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
  • Resource Type: javax.sql.Datasource

Give the pool a sensible name.

Once you have set this and the connection details (host, username, password etc) you can use the Ping feature to check the connectivity. If you get errors regarding classes not found, check your classpath / location of the JDBC library jars - possibly restart Glassfish if you have not already.

Once you have a successful ping, you can move on to configuring the JNDI resource:

JNDI resource:

Under the Resources\JDBC\JDBC Resources set up a JNDI resource to the pool you just configured (by name), give the JNDI resource a name of the form:

jdbc/myLovelyDbJNDIResourceName

ensure the resource is enabled!

Deployment descriptors, configuration:

sun-web.xml - Map the container JNDI to a resource reference in sun-web.xml, e.g. something like:

<!-- Map container JNDI to resource reference -->
<resource-ref>
<res-ref-name>myDbResourceName</res-ref-name>
<jndi-name>jdbc/myLovelyDbJNDIResourceName</jndi-name>
</resource-ref>

web.xml - Map the resource as a datasource reference in web.xml

<!-- set up resource reference for the web app -->
<resource-ref>
<res-ref-name>myDbResourceName</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>

Application Code:

In you application code, where you get a connection, you can then use something along the lines of:


Connection connection = null;

try
{
Context env = (Context)new InitialContext().lookup("java:comp/env");

DataSource pool = (DataSource)env.lookup("myDbResourceName");

if (pool == null)
{
throw new RuntimeException("Unknown DataSource");
}

connection = pool.getConnection();
}
catch(NamingException ne)
{
throw new RuntimeException(ne.getMessage());
}

return connection;

Of course, modify the caught, declared to throw exceptions to suit the application design...

References:

This article is a useful reference point, covering similar information in a slightly more verbose form:

http://thestewscope.wordpress.com/2008/01/08/glassfish-v2-ur1-and-mysql-connection-pool/

This forum post also details the deployment descriptor configuration well:
http://forums.java.net/jive/message.jspa?messageID=264629