Monday, March 26, 2012

Fixing Twitter Bootstrap and Eclipse Javascript Errors

I've been meaning to play with Twitter Bootstrap and some of it's other associated projects like Font Awesome lately and decided to see if I could integrate into a sample application I'm building.  I'm using an SpringSource Tool Suite 2.9.1 which is based on Eclipse 3.7.2.  When using a Dynamic Web project type and bringing in the assets directory from the Bootstrap download into my WebContent directory, I kept getting JavaScript errors, lots of them.

I realized that it was simply complaining about a single prettify minimized js file that went away if I got the unminimized version.  But I'm stubborn so I refused to let Eclipse win with this work-around...

At first I thought it was related to the Validator or a Builder.  But then I noticed that there was a JavaScript reference to a runtime and I checked the Facets.  Sure enough there is a JavaScript facet that you can unlock and then uncheck.

Since I am not using that capability now, removing that Facet seemed to do the trick once I applied and executed a Project -> Clean, but at least on one occasion I actually had to rename/replace the javascript file that was causing problems to be marked as directed to in this Stack Overflow thread.  Once that was out of the way I now had a nice Bootstrap example ready to customize.  I simply copied one of the html files like starter-template.html or hero.html over from the Bootstrap examples directory and fixed the asset references with a replace-all.  If you have a better approach to get Bootstrap and Eclipse to play nicely, I'd love to hear about it.

Sunday, March 25, 2012

Mirco Cloud Foundry - Set the Local Timezone

Would you like your Mirco Cloud Foundry to use a local timezone instead of UTC? Hopefully this propagates to the default timestamp display of whatever programming language you are using.  I wanted this for a Java application I've been playing around with.  Here are the simple steps I used.

1) Log in to Micro Cloud Foundry using the IP Address displayed on the console as root using the password you supplied when setting up MCF.
ssh [email protected]
2) Run the dpkg-reconfigure command to select your timezone
[email protected]:~# dpkg-reconfigure tzdata
You should get an ASCII-GUI that let's you select the timezone.

When finished you should see output like this:
Current default time zone: 'America/Los_Angeles'
Local time is now:      Sun Mar 25 13:01:18 PDT 2012.
Universal Time is now:  Sun Mar 25 20:01:18 UTC 2012. 
[email protected]:~# date
Sun Mar 25 13:01:30 PDT 2012
3) Restart your applications.

Once I restarted the Java application, this time it picked up the local timezone as the default
output for a
instead of the UTC timezone.

Friday, March 23, 2012

Arun Gupta Java EE 6 and Spring Response

Disclaimer - I am a VMware employee and former WebLogic Server Product Manager at Oracle.  I know Arun personally and he is my friend.  The views expressed below are mine own and do not necessarily represent the views of my employer.  I tried to post this comment on Arun's blog but it was marked as spam.


I'm really surprised to see you trolling Spring like this.  I realize that in your job as a Java EE evangelist that you want to advocate for products and frameworks that you are paid to advocate for, but I don't see the point in misrepresenting many of the attributes that people like about the Spring Framework.  I find it hard to believe that you actually believe your blog is a balanced and objective analysis.  I must say that I never hear the question why should I use Java EE 6 versus Spring and I think it's mostly a contrived question.  Evans Data surveys indicate that about 2/3 of Java developers are using or will use Spring  I guess if you're paid to travel around the world telling people not to use the most popular Java framework that you need to come up with reasons.  From what I can tell the people screaming the hardest not to use Spring are mostly authors employed by vendors that have a strong interest to lock-in their customers to full Java EE server instead of a framework that lets them (but not requires them!) to run on a Servlet or Java SE container.  In your publications list I see authors employed by vendors selling JBoss, Resin, WebSphere, Glassfish and WebLogic Server.  There have been lots of people that have a different point of view on this topic.  What I really don't understand as why someone promoting the Java ecosystem as their primary job wants to so obviously dissuade users from making up their own minds with an objective analysis of trade-offs, especially when it does not have to be a mutually exclusive choice and Spring is part of the Java community.  You know that many other people (in fact the vast majority of Java developers) do not share your view, yet you do not provide a single link to present an alternative perspective.  Are Spring advocates not part of the Java community in your view?

