Saturday, January 30, 2010

260 posts and some reworks, personal comments

Weekend. Finally. Hard weeks at the moment. Lot to do and too less time.
The blog move did not went smooth enough at all. Lost my template. This is basically the cause for the actuall simple look and feel. I'll try to rework this as fast as possible but I need to switch to the newer blogger template features. This takes some time.

After the Oracle/Sun merger I was posting a lot about the strategy and the webcast. Some followers already suggested I should work for Oracle ;)
I am not. And I don't know, if I ever will. But I like their products (especially the Weblogic family) and I also like Java EE 6 (and therefore GlassFish as the RI).

You will read more about best practices and experiences, if everything comes back to normal. Forgive me, thanks for following, I'll be back in less than two weeks ;)

UPDATE (01.02.10)
Things are slowly getting back normal. Improving the design step by step when there is time for it. So many template and design changes ;)

Thursday, January 28, 2010

Oracle + Sun: Java Strategy (SE+EE+JavaOne)

The facts from the java strategy webcast (15:59 minutes):

0) Innovate and Collaborate

0.1) Java is Critical for the Industry and Critical for Oracle
It is the foundation for Middleware and Applications. Working in/on Java since 1995.
Oracle is participating in over 80 JSRs, leading nearly 20. Executive Committee member of the JCP.

0.2) JCP continues to be the process with which Java evolves

0.3) Continiu driving the Java technology and platform to be the most ... widly used, productive, reliable and performant, innovative and pervasive software foundation in the world.

1) Java SE (transcript)
  • HotSpot and JRockit continue as strategic JVMs
  • Java SE 7 continues toward target release in 2010 with many new features (modularization, productivity, dynamic languages, higher performance)

2) Java EE (transcript)
  • GlassFIsh continues as the Java EE reference implementation (RI)
  • GlassFish continues as an open source project
  • Oracle plans to offer GlassFish as part of multiple commercial Java EE application server offerings

3) Engaging with Oracle (transcript)
  • Developers: java.sun.com, java.net, java.com, javafx.com, otn.oracle.com/java
  • Customers: oracle.com/java
  • Partners: partners.oracle.com

4) JavaOne (transcript)
  • Continues as the premier open community event for Java. Co-located with Oracle OpenWorld, SFO, Sep 19-23 2010
  • Expanding to other countries (Brazil, Russia, India, China)

Oracle + Sun: Application Server Strategy

The facts from the software strategy application server webcast (12:55 minutes):

0) Complete.Open.Integrated. set of products
From Hardware, to Database, to Middleware up to Applications.

0.1) Application Grid is the relevant part of Fusion Middleware
It's the plattform that powers the Oracle Applications.
Supports all your application environments.
Contains: Weblogic, Coherence, JRockit, Tuxedo, Enterprise Manager

0.2) Sun portfolio:
GlassFish Enterprise Server, Java System WebServer, GlassFish Web Space Server, GlassFish Web Stack

1) Combined Oracle-Sun Solution Focus (transcript)
  • GlassFish continues as the Java EE reference implementation and as an open source project
  • Oracle's strategic application server Oracle WebLogic Server, together with GlassFish, provide world class Java EE infrastructure
  • GlassFish Enterprise Server and WebLogic Server expected to share core components
  • Oracle plans to add GlassFish Enterprise Server to all WebLogic offerings
  • HotSpot and JRockit become OracleƄs strategic JVMs
  • Java System Web Server part of new Oracle Web Tier offering
  • GlassFish Web Stack maintained for existing customers
  • GlassFish Message Queue remains as the GlassFIsh messaging infrastructure

2) Licensing, Support and Maintenance (transcript)
  • Oracle plans to license GlassFish Server and Java System Web Server with all WebLogic Server offerings
  • GlassFIsh also available as standalone offering
  • GlassFish will continue to be supported and maintained for an extended time period for customers current on support
  • GlassFish v2.1 Premier Support up to Jan 2013, Extended support up to Jan 2015)
  • GlassFish v3.0 Premier Support up to Jan 2014, Extended support up to Jan 2017)
  • Full details for support will be published next weeks.

