I've mainly worked at companies which are "IBM shops" - you know, those that use RAD as their IDE and WebSphere as their Application Server. Irrespective of the version working iteratively with JEE web applications has never been a joyous experience - sometimes the code is hot swapped, sometimes I have to restart the server, sometimes the server stops responding and I have to kill the process. Always the server is slow to start. Of course, the hardware makes a difference, but not enough - development should be quick, responsive and I should get instant feedback on my changes.
Having recently purchased a Mac, Intellij 12 in their "Doomsday Sale" and having my interest perked by the WebSphere liberty dev team giving an IAMA on Reddit, I thought I'd see how this setup compared to my usual setup i.e. Windows, RAD and WebSphere server with all its bells and bloat.
In this first post I walk through installing the WAS Liberty Next Profile and setting up a simple JEE6 project, via a Maven archetype. Full conclusions I'll leave for another post, when I've done some "proper" work, as opposed to the Mickey Mouse example described below.
I've gone for the early access / beta version, which offers CDI, EJB Lite and Managed Beans support. This is called Next by the WebSphere team.
- java -jar wlp-developers-runtime-8.5.next.beta.jar
- bin/server create planetjones
Unfortunately Intellij is unable to recognise the new Next Profile, but copying 3 folders: /dev/api/ibm, /dev/api/spec and /dev/api/third-party into /dev/ seems a fair workaround until Intellij adds support. Note: I'm not sure why a profile where speed is the main concern, needs to be installed and a new instance created - unzipping it and being ready to go, would be easier.
<groupId>org.codehaus.mojo.archetypes</groupId> | |
<artifactId>webapp-javaee6</artifactId> | |
<version>1.5</version> |
You may need to enable the WebSphere plugin at this point. Open Preferences (shortcut "cmd,") then go to Plugins and check "Websphere Integration".
Open /usr/servers/
<?xml version="1.0" encoding="UTF-8"?> | |
<server description="new server"> | |
<!-- Enable features --> | |
<featureManager> | |
<feature>jsp-2.2</feature> | |
<feature>localConnector-1.0</feature> | |
</featureManager> | |
<applicationMonitor updateTrigger="mbean" /> | |
</server> | |
Go Run > Edit Configurations. Click the + sign and select WebSphere Server > Local. Hit Configure and enter the path to the WebSphere Liberty Next Profile e.g.
- /Users/planetjones/servers/wlp
On the Server tab set:
The Maven Archetype creates an index.jsp file in the root of the webapp. Hit the play icon to build and deploy your Web Application to Liberty:
Open your web browser and voila:
I got the whole thing started in just under 1 second - that's pretty good going. Updating the JSP file and switching to my web browser, means Intellj's frame deactivation kicks in and the updated JSP is copied to the exploded WAR. So the change is reflected without a restart. Now you can add a servlet e.g.
- http://localhost:9080/liberty_profile_test_war_exploded/
package co.uk.planetjones; | |
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 java.io.IOException; | |
import java.io.PrintWriter; | |
@WebServlet (name="TestServlet", urlPatterns="/test_servlet") | |
public class TestServlet extends HttpServlet { | |
@Override | |
protected void doGet(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) | |
throws ServletException, IOException { | |
httpServletResponse.setContentType("text/html"); | |
PrintWriter out= httpServletResponse.getWriter(); | |
out.write("Hello Servlet World!"); | |
} | |
} |
I'll play with JSF, CDI, EJB Lite, etc. and add these to another post.