Miles to go …

January 31, 2011

Java EE 6 & GlassFish @ JavaGruppen, JFokus, and Vaadin Meetup

Filed under: General — arungupta @ 9:53 am

Java EE 6 and GlassFish are floating to Denmark, Sweden, and Finland next week.

First stop is … Javagruppen! This annual conference is organized by Danish JUG and this year the theme is "Java – a cloudy affair".

  • Speakers
  • Schedule
  • Venue (Comwell Kellers Park)
  • Register now!
  • @javagruppen

I’ll be speaking on "Running your Java EE applications in the cloud".

Second stop is …. JFokus! This annual conference is organized by Javaforum, Swedish JUG, and will be celebrating 5th anniversary this year.

  • Speakers
  • Schedule
  • Venue (Stockholm Waterfront Congress)
  • Volunteer
  • Register now!
  • @jfokus
  • Speakers tweet-list

Here is the list of sessions presented by Oracle speakers …

  • Learning Nuts & Bolts of Java EE 6 in a Code Intensive Tutorial (Arun, Feb 14, 9am)
  • What a crazy year it has been (Herik, Feb 15, 9:15am)
  • The Java EE 6 Programming Model Explained (Alexis, Feb 15, 2pm)
  • Hitchhiker’s Guide to the NetBeans RCP (Geertjan, Feb 15, 2:35pm)
  • Java EE 6 Toolshow (Arun, Feb 15, 5pm)
  • It’s All About ME (Mobile and Embedded) (Roger, Feb 15, 5pm)
  • The Java EE BOF (Feb 15, 8pm)
  • Running your Java EE applications in the clouds (Arun, Feb 16, 10:10am)
  • JDK 7 Update (Tomas, Feb 16, 1pm)

One of my sessions at JFokus will have a special guest but still need to confirm the exact time slot. Based upon previous experience, this guest adds great humor to the otherwise extremely technical talk and so stay tuned on that :-)

Show your presence and track this conference at lanyrd.

And the third stop is … Vaddin Developer Meetup.

  • Speakers
  • Schedule
  • Venue (Cruise from Turku -> Stockholm)
  • Register now!
  • @vaadin

I’ll be speaking on "OSGi and Java EE Hybrid Applications using GlassFish" at an interesting time of 9:35pm :-)

This is my first time visit to each of these conferences and so certainly looking forward to meeting everybody!

Its going to be really cold, at least for a Californian, at all these places so Runners World tips on winter/snow running and winter gear will be helpful.

Technorati: conf jfokus vaadin meetup javagruppen javaee6 glassfish netbeans osgi

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

January 28, 2011

Oracle User Group Leaders Summit 2011 Report

Filed under: General — arungupta @ 10:56 am

Oracle head quarters was honored to host one of the most active and involved customers earlier this week at the annual User Group Leaders Summit. Other than the usual suspects like IOUG, OAUG, ODTUG and many others, the new additions were Java User Groups, MySQL User Groups, and Primavera SIG. There were about 150 leaders (> 50% increase from 2010) and > 30% of the attendees were from outside the USA. There were 54 sessions delivered sharing our campaigns, products, and services. There were even 12 unconference sessions allowing the attendees to engage in a more informal manner.

Several JUG leaders from around the world represented the Java community: Stephan Jansen (BeJUG), Bruno Souza (SouJava), Kevin Nilson (Silicon Valley Web JUG), Van Riper (Silicon Valley Web JUG), John Yeary (Green JUG), Daniel deOliveira (DFJUG), JP Petines (JEDI), Bert Breeman (NLUG), Max Bonbhel (Congo JUG), Dan Cline (Chicago JUG), Ranganath (Bangalore JUG), Stephen Chin (JavaFX UG), Frank Greco (NYC Java SIG), Dario Laverde (NYC JUG).

I attended sessions in the Java track and gave a presentation on "Whats Cool in Java EE 6" and the slides are available:

Whats Cool in Java E 6

The slides from rest of the sessions are already posted at iouc.org.

There were several sessions in the Java track providing updates on roadmap on different Java technologies. There were several sessions dedicated to hearing feedback from the JUG leaders on whats working and not. Then there was an open session where Steve Harris, Mark Reinhold, Ted Farrell, and Ajay Patel answered open ended questions to the audience. Here are couple of samplers …

