Showing posts with label Wicket. Show all posts
Showing posts with label Wicket. Show all posts

Monday, July 23, 2012

Google DataStore with JPA and Spring

I like Google App Engine. It's fast, reliable and free. It also comes with Google DataStore, a NoSQL solution to store data. The only problem is that it isn't that easy to use with the technology you want. We, for instance, wanted to use JPA and Spring. We've been struggling for a little while, but in the end, we managed to get all the right libraries. To make our life easier, we poured all those libraries in a Maven POM file, and made an archetype out of it. That way, we can just generate a new project from that archetype, and we're good to go!

Follow these steps to get started (You need Maven 3 to sucessfully run the app!)
mvn archetype:generate -DarchetypeGroupId=be.c4j -DarchetypeArtifactId=gae-wicket-archetype -DarchetypeVersion=1.0 -DgroupId=be.c4j -DartifactId=gaeproject -DinteractiveMode=false
  • The parts in bold are what defines your projectname and default package
  • On the newly created project, do a mvn gae:unpack 
  • Now you can mvn gae:run your application
  • It's just a simple Wicket Hello World app, but it's a base to start from
This setup was made to prepare our Summer of Technology session. A lot of thanks go to Sebastian Van Sande for sorting out dependency issues and creating the archetype.






Thursday, May 10, 2012

Summer of Technology @Contribute

It's that time of the year again! Summer is coming, and with summer comes Contribute's Summer of Technology.

During the months of July, August and September, Contribute organizes 12 free workshops. I am proud to announce that I'll be co-presenting one of them. It will be about building a Wicket application on Google App Engine. Click here for more details! Of course, there's much more than just my session, an a lot more topics than web application development will be covered.

Choose the session(s) that interest you, and subscribe. If you're having troubles viewing the website or registering yourself for one of the events, contact info@contribute.be.

Hope to see you on one of the sessions!

Friday, March 23, 2012

The Cloudbees cloud solution

A few weeks ago, I blogged about getting your app online with Google App Engine. While this is a very easy process, it is far from the only cloud solution available. I have tried another one, Cloudbees, and will tell you about my experience now.

Cloudbees offers more then just a deployment platform. It has Repositories, Continuous Itegration and an Application Server for you to play around with. It also offers database services, and has plugins for numerous other things (like Sonar, Sauce Labs and many others). For this next example, I used SVN as repository, Jenkins as CI and Tomcat as app server.

Signing up

Signing up for Cloudbees is easy. Fill in your name and e-mailaddress, and create an account. That's it! Now that your account has been created, you can select which services to use. There are both free and paying options. To get started, I added the following:
  • Repository
  • Jenkins
  • Applications
I chose the free version of each. The idea was to simulate a real world working environment. I know there are a SDK and plugins available to build and deploy from within Eclipse/STS, but I wanted to have a continuous integration build my SVN repository whenever I checked in changes.

Configuration

First, I created a new code repository (in the Repositories service). I named it 'blogtryouts'.

Then I created a new application, naming it, again, Blogtryouts.


You now can configure the application server, which is in fact a Tomcat instance. You can define JDBC-connections, or upload a WAR file to be deployed.

Continuous integration

But we don't just want to upload a WAR file. We want our newly created SVN repository to be checked out, the project to be built and the resulting WAR-file to be automatically deployed. Therefore, we'll create a Jenkins service in Cloudbees. I created a DEV@Cloud free instance.

The Jenkins instance is immediately available. I added a new job ('Blogtryouts', who'd have guessed?), and made it a Maven 2/3 project. Once created, we can start configuring our Jenkins build!

Checkout, build, deploy

The configuration is pretty easy as well. The first thing we want Jenkins to do, is checkout our SVN repository. Under Manage sourcecode, you can select Subversion and then specify a URL. That URL is the one Cloudbees gave you when you created your repository. You can find it by going to Services -> Repositories and selecting your repository.

Since we told Jenkins it's a Maven project, it'll automatically try to build the pom.xml. You can add parameters and specify when it should be built. Under Building Activators check Build when a change is pushed to CloudBees Forge. This will start a build when someone commits code to SVN.

Last but not least ,we want to deploy the built artifact. Therefore, check Deploy to CloudBees under Actions after build. You can now specify the site and application ID to deploy to. The site is normally your username, application ID is the name you gave your application, prefixed with yoursite/. Cloudbees helps a lot by providing a dropdown with sites, and by telling you an application ID can't be found. They can even tell you which application IDs are valid.

If you now click 'build now', There will be a warning that your account hasn't been validated. This is an extra step required. Just click the link and enter your phone number (make sure you're near the phone with that number!). Seconds later, you'll receive a phone call with a computer voice telling you a PIN code. Enter the pin code, and you're good to go.

