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.

Lost the Passion for Software Development?

This is a list of potential tips to help a fellow Software Engineer recover passion in his or her work:

  1. Learn A New Language: Stuck with working solely in Java and C++ languages? Learn Erlang, or Lisp. Try out Scheme, Perl, Bash, Haskell, or D.
  2. Learn a New Framework: Some of the frameworks to learn: xUnit, Testing frameworks [other than JUnit], Spring.net, Apache Tapestry, XMPP, Esper (Complex Event Processing), OpenGL, JasperReports, OpenCV, Win32, OSGi, or even Hessian binary web services.
  3. Revive old projects by refactoring the code to use a new framework. Review code in open source projects.
  4. Attempt to become an expert in an open source project. You might become an authority on the subject, and write a book.
  5. Meet new developers. To do this, branch outside of your company and go to user groups related to the language. JUG for Java groups, LUG for Linux user groups, NUG for .NET user groups etc.
  6. Read and listen to lectures on InfoQ.
  7. Take a “Thirty Day Challenge” by coming up with a complex application and writing it in a completely unfamiliar framework or language. Something that would be rather unique, write a web application completely in Prolog or Erlang. I haven’t heard of anyone that has done that yet, but it would be rather interesting.
  8.  Annoyed with an application, language or framework? Fix it. If it’s open source, then write a fix for it and publically submit a patch. If it’s due to a closed source application, then rewrite the main interface [if it connects to a backend service], or rewrite the application completely.
  9. Have a business idea? The book “The Lean Startup” suggests that startup-interested developers should create a stripped down demo, to gauge market interest.
  10. Add new “favorite tags” to your StackOverflow account. Look for questions that contain lots of votes. Look for questions that have not been answered in a long time, research a solution and answer the question.
  11. Find ways to make your current job/task easier. If you are spending a lot of time writing the same type of unit tests over and over again, find a way to automate this, or write your own domain specific framework. Even better, write a Domain Specific Language for the current development project.
  12. Use coverage tools to find new places to test code that is currently untested.
  13. Read research papers. This is typically a very dull task, but there are some quality papers available. It takes some effort to find those papers, but the ones that are well written are worth ones effort.
  14. Hack: [I’m not responsible for unethical/illegal actions, I would suggest doing these things only for personal interest] Setup a VM to learn how to exploit system services, learn how to perform a privilege escalation, learn how to write a buffer overflow and run shell code, learn how an intrusion detection system works and attempt to exploit them, and attempt to crack legally obtained software.  [I advise that the reader do these things ethically (don’t share a software crack). The reader is responsible for his or her own actions. ]
  15. “Hack Hardware”- Write an application that interfaces with an Ardinio device. Root an Android or Apple phone.  You could also go the route that Linus Torvalds went, take data from existing devices and write an application that interprets the data. His project is SubSurface, its designed to take the data from a dive-computer, and to transform it into something the user can add notes to, and visually interpret the data. Write software for an embedded processor (FPGA, Basic/Java stamp).
  16. Learn how to make your own operating system. Take a Gentoo distribution, and reconfigure everything. Try out a real time Linux distribution.
  17. Look for project suggestions on Stackoverflow. There are quite a few questions from students asking about project ideas.  One popular suggestion is to write a plugin for a popular game. From my understanding, one can write a plugin for Civilization 4 by using Python.
  18. Find ways to make your job more fun, or easier. Identify tasks that are uninteresting or tedious and find a way to automate them. Learn how to configure and/or extend a build tool. Learn Ant, Maven, or Gradle.
  19. Take a vacation: Over-working one’s self is not an achievement, no one is impressed.

Lastly, (This really isn’t considered to be a tip) to help connect with others who have a similar interest to what you’re doing, write about your attempts, successes, or failures in a blog. Even if you decide that your current job is not fulfilling, then these are things that you can mention on your resume or future employers can see on your blog.

You’re a developer, as a developer you have the unique ability to create things. There is very little holding you back from developing something you want.

Have I missed some important tips? Have these tips help you? Are there any languages or frameworks that one should study? If so, leave them in the comments box.

Fixing Classpath Issues with JasperReports, J2EE, and Maven

If you are having issues with bundling JasperReports, a J2EE server, and Maven, you are not alone. There are many bumps in the road for getting JasperReports integrated with Tomcat/J2EE Container and building with Maven. Hopefully, this blog entry will make things slightly easier.

Firstly, there is the confusion of where the JasperReports dependency lies in the maven2 repository. There is a very suggestive entry for: {groupid: jasperreports, artifactid: jasperreports} however, that entry only hosts versions 0.5.0 to 3.5.3. The entry: {groupid: net.sf.jasperreports, artifactid: jasperreports} contains the versions 3.6 to the latest version. In addition, the last entry contains an artifactid of jasperreports-fonts, handy if special reporting fonts are requested from your reports.

Secondly, if you are getting ClassNotFoundException or NoClassDefFoundError for the class: net/sf/jasperreports/engine/JRException your issue with still with the POM configuration for JasperReports. The ClassNotFoundException is a runtime error, so despite a successful build, you will still see this. Despite the  jasperreports-x.x.x.jar file being in your web-inf folder, you may still see this error.

You must modify the scope of the component in the pom.xml. Change the scope from compile [which is needed to build], to “provided.” (http://maven.apache.org/pom.html#Dependencies) Provided not only uses the dependency to build, but update’s the container’s classpath to use this as a runtime dependency.

Continue reading “Fixing Classpath Issues with JasperReports, J2EE, and Maven”