Apache Wicket [In Action]: A Review and How It Relates to the Java World

Java is a great tool for creating software. It is well designed, modular, has a wide array of platforms that it can run on, performs well, it’s very extendable, and it has a large community with lots of support. However, it’s support for websites and related services is severely lacking. It’s bad enough that frameworks that extend the existing infrastructure have massive pitfalls that you later discover.

For the most part Apache Wicket solves many of the web related issues that J2EE (JSP) has. If you are to follow the prescribed way of doing things, it can actually be quite pleasant. However, there are a few thorny patches with Wicket. I will get to those later.

Wicket In Action like a marriage. During the honeymoon, everything is great. Everyone is happy, and then later discontent grows and things go up and down. However, unlike a marriage, you don’t really get an ending. This is a rather good way to end things, but some of the lesser parts of the book were rather disappointing. One of the big selling points of Wicket is that it is a framework that assumes that the developer has already prototyped the pages in HTML prior to starting with Wicket [The pages are adapted into Wicket-ized and previewable pages]. This upside was enough to ignore the placement of the HTML files, in the class path rather than the web resources section.

I jumped into this book with lots of enthusiasm after reading the introduction. I even bore through some of the non-stated setup issues in the book. The book starts off by creating a project, from scratch, however I went the Maven route (which I discovered is the better way to go). The book mentions maven, but it doesn’t mention how to build your application or to generate a project. I believe that I went the correct way because Maven helped to setup all of the application servers and the folder structures. The book started by having the user to jump in, examine a few code segments, and then to start on a sample (full featured) e-commerces application. The store was oddly pleasant; the goal was to sell cheeses online. The application started from a few sample view pages, it went on to creating a reusable shopping cart, and finally on to a membership mechanism. This is a very straightforward and to-the point way of starting a new framework. It’s already addressing the needs of the majority of its audience.

Another nice thing to point out about the introduction is that it did not try to cover all of the material at once. It would frequently describe what you were doing, but would mention the chapter where the concepts were explained in depth later on. Something that pleased me was that the code listings did not include a listing number. They were place in the correct location of the text. After you’re done with the sample application, you should be quite proud of yourself. This is similar to your first website.

However, the book got a little disappointing when describing the more detailed interworkings of Wicket: sessions, bookmarkable pages, and layering/rendering. The book improves when it gets to the Ajax functionality and a brief mention of dependency injection and Wicket. The book gets a little rough in the Spring through Hibernate sections and then better in the testing section. The book ends in a rather low note on SEO, production configuration, and JMX. If I had known more about JMX, I would have probably had a better opinion of the ending.

Overall I am not sure if I can say that the less than stellar sections of the book were entirely the authors’ or the book’s fault. It quite possibly may be the technology’s fault.  I would strongly recommend the book if you are new to Wicket.

Lastly, here are some direct tips that I had to discover on my own that helped out a lot:

 

Two Issues I have With IntelliJ: Inconsistent building, and GUIs

During the massive end-of-days sale, I bought a copy of IntelliJ. I have been primarily a NetBeans developer, but I have used IntelliJ at a previous job. So two of the things that irritated me have been: the inconsistent build support and IntelliJ’s handling of Java GUIs.

IntelliJ has its own internal build system. However, it also has support for Maven. When you have a Maven project, it adds in dependencies to the Maven file, but continues to build with its internal build manager. If you need to add a dependency, IntelliJ will automatically add the dependency in the POM file, but you have to manually add it in its own build manager. Given this inconsistency, it is possible to have two different build configurations within the same project.

Additionally, converting a project from a Netbeans based project with a GUI doesn’t work in IntelliJ. IntelliJ will not interpret the Swing code generated by Netbeans. This means that for anything GUI related, I will have to use Netbeans.

What would be nice?

Support a non-proprietary build system. NetBeans defaults to ANT, and can support Maven natively. If this is not an option, then write an adapter for Maven/ANT/Gradle.

GUI: Reuse the Mattese code. Make Mattise a plugin and write an adaptor for IntelliJ.

New Repository ogg2mp3

Ogg2mp3 is a new script that I adapted from a flac2mp3 script I found elsewhere online. The script allows for you to convert an entire directory of ogg files into their similar MP3 version. This helps those who have MP3 device and players, which do not include support for OGG files. Anyways, I put the script on my GitHub account, and I’m willing to accept pull requests if they improve the script.

Repository: https://github.com/monksy/ogg2mp3

To use this script give the script execute privileges, navigate to the folder which contains the OGG files that you want to convert and run the script. The script will traverse the current directory, and all of the sub –directories within. From there it will convert the OGG file into a MP3 file with the same filename and metadata.

In Support Of Maven

