Tag Archives: java

Javapolis becomes Javoxx

A new name, a new logo but the same concept: Javapolis became Javoxx this week as javoxx.com was launched.

We still have to wait a bit about the exact reasoning behind the name switch, but the goal of the conference is clear: be the java community conference. (as it’s organized by the Belgian Java User Group (BeJUG).

Javoxx will take place from December 8th till 12th in Antwerp, Belgium.

Setup Weblets 1.0 for JSF on Weblogic 8.1

This week I’ve tried to upgrade from Weblets 0.4 to 1.0 while using the following technologies: JSF1.1, JDK1.4 and Weblogic 8.1.

Here are some of my experiences:

As noted in the documentation on https://weblets.dev.java.net/doc/longdoc/setup.html, the web.xml needs the following additions:

       <servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>

This URL pattern will be used only by Weblets. The generated URLs whenever you call weblet:url / weblet:resource via EL, Javascript, CSS or Java will begin with /faces.
This in fact makes sure that the WebletsPhaseListener knows when to process a resource or not by looking at the url

For Weblogic 8.1 it also necessary to add the following listener to your web.xml:

 

 <listener>
<listener-class>net.java.dev.weblets.WebletsContextListener</listener-class>
</listener>

I couldn’t get Weblets to work without it.

Last but not least you should add mime-mappings to your web.xml for all the different types of static resources you want Weblets to serve:

<mime-mapping>
<extension>css</extension>
<mime-type>text/css</mime-type>
</mime-mapping>
<mime-mapping>
<extension>js</extension>
<mime-type>application/x-javascript</mime-type>
</mime-mapping>
<mime-mapping>
<extension>gif</extension>
<mime-type>image/gif</mime-type>
</mime-mapping>

<mime-mapping>
<extension>png</extension>
<mime-type>image/png</mime-type>
</mime-mapping>

<mime-mapping>
<extension>jpg</extension>
<mime-type>image/jpg</mime-type>
</mime-mapping>

If you don’t do this, then a NullPointerException is thrown internally by Weblets and gives problems serving the static resources.
I don’t know about other servers, but on Weblogic doing a servletContext.getMimeType will return null when it was not defined in the web.xml

In fact, Weblets 1.0 also supports defining a <mime-mapping> in the weblets-config.xml. But adding the mime types only there didn’t work as in the Weblets source code there are few places where servletContext.getMimeType is called directly thus ignores any configuration done in the weblets-config.xml. For the next version of Weblets it would be interesting to fix this behaviour and document eg. that mime-mappings in weblets-config.xml take precedence. And if not defined there, Weblets will try to look for mime-mappings in the web.xml via the servlet context.

Weblets 1.0 has been released

Weblets 1.0 has been released at weblets.dev.java.net

Weblets is a Java servlet based framework that provides an easy way of loading resources (Javascript, CSS, images, …) directly out of JAR files.

For us the following features were the reason to start using it:

  1. Weblets has a full frontend api for neutral resource handling. This includes
    • a JSP API
    • JSF facelet integration
    • Using weblets from CSS and Javascript files is also possible.
  2. Weblets will automatically add Expires, If-Modified-Since headers to your HTTP responses. This enhances performance and is a way to implement Rule 3: Add an Expires Header from the Yahoo Performance team (http://developer.yahoo.com/performance/rules.html#expires)
  3. Weblets can automatically version your static resources. (eg. by adding a version id into the generated URL). Doing this accomplishes two things:
    • when a new version of eg. a CSS is in your jar, the URL location where it is served from will change (version id will be different). So there will be no browser issues of people still using the old version as the new URL will not yet be in the cache of the browser.
    • the first point allows you to define much more far future Expires headers; thus the chance that browser will use a cached version will be far higher, enhancing front end performance.

In the next post we will look at using Weblets 1.0 in a Weblogic 8.1 environment.

JSF 1.1 and 1.2 Support in future versions of Richfaces

Richfaces, one of the most fully featured JSF frameworks from JBoss has posted their roadmap for the future versions on their forum.

The Richfaces 3.1.x branch (the current general access production version) is now in maintenance mode and will not receive any new functionality anymore. Only bugfixes that do not require a long QA testing period will still be fixed on this branch.

This branch is also the latest one that supports JSF1.1 and Java 1.4! So it’s really getting time to upgrade to Java 5 or 6!

Richfaces 3.2.0, which supports JSF1.2 and Java 1.5 (or higher) will be released at the end of March. Richfaces 3.1.5 will be released around three weeks after the Richfaces 3.2.0 release. (e.g. the second half of April, 2008.)

More info at http://jboss.com/index.html?module=bb&op=viewtopic&t=129518

Javapolis 2007: Next gen RIA site Parleys.com V2 Beta is Available

RIA site Parleys.com V2 BetaOne of the coolest Flex based RIA applications showcased during the Javapolis 2007 convention was the beta of the new Parleys.com website. Parleys hosts all videos and presentations from Javapolis and other BeJUG organized events and is great source of information for Java developers to stay current.

Now version 2 is available for testing at http://www.parleys.com/display/PARLEYS/Parleys.com+V2+BETA+Program

Be sure to check out the online version and the desktop version (showcasing Adobe AIR technology). As a JSF/Richfaces/AJAX developer I’m impressed by the speed & look ‘n feel of the site. Having to implement the below requirements is certainly not easy either with the traditional set of Java web tools.

  • Full screen viewing of talks
  • Add comments and tags in the presentation time line
  • Bookmark talks and slides and forward them to a friend
  • Change slide transitions

Javapolis 2007: Bamboo, continuous integration the easy way

On Javapolis 2007 Atlassian presented two new products aimed at helping agile management projects ‘work’ in the real world.

First in the line is Bamboo, their continuous integration tool. Next we’ll talk about Crucible.

The guy from Atlassian Bamboo began his talk by telling the audience that “Continuous integration is a process, not a tool’. That’s certainly true, you should first think about your process before starting to setup tooling. That said, there are a lot of tools with an inadequate feature set or skyhigh prices, ultimately leading to a good process which is not followed in practice due to timeconstraints.

Bamboo tries to fit in a lot of functionality while still being relatively inexpensive.

Features include:

Build telemetry

Bamboo dashboard

Build telemetry lets you interpret statistics and trends of your builds. It also allows you to drill down into a specific build or pull up and look at overview information. Having this empirical data at your fingertips supports change as you can make informed choices.

Interesting statistics include:

  • build time
  • % of successfull builds
  • number of test failures
  • average time to fix a failure
  • allows comments on a failure
  • graph, allows to see trending and comparision between projects

Test telemetry

Test telemetry lets you interpret statistics and trends of your Unit Tests.

Handy features include:

  •  drill down to the tests that have failed
  • see if this test has failed in the past?
  • if true see how it was fixed the last time
  • a Top 10 of failing tests
  • historical summary of your tests can help identifying problem areas

Besides those two types of statistics, Bamboo also features a plugin framework which you can use to for example integrate Clover (coverage tool), PMD and FindBugs.

Seam in Action Javapolis University Day 1

Seam is the newest JSF based framework in town and this presentation by Peter Hilton and Pete Muir explained the shortcomings of existing JSF frameworks and ways to overcome these problems with Seam.

Seam promises tight integration with other frameworks/specs including:

  • EJB
  • Hibernate
  • jBPM (java business process management)
  • Richfaces
  • Drools (rules engine)

It also offers Eclipse IDE support with the JBoss tools plugin.

Continue reading Seam in Action Javapolis University Day 1

Java Generics and Collections in Action

On Monday, Maurice Naftalin, co-author of the Book Java Generics and Collections presented a talk about two new features in Java5/6:

  • Generics
  • (Concurrent) Collections

Generics

Maurice started by stating the advantages of using generics. These include the following:

  • cleaner code (eg. the enhanced for-loop; no casts)
  • more errors can be detected at compile time (which would otherwise only be noticed at run time)

Maurice then talked about the ‘by erasure’ implementation of generics that makes it possible to gradually ‘generify’ legacy libraries and your client code.

(Concurrent) Collections

Collections in Java (since v1.2) are by default not thread safe, which means that two threads can simultanuously read/write to a Collection, possiby leaving the Collection in an inconsistent state.

Thread safe Collections are also available, but note that this is not the same as concurrent safe access. Eg. when iterating (which is obviously is not an atomic operation) over a thread safe collection you’ll receive a ConcurrentModificationException when the underlying collection is modified. (a so-called fail-fast iterator)

The java.util.concurrent package introduce weakly consistent iterators. Weakly consistent iterators may or may not reflect insertions made during iteration, but they will definitely reflect updates or removals for keys that have not yet been reached by the iterator, and will not return any value more than once.

Here is a summarized list of the non thread safe and new java.util.concurrent Collection interfaces and when to use them. (Remember to choose your collection based on functional behaviour, performance characteristics and concurrency policies.)

  • Queues
    • Not threadsafe with FIFO ordering
      • ArrayDeque
      • PriorityQueue
    • Threadsafe (with weakly consistent iterator)
      • PriorityBlockingQueue
      • DelayQueue
      • ConcurrentLinkedQueue: best non blocking threadsafe queue
  • Lists
    • Threadsafe (with weakly consistent iterator)
      • CopyWriteArrayList: good when you have more reads then writes
    • Non thread safe
      • ArrayList: best general purpose list
      • LinkedList: only ok qua performance when using a ListIterator (which provides remove, add and iteration operations) – never do access by index => slow!!
  • Sets
    • Non thread safe
      • HashSet
      • LinkedHashSet: this set keeps O(1) when the set is almost full
      • EnumSet: optimized for using Enums objects
    • Threadsafe (with weakly consistent iterator)
      • CopyInWriteArrayList: good when you have more reads then writes

Javapolis 2007 University Day 1

This week I’m attending Javapolis 2007, the biggest European Java event, which is organized in Antwerp, Belgium (my homecountry :-)).

Today I went to the following talks:

  • Java Generics and Collections in Action
  • Seam in Action
  • Making sense of your builds with Bamboo Continuous integration server
  • Addictive code reviews with Crucible

Watch out for a detailed report on each of these talks in future blog posts!

Welcome to Java Blog – your source for Java tips and tricks!

Hi there, welcome to my new Java Blog!

I’m Wim Bervoets and I have been a Java developper since 1998 when I started using it on some projects at University. With this blog I hope to give you an overview of all the interesting things happening in the Java world and stuff I have learned over the years.

These include topics ranging from

  • backend java
  • web development (including JSF frameworks, AJAX frameworks, CSS, Javascript, …)
  • tooling (Eclipse, Netbeans)

till codequality tools like Findbugs.

Next week you can expect some coverage from the Javapolis event!