Steve Harris – If Java is not successful, we’ll fail! JCP is the best vehicle we’ve to discuss the future of Java. It has the ability to self-heal and has done so multiple times over the past.

Audience: Why didn’t Oracle shutdown GlassFish ?
Steve Harris: Its the RI, Pieces of WLS that are part of RI but not the RI.
The developer community of 10million downloads is very dear to Oracle.
The agility allows to make faster changes. WLS has heavy-duty integration stuff.
Its great technology, team, and investment on their part.
It’ll be a bad bad mistake to kill GlassFish.

Henrik on why Oracle will strive to make sure Java is successful: There are 20k developers working on Java inside Oracle, can’t mess with Java.

The response from the twittersphere (#iouc) was positive and here are some sample tweets:

  • @debralillley Great #IOUC so far, lots #ukoug stuff done yesterday now main summit starts, lots of usergroup leaders here, you can smell the passion #fb
  • @BambiPrice @odtug Oracle welcoming MySQL leaders to the #IOUC summit
  • @Mike_ODTUG Great to hear all of the exciting things all of the user groups accomplished last year. Congrats to all! #IOUC #ODTUG
  • @stenvesterli Ronan Miles @UKOUG__Chair from #UKOUG receiving Lifetime Award from Judith Sim at #IOUC. CONGRATULATIONS!
  • @Stephan007 Oracle nominates SouJava to the JCP Executive Committee. #IOUC
  • @BertBreeman Unconference during #IOUC-Summit new experience for a lot of people; JUG-leaders has more and more influence in this Summit; everybody happy
  • @congojug #IOUC Collaborating with Oracle in the #JUG Communities at #Oracle Headquarters #CongoJUG
  • @BertBreeman Good discussion during #IOUC: JavaOne vs OpenWorld. Oracle is listening to us. JavaOne separated from OpenWorld. JavaOne will be reanimated!
  • @BertBreeman JavaOne discussion during #IOUC: JavaOne probably going back to his original timezone: during Spring. JavaOne: the place to be again!
  • @johnyeary Finished the #IOUC #JUG leader summit earlier today. It was a successful event in my opinion. I walked away with a lot of good ideas.

Oralce nominated SOUJava to a seat in the JCP Executive Committee. The special elections are coming soon and we hope the members will vote to elect Bruno Souza to the JCP. Many congratulations to SOUJava and Bruno for the nomination!

Here are some pictures from the event …

And the complete album below:

Technorati: conf summit usergroup jug leaders iouc oracle community

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

January 26, 2011

Java Pass: Huge Savings on Oracle’s Top 10 Java Live Virtual Classes

Filed under: General — arungupta @ 2:00 am

Companies are taking advantage of Java Pass, a program from Oracle University that helps get developers and programmers up to speed with Java. With Java Pass, each employee you sign up can take Oracle’s top 10 Java Live Virtual Classes for a full year at a significantly lower cost, plus receive a discounted voucher for a Java Certification exam. Students train and become Java certified on their own schedules, without the expense and hassle of travel.

Now available in Australia,  Canada, Germany, United Kingdom, and United States.

There are several Java SE 6 and Java EE 6 courses available.

Why wait ? Sign up now!

Technorati: oracle university education javapass courses training certification

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

January 25, 2011

2-day Java EE 6 workshop in Budapest – Delivered, More coming!

Filed under: General — arungupta @ 4:19 am

I delivered a 2-day Java EE 6 workshop in Budapest last week. This was my longest speaking engagement at one shot and I really enjoyed it! There were about 30 attendees and hoefully they enjoyed it too :-)

Other than talking about the key Java EE 6 technologies (CDI, Bean Validation, Servlets 3, JSF2, JPA2, EJB 3.1), the 2-day workshop gave ample time to show NetBeans and Eclipse live coding sessions and interact with the attendees. Here is some feedback from the attendees:

  • We expect more productivity and cleaner code with Java EE 6.
  • Simplified EJB development without XML DD.
  • Good mixture & collection of effective tools of coding styles today, seems really effective.
  • Like CDI, better than Spring because of no XML DD. Hate XML.
  • CDI is one of the most powerful features of Java EE 6, make it easier with web tier, also makes it possible to introduce new annotations.
  • Opens the barrier, not so rigorous, more flexible, For example EJBs in web container.
  • Auto-deploy is great
  • JSF is usable.
  • Programmers Non-standrd way to solve problems, Java EE 6 is solving that problem.
  • Improvements of EJB testability.

