Tuesday, November 13, 2012

Java in the Cloud

Disclaimer: I have seen and read about Heroku, but have not tried it!

I want to talk about Cloudbees. Cloudbees is a service that let's you deploy your Java webapp to the cloud fairly easy. What I found to be so nice about this service, was that you can download a SDK (from Cloudbees) and run your Java app from your local machine to verify that it works before deploying (this is done through a tomcat 6 container).
This is the way you deploy from the command line:

bees app:deploy   [appName].war   [accountname]/[appName]

Also, it is free if you can manage with a 128MB server and a 5MB MySQL database :)

From what I have learnt this far, you cannot run your app in a tomcat 7, which means you can not use the Servlet 3 API. So, you have to keep your web.xml file. It also means you cannot take advantage of the WebApplicationInitializer from Spring. You will need an applicationContext xml reference in your web.xml (for Spring's ContextLoaderListener). Also, you can not use Java 7. The version in use is Java 6, so there will be no diamond operator or try-with-resources!

For my test application I have used Spring 3.1, Struts 2 and Hibernate. In time of writing, I have not created any tables in my "cloudy" MySQL instance, but I have verified that the datasource and connection was successfully made by checking my "cloudy" log4j (e.g. both were eagerly instantiated and logged).

The datasource is set up with JNDI. When you create your database, cloudbees will give you the settings for how to configure it (the only thing you need which is not a J2EE standard is a cloudbees-web.xml). So if you do test-driven development, autowired the Spring beans in your tests (e.g. made you Spring context available) and configured your datasource through a bean which in turn accesses the javax.naming.InitialContext, you will run into issues. You will have to mock the InitialContext when you run your tests. This can be done fairly simple with the @BeforeClass annotation on a method in your test class, SimpleNamingContextBuilder from Spring, BasicDataSource from common-dbcp and something that looks similar to the code below:

    @BeforeClass
    public static void setupJndi() throws Exception {
        BasicDataSource dataSource = new BasicDataSource();
        dataSource.setUsername("****");
        dataSource.setPassword("****");
        dataSource.setUrl("jdbc:mysql://127.0.0.1:3306/[dbname]"); //needs to valid (real) 
        dataSource.setDriverClassName("com.mysql.jdbc.Driver");
        SimpleNamingContextBuilder.emptyActivatedContextBuilder(); // Spring-mock class
        Context context = new InitialContext();
        context.bind("java:comp/env/jdbc/lotterydb", dataSource); 
    }

Besides JNDI, the application is completely self-contained. This is quite appealing, considering you are then free to use almost whatever framework you'd like. I've read that with Heroku, you can get a MongoDB instance, but as far as I know this is not an option with the free service on cloudbees.

Also, this is my first Java-cloud app, and I've found the experience quite exciting!




Wednesday, January 18, 2012

IntelliJ IDEA, Maven and JRebel

After years of working with WSAD, Eclipse and JDeveloper I was finally provided with a license for IDEA.

After the trail period expired I was convinced that this was the tool of choice for any Java developer. Now that I am a proud owner of a license my Java work suddenly became more effective and pleasant.

The other tool, JRebel, which by no means is an unknown tool, the workflow has become simply amazing. Everything just works. No bugs (as of yet) and no hassle with the third party plugins.

By no means is this post any attempt to undermine the work done by all the fantastic talented developers of the other IDE's mentioned above. Just a simple statement of fact that the people at Jetbrains are a bunch of innovative people that have created a fantastic tool.

Needless to say, the Maven support is stunning. And I have not yet had time to explore all the other goodies that IntelliJ have to offer.

So for all you Java developers out there, download the latest trail and test i for 30 days and give it a go :)

Friday, December 31, 2010

Better Alternativ to ScrumWorks

As I am working freelance on a project for a Norwegian consulting company, I came across this great tool. I had initially installed ScrumWorks Basic. This was the tool in which we used in various projects in my previous job. It's a great tool, but, it requires a server installation and a scrumworks.jnlp on the clients to make a remote connection to the server.
 
For this project I am working on now, I started out using ScrumWorks again. But, after having played with this other tool for an hour or so, I was sold!

Pivotaltracker is an online tool for 
  • creating user-stories/-cases
  • feature/bug/chore/release -tags for categorizing a story
  • labels for creating custom 'tags' for describing the story (like, design, dev, reasearch etc)
  • the UI is incredibly easy and intuitive to use 
Check out these videos to get an idea of how it's functions:


Another good to tutorial:


A testament from one of it's user:


Give it a try in your team, and let me know if it meets you needs or if anything is lacking.

Happy new year :)

Wednesday, December 22, 2010

Kent Beck training Norwegian Developers in Norwegian Iterate

Old news  for some maybe, but still amazing!

The XP Guru provides assistance for the Norwegian developers in the company Iterate.

Any Java developer has at some time read or heard of this great man.

Friday, December 10, 2010

The next big DJ thing

Native instruments new integrated console for traktor.
Video demo
This is gonna be a killer. And better yet, you can still connect your old Tecnhics 1210 if you wanna go old school… Great! Smile