3) Engaging with Oracle
  • GlassFish open source projects thrive. Ongoing commitment by Oracle to java.net and other open source projects that make-up GlassFish
  • Continued collaboration, Blogs (The Aquarium), Enhancements (java.net) and the GlassFish Wiki
  • More information: Oracle.com/AppServer

Wednesday, January 27, 2010

News and announcements from todays Oracle / Sun Webcast

I am going to update this posting during/after the webcast and try to collect the relevant information (even the ones, that are relevant to me about java, GF, JEE:))

5:19 PM (via Jason Lee) twitter
JavaOne 2010 WILL happen. Yea. :) No CommunityOne, though :|

5:29 PM (via Arun Gupta) twitter
"JavaOne is an incredible brand and experience", co-located with Oracle Open World in 3rd week of Sep this, no Community One.

5:32 PM (via Arun Gupta) twitter
java.net will continue to live, logo will be updated, love Java Champions program, invest more in infrastructure/community

5:52 (via Eddie Awad) twitter
Ellison said that he expected Sun’s chief executive, Jonathan Schwartz, to resign
many more news and updates came up during the webcast.
Most of the Java relevant ones were collected on a Oracle FaQ page.

Sun Developer Network, java.sun.com
For the near future, all these sites will remain in their current form.

JavaOne in 2010
JavaOne will be co-located with Oracle Develop during Oracle OpenWorld in San Francisco from September 19-23, 2010.

Project Kenai
Project Kenai, will be discontinued for public use.

NetBeans.org
NetBeans.org will continue to be available at the usual URL.

Slides from the Java relevant part of Thomas Kurian:
The Appserver Slide


The Development Slide:


The Java EE Slide:


The Java FX Slide:


The Java ME Slide:


The Java SE Slide:


Java in the world:

SOFTWARE. HARDWARE. COMPLETE. (Oracle + Sun Strategy Update Webcast)


It is known since a few days. Today is the day, where the internet has to proof that it is able to handle big loads. Apple announces his new toy and Larry and his team are going to talk about the Oracle/Sun future. The live webcast takes place
today, Wednesday, January 27, 2010 9:00 a.m. – 2:00 p.m. PT
I am going to tweet about this. Follow me on twitter.com/myfear.

The following agenda will be covered:

9:00 a.m.
Safra Catz: Welcome
Charles Phillips: Oracle + Sun: Transforming the Industry
John Fowler: Hardware Strategy
Thomas Kurian: Software Strategy
Edward Screven: Operating Systems and Virtualization Strategy
Juergen Rottler: Customer Service & Support Strategy
Safra Catz: Software. Hardware. Complete.

12:30 p.m.
Lunch break

1:00 p.m.
Larry Ellison

Switching to blog.eisele.net

As Google/Blogger will discontinue the ftp publishing I need to switch this blog, too.
If you have problems accessing it, you know why. Will post, when it is back online :) Thanks for your patience!

Status:
New adress: http://blog.eisele.net/. Is active. The content under www.eisele.net/blog/ is still available. I am going to redirect requests to files there during the next few days ...

Some tips for changing from ftp publishing to custom domain settings:
1) Add your CNAME DNS entries a few days before actually switching.
2) Switch from ftp to blogspot hosting and after that to custom domain
3) Use feedburner or comparable for your feeds
4) Add new sitemaps to googles webmaster tools
5) Add a permanent redirect with .htaccess

Thursday, January 21, 2010

EC approves Oracle and Sun merger

Only one hour before this post, it was finaly done :)
The EC approves the Oracle/Sun merger.
Oracle announced today that it had received regulatory approval from the European Commission for its acquisition of Sun Microsystems, Inc. Oracle expects unconditional approval from China and Russia and intends to close the transaction shortly.

Here are some links:

techcrunch.com
oracle.com
europa.eu
online.wsj.com