This workshop is also getting scheduled at the following locations (provided enough attendees register) …

  • Manila – Feb 28/Mar 1
  • Singapore – Mar 3/4
  • Netherlands – May 23/24

Here are some pictures from Budapest …

Also managed to get another run by River Danube:

And now the complete photo album:

Technorati: conf javaee6 glassfish netbeans eclipse

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

January 24, 2011

Oracle WebLogic Server and Java EE 6 – FREE OTN Virtual Developer Day

Filed under: General — arungupta @ 4:40 pm

Do you know that recently released WebLogic 10.3.4 supports some of the key Java EE 6 APIs (JSF2, JPA2, JAX-RS 1.1) ?

Do you know that WebLogic is planning to go Java EE 6 compliant later this year ?

Do you want to practice some hands-on stuff with WebLogic using a VirtualBox image ?

OTN is conducting a Virtual Developer Day on several dates next month to get you started easily.

When ?
Feb 1, 9:30am Pacific Time
Feb 10, 9:30am UK Time / 10:30 am Central European Time
Feb 17, 9:30 India Time
Feb 24, 9:30am China Time

Where ? Online event, register today!

What ?

  • 3 tracks, keynote, hands-on-labs powered by VirtualBox
  • Moderated chat during sessions and labs
  • Networking lounge

Here is the complete agenda:

And the twitter hashtag for the event is: #otnvdd

Register today!

Technorati: conf webinar otn weblogic javaee6

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

January 21, 2011

Screencast #37: Java EE 6 with NetBeans and GlassFish – Webinar Replay and Q&A

Filed under: General — arungupta @ 1:07 pm

The replay of Java EE 6 with NetBeans and GlassFish webinar is now available:

This video can also be seen in full screen HD mode.

The complete source code built during this webinar can be downloaded here.

And here is a transcript of Q&A session from the webinar:

Q. How can I using NetBeans generate an entity class with SequenceGenerator annotation for a PostGreSQL table?
A. If you use NetBeans to generate entities from database, it should do the right thing, based on the SQL types of your DB columns. If not, please file a bug report against NetBeans. Thanks.

Q. Do I need to have a good idea in Java EE 6 to attend this conference ?
A. I would help a bit, but NetBeans is doing a great job at helping discovering Java EE 6 with GlassFish

Q. Is there a EOL for GlassFish?
A. There is no EOL for GlassFish as a product. As the reference implementation for Java EE, GlassFish is a strategic product for Oracle. As with any software product, specific versions of GlassFish will EOL over time, as newer releases come out. For example, Oracle GlassFish Server 2.x will be supported until 2014, and we are working now on releasing GlassFish Server 3.1 in the near future.

Q. What is the link to file a bug report for NetBeans IDE?
A. This should help: http://netbeans.org/community/issues.html

Q. Can we you eclipse instead of netBeans?
A. Yes. The GlassFish Eclipse Plugin is available. Screencast #36 shows how to use Eclipse for Java EE 6 development and deployment with GlassFish.

Q. I would love to see a GF 3.0.2 fixing the known memory leaks. Any plans on that, or will it be GF 3.1? (And when?)
A. Fixes for GlassFish Server 3.0.1 will be available either through a support contract (patch), or you can always publish an issue on issuetracker at http://glassfish.java.net, and it will get addressed in the trunk (and 3.1 releases).

Q. Hi, My name is Andrew. i’d like to know all the possible ways to pass values between different JSF pages.and the value which need to be passed is dynamic. A. The easiest way is to use the new Flash scope in JSF 2.0. Failing that you can put it in session and remove it. You could also use @ConversationScoped from CDI.

Q. Why we have no glassfish rpm packets even for Oracle Enterprice Linux?
A. We have to support many Unix/Linux variant so we provide one shell script for all flavors including OS X. In the next release we provide topology creation in the installer which make a RPM less viable. Zip installs are also available.

Q. can you repeat? what blog?
A. The blog we mentioned is hosted by Arun Gupta, blogs.sun.com/arungupta – and a link to all webinar content will always be available at http://glassfish.org/webinars/