In the last few days there has been an article completely bashing Maven on hacker news. I found this a little aggravating. Much of the article spent time complaining about how the files are structured, and how much effort it takes to maintain a Maven file. Also, the article complained about the plug-in structure.

To some extent I can agree with the original author. The plug-in system makes Maven a little difficult to learn and get completely right. On the other hand, the plug-in system makes it easy to deliver a single meta-build system that can easily adapt to what you need it to do. Building a Java web app? It has a plug-in to build and package it for you.

My main beef with the article is that it completely ignores why we got Maven in the first place. It builds, packages, and manages your dependencies better than ANT does. Before, you had to manually acquire, and grab your dependencies. If you had ANT or make, then you had to include the declarations for the dependencies in the build file, and put the dependency in your project. This is a pain for those that are using source control, and for setting up new developer machines. However, with Maven, just declare the dependency and the scope in the build file and you’re done. If you’re using an IDE it’ll bring in the references and may be able to pull the Javadoc if it’s available. Additionally, any new upgrades to the dependencies could be added just by changing the version number. Imagine doing that without a Maven like build system. Maven can even go the extra mile and create a redistributable package [this is a little tricky, but you can do it], deploy your new package to a repository, check in your code for you, or even deploy it to a webserver. For example, if you have a web service and don’t have Tomcat7 downloaded, run it with an embedded instance with mvn tomcat7:run . You’re done, Maven grabs Tomcat7, its dependences and tries to deploy your webapp to the new instance of Tomcat7. No installation of the server required.

In closing, Maven is a build tool. Unless you’re making project structure changes you shouldn’t be messing about with the way it builds things.

Links I’ve Found Interesting in the Last Week/Technical Things I’ve found Interesting (6 January 2013)

  • Getting the “Application Server Libraries not found” error with IntelliJ when you try to add a local Tomcat server? If you’re using Gentoo it’s a matter of file locations. Install the tomcat-api package, and make a symbolic link from the API within the Common and Shared Tomcat directories. Source.
  • Tomcat 7 has changed around how resources can be accessed. You can no longer use “getResourceAsStream” to get files placed in the Web-inf/Classes folder. Instead, you should attempt to get the resource through the context of the local thread. An example: Thread.currentThread().getContextClassLoader().getResourceAsStream(). This is useful for applications that use JasperReports [location of the JRXML file], and that are web applications. Source.
  •  If you are trying to stand up a web server, and don’t want to allow it to accept public connections? Set the accepted connections on tomcat to only listen on the local address. For tomcat see this. For NGinx see and set it only set listen to 127.0.0.1:[port].
  • Converting a GUI Netbeans project into a Maven based project? Most of the needed libraries will be covered by the default Maven repositories. However the swing-layout dependency is a special case. To use include the Netbeans repository reference, and include the swing-layout-1.0,4 dependency.
    Repository:

    <repositories> 
       <repository>
          <id>netbeans</id>
          <name>NetBeans</name>
          <url>http://bits.netbeans.org/maven2/</url>
       </repository>
    </repositories>

    Dependency:

    <dependency>
       <groupId>org.netbeans.external</groupId>
       <artifactId>swing-layout-1.0.4</artifactId>
       <version>RELEASE691</version>
    </dependency>
  • Ignoring failed tests on a maven build: Add this parameter to your mvn command: -Dmaven.test.skip=true
  • Sort directories and files with a human readable format: This is like ls –Sh, but it traverses directories.
  • If you have a set of directories to ignore, SVN propset includes an option to recursively ignore specified names/folders. A word of warning propset overwrites any svn:ignore properties.

Things I would like to Learn/Experience/Improve-Upon This Year [2013]

Since this is the time of the year that many making resolutions relating to self improvement, here are a few of mine:

  1. Finally get around to learning GridGain.   [I would love to see a well published book, or at least a Kindle eBook to get some headway on this] HazelCast would also be interesting, but GridGain has more of what I’m looking for.
  2. Finish the massive tomb that is “Groovy In Action”
  3. Finally understand how network routing works.
  4. Get more experience with DNS, and DNS tools
  5. Master NMap [not just learn the basic uses of it, but to really excel with the tool] This would be similar with the reading up on SSH I did last year.
  6. Get up to conversational level German. [Living outside of German speaking nations makes this incredibly difficult]
  7. Finally develop some strong time management habits.
  8. Learn how to use Python [to the point where you can do some cool stuff with it]
  9. Learn R [rather than haphazardly hack]
  10. Meet/talk with some of the gurus of airfare scheduling/decoding, and the famous Tom Stuker.
  11. Learn how to use GraphViz [This is one of the odd ones here, but it’s interesting]
  12. Get better with Erlang and to find/make real world uses.
  13. Learn/Create a GUI in Apache Pivot, and a web interface with either Stripes and/or Wicket.