The webapp

So, now that our cloud is fully setup, we of course need a webapp to deploy. For demonstration purposes, we'll just use a general Maven archetype. As in some of my prvious blogposts, we'll create a Wicket project. We can do this quickly by executing this Maven command:

mvn archetype:generate -DarchetypeGroupId=org.apache.wicket -DarchetypeArtifactId=wicket-archetype-quickstart -DarchetypeVersion=1.5.5 -DgroupId=com.mycompany -DartifactId=myproject -DarchetypeRepository=https://repository.apache.org/ -DinteractiveMode=false

The magic

Now that our application has been created, we just have to import it into our SVN repository. I used TortoiseSVN to do an Import to my Cloudbees repository. It doesn't matter how you do it, but once the import's been done, you can watch the magic happen.

Jenkins will notice a new commit and will start a new build. When that's done, it'll deploy the generated WAR-file. When you now go to Services -> Applications, and click your application, you'll notice a new deploy has been done, with a Jenkins build message. This means your app is up and running! The URL is found on top of this page as well. Mine is available here.

Tuesday, March 20, 2012

Wicket 1.5 in Google App Engine

In a previous post, I explained how to quickly setup a Wicket application using Maven and Google App Engine. As you may have noticed, the default version of Wicket that is used, is 1.4. If you want to use Wicket 1.5, you have to replace Wicket dependence in your pom.xml.

This is what is there by default:

  <dependency>
      <groupId>org.apache.wicket</groupId>
      <artifactId>wicket</artifactId>
      <version>1.4.10</version>
    </dependency>


We'll replace it with:

  <dependency>
      <groupId>org.wicketstuff</groupId>
      <artifactId>wicketstuff-gae-initializer</artifactId>
      <version>1.5.5</version>
    </dependency>
>

Saturday, March 3, 2012

Get your app online in 10 minutes with Google App Engine!

In this post I'll explain how to easily get an app online and running in under 10 minutes. There are a few thing we need before we can start, though:
The Google App Engine SDK can easily be installed from within STS itself.

So, once we have all these prerequisited, we can get started! First thing you have to do is tell Google you want to deploy a new application. To do this, go to the Google App Engine start page, and create an application.

I named my app blogtryouts.

Now we are ready to actually build an application. Springsource Toolsuite comes with Maven preconfigured, so we might as well use Maven and its rich collection of archetypes to get going. So, in STS, create a new Maven project (File -> New -> Other..., and then select Maven project)

A wizard starts to help you create a new Maven project. Make sure you leave the Create a simple project (skip archetype selection) UNCHECKED! We're going to select a Maven archetype to get started really fast. More information about Maven Archetypes can be found here. When you click next, you can select the maven archetype you want to use. Filter on gae, and select the archetype using the framework you desire. I chose Wicket, cause I like the way it works (and how you can have a web designer do the tedious HTML/CSS styling while you can focus on the real Java development). To use wicket, select gae-archetype-wicket.

Click Next. Now comes the screen where you enter your application information. Enter data concerning to your application in Group IdArtifact Id and package. In the gaeApplicationName field, you enter the name of the application you created on appengine.google.com. In our case, this was blogtryouts.

Also notice the gaeApplicationVersion field. It defaults to test. We'll change it to release, to deploy a release version of our app. Click Finish. Maven will now create an archetype!

Now, there are still some issues before you can deploy your application. You have to put the Google App Engine SDK to your buildpath. I have no idea why this isn't done by default, but it isn't, so we'll have to do it ourselves. Easiest way is by right clicking your project, and select Google -> App Engine Settings... Basically, you can just hit Ok, to accept all default values.

Now that the SDK has been added, there still is 1 problem to be addressed. I think it's a bug in either STS or the Maven Archetype, but the appengine-local-runtime artifact seems to be missing. You can just go to the pom, and delete the entry.

<dependency>
  <groupId>com.google.appengine</groupId>
  <artifactId>appengine-local-runtime</artifactId>
  <version>${gae.version}</version>
  <scope>test</scope>
</dependency>


Now, build the project by using the maven package command. The necessary files and folders will be created, and your application is ready to be deployed! When Maven has finished packaging, right click your application in STS, select Google -> Deploy to App Engine... and deployment will start. When it's finished, your application is available at yourAppname.appspot.com.

If you used test instead of release in the gaeApplicationVersion I mentioned earlier, it would deploy to test.yourAppname.appspot.com.

Good luck and have fun!