Q. How do we do junit without depending on Glassfish server. I want my junit to be totally independent of runtime.
A. If you want to test EJB and CDI code, you will need the embeddable container, which is server-specific. If you want to only test utility classes or JPA, this can be server-independent.

Q. is there any online classes on Java EE6 with Netbeans and GlassFish?
A. This is a great starting page: http://netbeans.org/kb/trails/java-ee.html. See for example the 5-part video screencast.

Q. it is possible.. they dont have any support
A. If you are asking about support for the products, yes – support is available from Oracle for GlassFish server, and for Netbeans you can go to http://netbeans.org/community/lists/index.html You can also obtain incident support for Netbeans from Oracle at http://netbeans.org/kb/support.html If you would like more information, please email [email protected]

Q. What kind of support is NetBeans providing for REST frameworks like Spring-RS?
A. NetBeans has a very good and extensive REST support for JerSey (The reference implementation of JAX-RS) and GlassFish 3 which contains JerSey. For Sprin-RS you would need to regsiter as an external library… I am not sure how well it is tested with GlassFish, since there is no need to use a external RS implementation when one is provided in the Java EE 6 runtime

Q. I feel like this is just a heavy adaptation of the Ruby on Rails scaffolding capability, don’t you think ?
A. Yes, Rails definitely had a good influence on Java server-side development. Many good things in Java are inspired by Rails.

Q. where i can download Netbeans ?
A. netbeans.org

Q. What is the difference between singleton EJB and an EJB with maxbeans-in pool=initialbeans-inpool=1 ?
A. A quick answer is that the @Singleton annotation is defined by the Java EE 6 specification, is much more readable by developers, and less error-prone than editing container configuration (or other historical workarounds such as static fields). You can also ask at the GlassFish users forum at http://www.java.net/forums/glassfish/glassfish

Q. My Netbeans 6.9.1 does not have Servers or Glassfish on the Services tab, do I need Netbeans 7 to bring up Servers?
A. Which edition of NetBeans do you have? If you have "all-in-one", then the Java EE development features may not be activated. When you start creating a web project, these features will be activated and you will see Servers. You need "Java" or "all-in-one" edition.

Q. What is the Oracle strategy to move forward with NETBEANS and Jdeveloper?
A. Both will continue as supported IDEs at Oracle. Jdeveloper is usually for ADF development and other Fusion development. NetBeans is great for cutting edge Java SE/EE/FX/ME development. Large teams continue to work on both products. They are both swing based IDE tools — JDeveloper may start to incorporate select netbeans features in the future.

Q. I understand netbeans IDE, but what is the benefit of glassfish?
A. GlassFish offers a lightweight, modular Java EE 6 runtime. It offers rapid development features such as saving HTTP session state on redeploy.

Q. What make me move to glassfish since there’s lot IDE tools ?
A. GlassFish offers a lightweight, modular, and productive runtime for Java EE 6.

Thank you every body for attending the webinar!

The complete list of webinars (replay and upcoming ones) is listed at glassfish.org/webinars.

Technorati: conf webinar javaee6 glassfish netbeans

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

January 19, 2011

Running by River Danube in Budapest

Filed under: General — arungupta @ 9:23 am

River Danube is Europe’s second largest river, runs for about 1771 miles, originates in Black Forest, Germany, empties into Black Sea, flows through 10 different countries, and 11.7% of it flows through Hungary. I ran about 6 miles (actually 3 because ran couple of loops) along the river in Budapest earlier today before it became cold, wet, and dark!

Click on the image to find more details about the run.

This was a great way to stretch out legs after first international flight of the year. And now Java EE 6 workshop tomorrow!

The hotel has no fitness center (dang!), the next two days are going to be long, and it gets bright late and dark early here so not sure if I’ll get another opportunity to run.

Fingers crossed …

Technorati: conf running hungary budapest river danube

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

January 17, 2011

Java EE Day @ JAX San Jose 2011

Filed under: General — arungupta @ 11:14 pm
After conducting multiple conferences, primarily in Europe, and some in other parts of the world, for many years, JAX is now coming to the USA as well. And that too right in the heart of Silicon Valley, in the downtown San Jose.