A warm welcome to all of the Sun people around! Happy to have you on board! Looking forward to a great new Java World!! See you on OOW10!

Update (22/01/10):
The _official_ page:
http://blogs.sun.com/jag/entry/so_long_old_friend

Wednesday, January 20, 2010

GlassFish v3, CDI, Maven, Eclipse

I am disaffected with NetBeans. It looks fancy, but I still can't get back the love I had using the 3.x version :) Seems as if I am converted to an Eclipse lover.
This was the point where I started to try getting CDI examples to work with GlassFish v3, CDI/Weld, Maven and Eclipse.
For those of you, haven't made it. Here is the how-to (I am using versions with the numbers in brackets):

1) Get:
- Maven (2.2.1)
- Eclipse (3.6M2)
- GlassFish (v3 build 74.2)

2) Create a maven project using:

mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=cditests -DarchetypeArtifactId=maven-archetype-webapp


3) Add a my-webapp\src\main\java folder to it
4) Add the following dependencies to the my-webapp\pom.xml

<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<scope>provided</scope>
<version>1</version>
</dependency>

<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<scope>provided</scope>
<version>1.0</version>
</dependency>

<dependency>
<groupId>javax.annotation</groupId>
<artifactId>jsr250-api</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>


5) Add an empty file named beans.xml to my-webapp\src\main\webapp\WEB-INF
6) run mvn eclipse:eclipse for making this an eclipse based project
7) add your code
8) run mvn clean install (compile / package)
9) deploy it to your GlassFish domain
10) think about enhancing this with JSF 2.0 ;)

Tuesday, January 19, 2010

JSR-299 CDI portable extensions

One of my fav features of the new CDI spec is the ability to integrate custom extensions. The portable extensions spi is the place to start over with it.
You can find some examples of portable extensions in gavins blog. The latest weld reference documentation (weld-reference.pdf, 867 KiB, application/pdf) contains a chapter (16) with more details about the extension spi.
CDI is intended to be a foundation for frameworks, extensions and integration with other technologies. Therefore,
CDI exposes a set of SPIs for the use of developers of portable extensions to CDI.

Getting started is straight forward. (I was using NetBeans 6.8 with this example)
Add a webproject and a separate java library project. Push whatever is needed to your webproject and don't forget to put an empty beans.xml in your WEB-INF/ folder.
Now, start writing your extension.

1) Create a java class
that implements the marker interface javax.enterprise.inject.spi.Extension


public class MyExtension implements Extension {
//...
}

2) Register your extension
as a provider by creating a folder named META-INF/services/ in your java library project and putt a file named javax.enterprise.inject.spi.Extension in it. This file has to contain the full qualified name of your extension class (in my case net.eisele.cdi.extensions.MyExtension))

3) Implement the extension logic.
Basically extensions listen to events fired by the CDI container and are able to modify the containers metamodel. The events fired are one or all of the following:
javax.enterprise.inject.spi.BeforeBeanDiscovery
javax.enterprise.inject.spi.ProcessAnnotatedType
javax.enterprise.inject.spi.ProcessInjectionTarget and ProcessProducer
javax.enterprise.inject.spi.ProcessBean and ProcessObserverMethod
javax.enterprise.inject.spi.AfterBeanDiscovery
javax.enterprise.inject.spi.AfterDeploymentValidation

You have to add your business methods and declare an @Observes for every event you are willing to catch. Example:

void beforeBeanDiscovery(@Observes BeforeBeanDiscovery bbd) {
log.info("Begin the scanning process");
}


4) You can have a BeanManager
injected to your methods, too.

public void getBeanManager(@Observes BeanManager bm)

The nerve center for extending CDI is the BeanManager object. The BeanManager interface let you obtain beans, interceptors, decorators, observers and contexts programmatically.

5) You can inject your new extension
even it is not really a bean.

@Inject
MyExtension ext;

or

@Inject
MyBean(MyExtension myExtension) {
myExtension.doSomething();
}