How am I planning to accomplish these things? Having goals, and putting them on my task list.

Currently, I am reading up on Maven, and Groovy. I read a book on GIT, and got some practice w. A review of the strengths and weaknesses may be coming up in a later post on this blog.

To the 1.5 readers left reading this blog: What are your goals for the New Year? Leave the response as a blog post linking back to this post or in the comments below.

Massive IntelliJ Sale

Usually I’m not the type to advertise on going sales, especially when it is a ‘limited-time’ type sale. However, IntelliJ is having a 75% off sale. They’re offering the IntelliJ IDE for $50 for a personal license. This is incredible, considering that the IDE is similar to Netbeans and it includes features that were stripped out of Netbeans in previous versions. The sale lasts until 5AM 21 December [Eastern Standard Time].

Really Cool Things I’ve Learned This Week (R, Random Numbers, Java, Hypervisiors, and fan maintenance)

Within the last week I’ve learned a few interesting and strange things:

  • Given the right connectors, R and PostgreSQL can work with each other to produce graphs, and use each other’s functions. I believe that the strongest use forthesetoolsare: to create windowing functions that aren’t already provided in PostgreSQL and to generate charts directly from the database.
    • R can operate within PostgreSQL with the Pl/R module. This means that you can create a graph from an SQL query. In addition, with Pl/R, you can make R functions callable from SQL. For an example on getting Pl/R to work, and generate a graph see this. One example, is that R can provide an aggregate function, that PostGreSQL does not contain: median. Warning: At this time, PostgreSQL 9.1 is the most recent supported DB for Pl/R.
    • R can work with PostgreSQL with the RPostGresSQL driver. This is pretty cool, as that the data it brings in is an ordinary data frame, in-which you can perform any R related function as if it came from any other source. Instructions can be found on it’s project page.
    • This may sound crazy, but the lack of random numbers on Linux may cause WebLogic to double the time needed to start. My own personal test has confirmed this to be the case. This is typically an issue with Linux, /dev/random’s behavior, and WebLogic’s usage of SecureRandom [Java].  Under Linux, SecureRandom uses /dev/random for its default source of random numbers. However, under Linux /dev/random blocks until it can get the next random number, and the numbers are based on activity from system drivers.  Within a VM, the performance of /dev/random is exacerbated by a lack of driver noise. As of the time of writing, the only hypervisor to provide a driver to assist in this issue is KVM; VMware and Xen do not provide a driver. The solutions provided by Go-Integral are: redirect /dev/random to urandom(not advisable), use a hardware key, use a broker, or use the hypervisor driver (if it exists).
      • TL;DR: Using VMs and plan on generating lots of random numbers for SSL and/or crypto? Use a hardware key, entropy broker, or a hypervisor driver if you’re using KVM.
    • Recently, a lower powered box that I own refused to operate. This was due to a fan underperforming, and would let the box get too hot, to the point that the BIOS just halted the machine from running. Instead of replacing a functional fan, I found out that a little machine oil [for sewing machines] can actually fix the issue. Oiling the fan should be in every computer user’s periodic maintenance schedule along with backing up their data, and cleaning out the dust. Due to fan size this is incredibly important on laptops and GPUs.
    • If you need numbering for groups within a PostgreSQL query, you should use the rank function. It is a Windowing function, that will give you the number for that particular group, based on a criteria. See the documentation yourself for a better explanation. 

Part 1 of 2: How To Make Your Life Easier As A Tech Worker (IT/Software Engineering/System Administrator): Automation