The Call for Papers ends on Jan 21 and allows you to submit papers in several different tracks such as Java Core, Java Enterprise, JSF Summit, Web Tech, Agile Tools & ALM, Cloud, Mobile, and many others. There will be a Java EE day as part of the conference so please submit your sessions today and make sure to mark them to be included in the Java EE track.

What are we looking ?

  • Are you passionate about any or all Java EE 6 technologies and using them to solve your business problems ?
  • Are you building CDI extensions ? Any creative or radical usage of CDI ?
  • Are you using PrimeFaces or any other JSF 2-compliant libraries, in conjunction with rest of the Java EE 6 stack ?
  • Are you using EJB-in-a-WAR packaging, web.xml-free Servlets, RESTful Web services using JAX-RS or any other ease-of-use features from Java EE 6 in your applications ?
  • Any production tips on going live with Java EE 6 ?
  • Any migration experience from properietary frameworks to Java EE 6 ?
  • Any migration experience from previous versions of J2EE 1.4 and Java EE 5 to Java EE 6 ?
  • Would you like to participate in a panel discussion ?
  • Are you one of the spec leads and would like to share your perspective ?
  • Any other wild ideas around Java EE ? :-)

Don’t wait, submit your papers now!

When ? Jun 20-23, 2011

Where ? San Jose Convention Center (right in the downtown)

Follow @jaxconf for the latest updates!

Jun 21st also marks the beginning of summer in the US and where else would you want to be other than sunny California to celebrate it :-)

Technorati: conf jaxconf sanjose javaee

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

January 12, 2011

JAX-RS 2.0 and JPA 2.1 JSRs filed … Java EE 7 moves forward!

Filed under: General — arungupta @ 1:00 am

JSR 338 (JPA 2.1) and JSR 339 (JAX-RS 2.0) are the first formal steps in moving Java EE 7 platform forward!

The key features considered in scope of JPA 2.1 are:

  • Support for the use of custom types and transformation methods in object/relational mapping.
  • Support for the use of "fetch groups" and/or "fetch plans" to provide further control over data that is fetched, detached, copied, and/or used in merging.
  • Support for the specification of immutable attributes and readonly entities.
  • Support for user-configurable naming strategies for use in O/R mapping and metamodel generation.
  • More flexibility in the use of generated values; support for UUID generator type.
  • Additional mapping metadata to provide better standardization for schema generation.
  • Support for multitenancy.
  • Additional event listeners and callback methods; availability of entity manager to callbacks.
  • Methods for dirty detection.
  • Improved ability to control persistence context synchronization.
  • Additional unwrap methods to support use of vendor extensions.
  • Support for dynamic definition of persistence unit, including object/relational mapping information.
  • Extension of metamodel API to object/relational mapping information.
  • Improvements to the Java Persistence query language and criteria APIs

More details in JSR 338. Click here if you are interested in joining this Expert Group.

The key features considered in scope of JAX-RS 2.0 are:

  • Client API – a low-level using a builder pattern and a higher level leveraging the former one
  • Hypermedia processing on client and server
  • MVC architecture compatible with JAX-RS programming model
  • Integration with Bean Validation for parameter validation
  • Tighter integration with JSR 330 annotations, such as @Inject
  • Asynchronous request processing
  • Sophisiticated server-side content negotiation
  • More ease-of-development following DRY principles

More details in JSR 339. Click here if you are interested in joining this Expert Group. This Expert Group will have a public observer alias to monitor discussions.

The JSR ballot closes on Jan 24, 2011. After the JSRs are approved the Expert Groups start discussion on each and every item of the proposal. And you’ll start seeing the promoted builds and integrations into GlassFish after that.

Stay tuned to hear details as Java EE 7 continues its march forward. In the meanwhile, you can download GlassFish 3.1 promoted build (soon to be final) that provides full Java EE 6 functionality along with centralized administration and high availability.

Technorati: javaee7 glassfish jaxrs jpa restful persistence

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

January 11, 2011

TOTD #154: Dynamic OSGi services in GlassFish 3.1 – Using CDI and @OSGiService

Filed under: General — arungupta @ 4:00 am