If you deploy your app to GlassFish v3 you see something like this in your logfile:
INFO: Begin the scanning process

That was it. You got your first CDI extension up and running.

Monday, January 18, 2010

JSR-299 CDI Interceptors

Playing around with Java EE 6 these days, I came across some new features, I will blog about. Today I just want to give a short introduction to the enhancements made to javax.interceptor by the CDI.

Interceptor functionality is allready defined by the Java Interceptors specification. CDI enhances this with a more sophisticated, annotation-based approach for binding interceptors to beans. Only four stepts to get to your new CDI interceptor.

1) Write the interceptor binding:

@InterceptorBinding
@Target({METHOD, TYPE})
@Retention(RUNTIME)
public @interface Log {}


2) Write the interceptor:

@LogTime
@Interceptor
public class LoggingInterceptor {

@AroundInvoke
public Object logExecutionTime(InvocationContext ic) throws Exception {
long start = System.currentTimeMillis();
try {
return ic.proceed();
} catch (Exception e) {
throw e;
} finally {
long time = System.currentTimeMillis() - start;
String method = ic.getClass().getName();
Logger.getLogger(
LoggingInterceptor.class.getName())
.log(Level.INFO, "*** Invocation of "
+ method + " took " + time + "ms");
}
}
}


3) Declare the interceptor in beans.xml:
<interceptors>
<class>cdi.LoggingInterceptor</class>
</interceptors>

4) Use the interceptor in your code:

//...
@LogTime
public String getText() {
//..
}


That is all. Have fun.

Wednesday, January 13, 2010

JPA 2.0 and Oracle Weblogic 10.3.2.0 (11g)

Everything is about JEE 6 these days. And believe me, I really love the new spec. What I am really missing is the JEE 6 version of a Weblogic server. Anyway, I am still giving parts of the spec some tries on the latest version. Up to now, this was not too successfull. JSF 2.0 is not working. Next was to give JPA 2.0 a try. The guys from the EclipseLink project already did this for me. There is a complete analysis about the possible solutions online in the EclipseLink wiki space. You basically have two differnt options available at the moment to use even parts of the new JPA 2.0.

Change your server/domain install to use new versions of javax.persistence.* and org.eclipse.persistence.* or bundle the related libraries with your application. Both cases have some drawbacks at the moment.

I decided to give it a try anyway and just wanted to give you a more detailed explanation, of what to do to make the second approach work.

First is to get the latest EclipseLink 2.x and the JPA 2.0 API libraries. I was using javax.persistence_2.0.0.v200911041116.jar and eclipselink.jar both taken from the eclipselink-2.0.0.v20091127-r5931.zip download.

Now you have to setup an EAR and a WAR project within your favorite IDE. I am using the Oracle Enterprise Pack for Eclipse (OEPE) for this. Add both jars to the APP-INF/lib folder of your EAR project and change the weblogic-application.xml descriptor by adding the following lines to it:

<wls:prefer-application-packages>
<wls:package-name>org.eclipse.persistence.*</wls:package-name>
<wls:package-name>javax.persistence.*</wls:package-name>
/wls:prefer-application-packages>

Now you have to add a src/META-INF folder to your WAR project. Create a MANIFEST.MF file with the following two lines:

Manifest-Version: 1.0
Class-Path: javax.persistence_2.0.0.v200911041116.jar eclipselink.jar

Place your persistence.xml in the same place. Mine looks like this:

<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="example" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>ds/localJTA</jta-data-source>
<class>...</class>
<properties>
<property name="eclipselink.target-server" value="WebLogic_10"/>
<property name="eclipselink.logging.level" value="FINEST"/>
<property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
</properties>
</persistence-unit>
</persistence>

This is basically everything. Now you can start to put your Entities and business in your webapplication. But remeber to:
- add every Entity as a <class>...</class> entry to your persistence.xml as dynamic class weaving will not work with this approach.
- Reorder the Java Build Path of your IDE to have the EAR libraries in front of any server libraries. Only this way, you will be able to use the new API features.
- As the schema of the persistence.xml states, you are only able to use JPA 1.0 declarations in it.
- Injecting the EntityManager will not work. You have to get it manually from javax.persistence.Persistence like this:

