- 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.
Tag: tomcat
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”