TOTD #131 explained how dynamic OSGi services can be easily created and deployed in GlassFish. The dynamism comes from the fact that the client keeps a reference to the service which is automatically refreshed if the bundle providing the service is refreshed. That tip used ServiceTracker API for the dynamic discovery of service which still uses some boilerplate code. In Java EE 6 environment, this can be further simplified by using CDI to inject the service and delegate all the service discovery/bind code to a CDI Qualifier available using CDI extensions in GlassFish 3.1.

Siva provides more details in his blog. But basically GlassFish 3.1 comes with a a standard CDI portable extension (org.glassfish.osgi-cdi) that intercepts deployment of hybrid applications that has components who have expressed dependencies on OSGi services. This CDI extension then takes care of discover, bind, inject, and track the service.

With this new CDI extension, the boilerplate code of dynamically tracking the service changes from:

ServiceTracker tracker = new ServiceTracker(context, Hello.class.getName(), null);
tracker.open();
Hello hello = (Hello) tracker.getService();
System.out.println(hello.sayHello("Duke"));

to

@Inject @OSGiService(dynamic=true) Hello hello;
System.out.println(hello.sayHello("Duke"));

No String-based and completely typesafe resolution of an OSGi service in a web application, how neat!

This will work in a "hybrid application" only, and not in pure web application, as BundleContext is required for dynamically tracking the service. Notice that by default the application is not ready to handle the dynamicity of OSGi environment and so "dynamic=true" need to be set explicitly on @OSGiService.

The complete source code for this application is available here. This project consists of 4 Maven modules:

  • helloworld-api
  • helloworld-impl
  • helloworld-client
  • helloworld-cdiclient