EntityManagerFactory emf = Persistence.createEntityManagerFactory("example");
EntityManager em = emf.createEntityManager();


After all, this is not a full blown approach to JPA 2.0. But better than nothing. Let's hope for a early preview of EclipseLink 2.0 on Weblogic Server.

Monday, January 11, 2010

Running Mojarra 2.0.2 on GlassFish v2.1.1

First of all: Happy new year to all of my readers. I had a quite busy time during the start of the new year. But now, everything seems back to normal operation and I can start over blogging about my fav topics.

A few days ago, a co-worker asked me, about running JSF 2.0 on GlassFish v2.x. I realy was not shure about this first. The JSF 2.0 spec is part of JEE 6 and should work with JDK 1.6. But what about JEE 5 and JDK 1.5? Reading the spec clearly states that it is based on Java 2 Platform, Standard Edition, version 5.0. Ok. This should work according to the spec.

Let's start.
Grep the latest Mojarra 2.0 Download from the projects websites. If you are there already, also get the sources. We will need them later ;)
Extract the binary distribution (mojarra-2.0.2-FCS-binary.zip/.tar) and setup the example build. I was trying to get the "guessNumber" example (mojarra-2.0.2-FCS\samples\guessNumber) working and will use this further on, too.
If you have everything in place, switch to your favorite JDK 1.5 version (I was using the latest 1.5.0_22) and give it a try (mvn clean install).
Without chaning anything, you will notice, that this will not work:

[INFO] Compilation failure
X:\mojarra-2.0.2-FCS\samples\guessNumber
\src\main\java\guessnumber\ClientSideValidatorHandler.java:[42,-1] cannot access
javax.faces.component.UIComponent
bad class file: ~.m2\repository\javax\faces\jsf
-api\2.0\jsf-api-2.0.jar(javax/faces/component/UIComponent.class)
class file has wrong version 50.0, should be 49.0

What does this version thing mean? It states, that the UIComponent.class was compiled with JDK 1.6 and you are trying to use it with JDK 1.5. Fail :|

Lets correct this.
Next is to extract the sources from the download (mojarra-2.0.2-FCS-source.zip/.tar) and compile a JDK 1.5 compliant jsf-api project. Thank god, the JSF guys know how to setup a build. Copy the build.properties.glassfish.orig to a build.properties file and add your jsf.build.home. Beeing behind a corp firewall forces you to add the needed proxy configurations to your ~/.m2/settings.xml file next. Now call ant and build Mojarra 2.0.2.

Now we are going to use our two new jar files. Find
the jsf-api.jar in \mojarra-2.0.2-FCS-source\jsf-api\build\lib and the
the jsf-impl.jar in mojarra-2.0.2-FCS-source\jsf-ri\lib and install them to your local maven repository. I was using other version numbers but same group and artifact ids for testing.

mvn install:install-file -DgroupId=javax.faces -DartifactId=jsf-api -Dversion=2.0.2 -Dpackaging=jar -Dfile=jsf-api.jar

mvn install:install-file -DgroupId=javax.faces -DartifactId=jsf-impl -Dversion=2.0.2 -Dpackaging=jar -Dfile=jsf-impl.jar

Now you have to change the pom.xml of your guessNumber example to reflect the changes. If you are not using a JEE5 SDK, you also have to add the javax.annotation dependency.

<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.0.2</version>
</dependency>


<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.0.2</version>
</dependency>

Almost finished now. Next step is to add a sun-web.xml to the webapp (guessNumber\src\main\webapp\WEB-INF). It should contain:

<class-loader delegate="false"/>
<property name="useBundledJsf" value="true" />

Now you are ready to go. Call mvn clean install and deploy your guessNumber\target\guessNumber.war to your GlassFish v2.1.1 domain. And you are done!