I find it very strange that you try and attach a "l"-word attribute to Spring when the major app server vendors have not even been shipping full Java EE 6 releases until so recently that almost no customers have the latest versions of WebLogic, WebSphere or JBoss installed.  Java EE 6 came out in December of 2009 which is 2+ years old, WebLogic Server 12c only started supporting a Java EE 6 compliant server 3 months ago!  WebSphere 8.0 was summer 2011 and JBoss EAP 6 is not even yet generally available.  You are advocating to use a framework with implementations that are so new that almost no customers of the major application servers have a compliant server in production.  Java EE 6 is not even available in the Oracle Public Cloud yet, so if Oracle can't even upgrade their containers that fast how can you expect all the customers to be up-to-date?  Spring 3.1, which had a lot of features for a minor release, started shipping in the Fall of 2011, almost 2 years after Java EE 6.  Plus as you probably are aware, it supports Java SE 5 and above, so customers are not required to be on the bleeding edge to use it.

You had some trouble finding a tutorial, and I am happy to help you with that since that should be very easy.  First go to and you should click the big button that says "Get Started".  The next page has the links for both tutorials and sample code.  The tutorials page has both video and written tutorials.  If you want to create an MVC style application, there is one called "Green Beans: Getting Started With Spring MVC" by Colin Sampaleanu.  Someone helpfully published a maven archetype in the comments and with only two maven commands you can run the sample with Apache Tomcat, no separate application server installation is required!  If you also wanted to use persistence, you could consider a video like Spring Data JPA by Oliver Gierke

The listing of jar files in the application is not complete if you don't list all the jar files inside Glassfish or WebLogic Server that implement Java EE 6.  The comparable Apache Tomcat list of jars is obviously much smaller.  You know that an application is a container + framework code + application code and you should represent the entire accurate picture.

As for jpetstore, that's not really an updated Spring example as you can see by the Spring version being only a SNAPSHOT before 3.0.0 was released.  It should probably be removed from the list of samples.  The error you saw in maven is from an issue with a JBoss repository.  When I removed the JBoss repository at the bottom of the pom.xml file and updated the Spring version from a SNAPSHOT to RELEASE then my maven build worked fine.  If you want to use a sample that is often highlighted by Spring advocates, then you could look at Spring Travel, but it is only based on Spring 3.0 and not yet taking advantage of all of the Spring 3.1 capabilities.

Your comparison tables are also Apples and Oranges.  You can simply put Tomcat or Jetty in that comparison table and tc Server Standard edition is under 15MB  If you include tc Server, then you should use the Standard Edition recommended for production at 15MB as the Developer Edition includes Spring Insight, which would require including JRockit and JRockit Mission Control in the Java EE 6 column.  I suppose it doesn't help your case to point out that the production version of WebLogic Server 12c has a 1 Gigabyte generic zip installer and that the smaller developer versions are not suitable or supported in production.  I think you are also well aware of the fact that you could run Spring apps on embedded Tomcat 7 which is just a few megs.  I am simply amazed that you think tc Server is proprietary when it is based on Apache Tomcat, the reference implementation of the Servlet Specification, which is part of Java EE!  Why would you want to mislead people like that?  You know as well as I do that there are lots of WebLogic Server customers that are stuck using weblogic.ejb... packages in their code from previous versions of the specification.  The only thing even close to that might be Tomcat valves, but over 1/2 of all Java applications use Tomcat these days, which is free and open source, so it's not locking anyone in.

VMware provides commercial support for both Tomcat and Spring as open source products and customers are not left on their own to manage jars.  VMware also provides commercial products like tc Server, which is Apache Tomcat with some additional management and configuration capabilities and other open source derived products in the vFabric family that represent the way most modern applications are built.  VMware customers are free to use open source with or without commercial support or they can choose a commercial product derived from open source, the choice is theirs.

While Java EE 6 was finalized over 2 years ago, Spring has moved on to simplify and provide solutions to lots of other problem domains with Spring Data applied to NoSQL (MongoDB, GemFire, Riak, Redis, Neo4j) and Big Data (Hadoop)  Spring Social has already been available providing solutions to integrate with Twitter, Facebook, LinkedIn, TripIt and Github while JSR 357 is just getting started   Developers want solutions to these problems now, not when RedHat, Oracle and IBM get around to it.

People may not realize that you and I are friends and I'm happy to see you are passionate about your job, but I can't let you misrepresent the facts without setting the record straight.  I don't understand the Java EE vendor mentality that encourages deriding Spring when so many developers use it effectively and like it.  Go ahead and cheer for your team, but to misrepresent what you see as the other team's case is disingenuous.  I personally find it very deflating to the Java community as a whole when you, Bill Burke and others write trolling articles.  Hopefully only the vendors are paying attention in these artificial and made-up scuffles while productive developers are actually getting work done.


James Bayer