The first three modules are explained in detail at TOTD #131. Lets create "helloworld-cdiclient" module!

  1. In the parent directory of TOTD #131 zip file, create a new Maven module as:
    mvn archetype:create -DarchetypeGroupId=org.apache.maven.archetypes -DgroupId=org.samples.osgi.helloworld -DartifactId=helloworld-webclient
    

    Make sure to change the all the references from "totd131" to "totd154".

  2. The updated directory structure looks like:
    osgi.properties
    pom.xml
    src
    src/main
    src/main/java
    src/main/java/org
    src/main/java/org/samples
    src/main/java/org/samples/osgi
    src/main/java/org/samples/osgi/helloworld
    src/main/java/org/samples/osgi/helloworld/App.java
    src/main/resources
    src/main/webapp
    src/main/webapp/index.jsp
    src/main/webapp/WEB-INF
    src/main/webapp/WEB-INF/beans.xml
    
    1. "index.jsp" is generated by the Maven archetype
    2. "beans.xml" is a newly added file to enable CDI injection
    3. "osgi.properties" is a newly added file and is used to read the metadata for OSGi hybrid application
    4. "App.java" is a Servlet that invokes the service
  3. The "osgi.properties" file looks like:
    Web-ContextPath:/helloworld-cdiclient
    

    This makes sure that the hybrid application is accessible at "/helloworld-cdiclient" context root.

  4. The updated "pom.xml" looks like:
    <?xml version="1.0" encoding="UTF-8"?>
    <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
    http://maven.apache.org/xsd/maven-4.0.0.xsd"
    xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>
    <parent>
    <artifactId>totd154</artifactId>
    <groupId>org.samples.osgi.helloworld</groupId>
    <version>1.0-SNAPSHOT</version>
    </parent>
    <packaging>war</packaging>
    <groupId>org.samples.osgi.helloworld</groupId>
    <artifactId>helloworld-cdiclient</artifactId>
    <version>1.0-SNAPSHOT</version>
    <name>helloworld-cdiclient</name>
    <url>http://maven.apache.org</url>
    <dependencies>
    <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>3.8.1</version>
    <scope>test</scope>
    </dependency>
    <dependency>
    <groupId>org.samples.osgi.helloworld</groupId>
    <artifactId>helloworld-api</artifactId>
    </dependency>
    <dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-api</artifactId>
    <version>6.0</version>
    <scope>provided</scope>
    </dependency>
    <dependency>
    <groupId>org.glassfish</groupId>
    <artifactId>osgi-cdi-api</artifactId>
    <version>3.1-SNAPSHOT</version>
    <scope>provided</scope>
    </dependency>
    </dependencies>
    <build>
    <pluginManagement>
    <plugins>
    <plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <version>2.1.0</version>
    <extensions>true</extensions>
    <configuration>
    <supportedProjectTypes>
    <supportedProjectType>ejb</supportedProjectType>
    <supportedProjectType>war</supportedProjectType>
    <supportedProjectType>bundle</supportedProjectType>
    <supportedProjectType>jar</supportedProjectType>
    </supportedProjectTypes>
    <instructions>
    <!-- Read all OSGi configuration info from this optional file -->
    <_include>-osgi.properties</_include>
    <!-- By default, we don't export anything -->
    <Export-Package>!*.impl.*, *</Export-Package>
    </instructions>
    </configuration>
    <executions>
    <execution>
    <id>bundle-manifest</id>
    <phase>process-classes</phase>
    <goals>
    <goal>manifest</goal>
    </goals>
    </execution>
    <execution>
    <id>bundle-install</id>
    <phase>install</phase>
    <goals>
    <goal>install</goal>
    </goals>
    </execution>
    </executions>
    </plugin>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
    <source>1.5</source>
    <target>1.5</target>
    </configuration>
    </plugin>
    <plugin> <!-- Need to use this plugin to build war files -->
    <artifactId>maven-war-plugin</artifactId>
    <groupId>org.apache.maven.plugins</groupId>
    <!-- Use version 2.1-beta-1, as it supports the new property failOnMissingWebXml -->
    <version>2.1-beta-1</version>
    <configuration>
    <archive>
    <!-- add bundle plugin generated manifest to the war -->
    <manifestFile>
    ${project.build.outputDirectory}/META-INF/MANIFEST.MF
    </manifestFile>
    <!-- For some reason, adding Bundle-ClassPath in maven-bundle-plugin
    confuses that plugin and it generates wrong Import-Package, etc.
    So, we generate it here.
    -->
    <manifestEntries>
    <Bundle-ClassPath>WEB-INF/classes/
    </Bundle-ClassPath>
    </manifestEntries>
    </archive>
    <!-- We don't have a web.xml -->
    <failOnMissingWebXml>false</failOnMissingWebXml>
    </configuration>
    </plugin>
    </plugins>
    </pluginManagement>
    <plugins>
    <plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    </plugin>
    </plugins>
    </build>
    </project>
    

    Screencast #32 provide a detailed explanation of this "pom.xml". A basic introduction to "hybrid applications" is given here.

  5. The updated "App.java" looks like:
    package org.samples.osgi.helloworld;
    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.inject.Inject;
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.glassfish.osgicdi.OSGiService;
    import org.samples.osgi.helloworld.api.Hello;
    /**
    * Hello world!
    */
    @WebServlet(urlPatterns = {"/HelloWebClient"})
    public class App extends HttpServlet {
    @Inject @OSGiService(dynamic=true) Hello hello;
    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException {
    PrintWriter out = response.getWriter();
    out.println(hello.sayHello("Duke"));
    }
    }
    

    This is a "web.xml"-free servlet using @WebServlet. "@OSGiService" is used to dynamically discover, bind, inject, and track the service. So if the backend service changes then the service reference is automatically updated without any additional effort.

  6. Build and Deploy this project as:
    mvn clean install
    asadmin deploy --type=osgi  target/helloworld-cdiclient-1.0-SNAPSHOT.war
    

    Optionally you can also drop this generated WAR file to "glassfish/domains/domain1/autodeploy/bundles" directory as well.

  7. Run the app
    1. Make sure helloworld-api-* and helloworld-impl-* bundles are already deployed as explained in TOTD #131.
    2. Invoking "curl http://localhost:8080/helloworld-cdiclient/HelloWebClient" shows the result as "Hello Duke".
    3. Change "org.samples.osgi.helloworld.impl.HelloImpl" to use "Howdy" string instead of "Hello", build the bundle again (mvn clean install), and copy it to the "glassfish/domains/domain1/autodeploy/bundles" directory.
    4. Invoking "curl http://localhost:8080/helloworld-cdiclient/HelloWebClient" now shows the result as "Howdy Duke". This ensures that the service changes are dynamically tracked.

I tried this with GlassFish 3.1 build 35 Web Profile.

Read the latest about GlassFish and OSGi integration on this wiki.

Where are you deploying your OSGi applications ?

Technorati: totd osgi javaee6 glassfish dynamic discovery

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot
Older Posts »

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.
Powered by WordPress