After some time of being a student, and a tech worker [Software Engineer, IT Consultant, or  System Administrator], you should start to find ways to make your job easier.  These are some of the things I found helpful:

  • Create templates for daily status emails. If your employer/ client requires a daily status, this makes the task of writing up the daily status easier. Outlook has the ability to keep track of email templates.
    • If the daily status is being sent to multiple people it may be helpful to create a distribution list. A distribution list is less likely to lose contacts between statuses.
    • One template a coworker of mine uses is this template.
  • Create filters for emails. This can help reduce the amount of email that requires attention. For example if a group communicates with a shared distribution list then create a rule or a filter that can organize that into a separate folder. This can also clear out “Build succeeded” emails [if your company automatically subscribes you to those]
    How To Create Rules In Outlook.
    How to Create GMail Filters.
  • Use SSH keys: SSH Keys can save a little bit of time by creating password-less logins. Also with SSH keys, scripts are able to run commands on other SSH enabled boxes. This means that much of the repetitive system administrative tasks can be automated. Gentoo Guide to SSH [This include generic non-gentoo instructions.
  • SSH Commands: SSH Commands are shell-less sessions in which a user logs into a SSH box with a key to kick off only one specific command. For example, say you had to reset an environment, and it required quite a few commands. With an SSH command, you would combine all of those commands and then kick off the command as an SSH command with its own key. From there on, you could kick off those commands by connecting to the SSH box with the key.  More information.
  • Backups- It can’t hurt to backup your data. I’ve never found a single person that was reliable at doing this frequently. Setting up rsync, SSH-keys and making it a cron job is a good first step. I’ve heard good things about luckyBackup, but I haven’t had a chance to try it. 
  • Using Salt/Puppet to automate system administrative tasks on multiple machines. This would be a bit more helpful for those who regularly roll out new software to multiple machines, or need to perform other system admin tasks.
  • IfThisThenThat (Review) is an online service that connects other online services to perform the intended result. For example, if a Google search reveals specific keywords, you can have that update a twitter account.

New Equipment and Switching Workstations

Recently I got a sweet new laptop. After being stuck with laptops with cheap builds and parts, this is a welcomed new addition. When converting my previous workstation over to the new one, a few things came about some bad, and mostly good. The awesome bit about the new machine is going from a core duo to a Core i7 processor. My primary operating system has been Gentoo, so installing a new operating system requires a manual install, configuring a new kernel, and building all of the needed secondary applications.

Let’s start off with the annoyances:

  • Since both machines are Gentoo sharing the USE flags from Make.conf, and adjusting the new one to the new hardware included an outdated keyword or two. It turns out that Xvmc is outdated and by using an Nvidia card, one should use VDPAU. This was fixed by eliminating all mentions of Xvmc keywords.
  • IceTea Java requires printing [Cups], which CUPS require Java. This circular dependency was quite annoying. At the moment, I cannot recall how this was fixed. However, I believe it was fixed by forcing Portage to pick Oracle’s version of Java rather than IceTea. [I’m not sure how to set the preference prior to installing; I had to force/nodeps this one].
  • CrossOver Professional [at least the 10.3 version] requires the use of Python 2. If you have a new install, then Python 3 will be in place. To fix this: you’ll need to fix the Python 2 references in the installation directory. I found this guide to be helpful, although, it was a bit difficult to find. If the guide has been deleted, this is a copy from the site:
    $ cd ~/cxgames/bin
    $ sed -i -e "s|#![ ]*/usr/bin/python$|#!/usr/bin/python2|" *
    $ sed -i -e "s|#![ ]*/usr/bin/env python$|#!/usr/bin/env python2|" *
    
    $ cd ~/cxgames/lib/python
    $ sed -i -e "s|#![ ]*/usr/bin/python$|#!/usr/bin/python2|" *.py
    $ sed -i -e "s|#![ ]*/usr/bin/env python$|#!/usr/bin/env python2|" *.py
  • CrossOver Pro, despite having a 64bit version, requires multilib support. [Which was included, but for those who wish to be 64bit purist may find a little too late]. The kernel must include IA32 Emulation support [from the Executable file formats / Emulations section]. The CrossOver Pro documentation claims you should have ia32-libs installed. In Gentoo this is the equivalent to the app-emulation/emul-linux-x86-* libraries.
  • Nvidia Optimia – There is no fix for my laptop. It’s frustrating. Although, the Intel video card does quite well. I’ve tried to install bumblebee, but the configuration isn’t currently supported.

Some nice changes in the Linux environment/Gentoo:

  • The added features to the Linux kernel. It looks like better SSD Support has been added, awesome!
  • NetworkManager/NetworkManagement. I’ve struggled with a lack of dynamic network support a while. This should be included in the KDE meta-ebuild. Although, from my understanding, there is quite a bit of approval/support for WCID. NetworkManager has great desktop support clients, if the user unplugs an Ethernet cable; it tries to switch to WIFI.
  • If you have CrossOver Pro, and use the Bottle functionality. You can create mutually exclusive containers for applications. You can also export these bottles as archives and import them later. This is amazing! To bring over your copy of MS Office, you don’t have to deal with the trouble of recreating the environment, or reinstalling the dependencies.
  • LSOF- This can help you find what process is listening to which port. That can be helpful when tracing down rogue/bad installs of server components. Looking for the process that is responsible for port 90? Use the command lsof –i :90.
  • Adding SSH keys for passwordless logins. Prior to using this command, I always setup this functionality manually. Then I heard about ssh-copy-id. This command takes your default key [or one specified by an argument] and copies it to the right place at the target. The downside to this command is that it depends on quite a few defaults. [I.e. Default port of 22, default users, port following, and default keys] This is an annoyance that has a bit of good in it. Having a non-default SSH setup will require you to alias and setup a personal SSH config.