Posts Tagged ‘java’
Monday, January 25th, 2010
If you have ever looked at the console or logs while starting a Tomcat instance on Windows you have probably seen the following line about APR.
INFO: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path
As long as the “tcnative-1.dll” is in the Windows PATH, generally you can place it in c:\windows\system32, but any other location in the PATH will work should you need it to be portable, or have different versions in use.
NOTE: Other Operating Systems use a similar approach as Windows to add an environmental variable, optionally you can also add the appropriate location to the “java.library.path” attribute used when calling the VM, if you are more technically inclined.
Cheers
Tags: apache, apr, dll, java, jni, native. library, performance, tomcat, win32, windows
Posted in Work | No Comments »
Monday, October 27th, 2008
If you do any development or even production testing with Apache Tomcat, you may have seen the following message in your logs.
“The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path”
Here’s a quick solution that will leave you with greatly improved performance.
- Go to the following URI’s:
- Download the appropriate version of tcnative-1.dll
- For Windows, place that file in c:\windows\system32\
- Restart your Tomcat server
- You are done!
Cheers
Tags: apache, dll, java, jsp, native, server, tomcat, windows
Posted in WebStandards, Work | No Comments »
Friday, May 30th, 2008
I’ve got my “Java Yellow Belt”
While this website does not give out official certifications, it’s a decent measure of individuals knowledge and provides a great way to test what you know (and may have forgotten over the years).
http://www.javablackbelt.com/
Cheers!
Tags: certification, java, testing
Posted in WebStandards, Work | No Comments »
Tuesday, April 22nd, 2008
Often you want to use Apache HTTP for static content, yet use Tomcat for JSP and other Java type work. This is a very common infrastructure for enterprise applications, particularly when using ‘pools’ of servers for performance, redundancy and security.
In order to accomplish this, all connections need to be handled by the Apache webserver, which will delegate appropriate requests to Tomcat for it to process.
Here’s a simple setup to get you started:
- First you need to get the connector appropriate to your installation:
http://tomcat.apache.org/connectors-doc/
- Next make sure the connector file is in the /conf folder of your Apache installation.
NOTE: I prefer to use this path and leave the version name to make maintenance and backups easier.
- Add the following line to httpd.conf
LoadModule jk_module conf/mod_jk-1.2.26-httpd-2.2.4.so
- Now, add the following to http.conf
<IfModule jk_module>
Include “c:/TOMCATPATH/conf/auto/mod_jk.conf”
JkWorkersFile conf/workers.properties
JkLogFile “c:/LOGSPATH/tomcat55_mod_jk.log”
</IfModule>
- Add the c:/APACHEPATH/conf/workers.properties file with the following (minimal) contents:
worker.list=ajp13
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
- Finally, restart both Apache and Tomcat
- The following file should have been created in c:/TOMCATPATH/conf/auto/mod_jk.conf
########## Auto generated on …some datetime… ##########
<IfModule !mod_jk.c>
LoadModule jk_module “C:/APACHEPATH/conf/mod_jk-1.2.26-httpd-2.2.4.so”
</IfModule>
JkWorkersFile “C:/TOMCATPATH/conf/jk/workers.properties”
JkLogFile “c:/LOGSPATH/mod_jk.log”
JkLogLevel emerg
<VirtualHost localhost>
ServerName localhost
JkMount /webdav ajp13
JkMount /webdav/* ajp13
JkMount /servlets-examples ajp13
JkMount /servlets-examples/* ajp13
JkMount /jsp-examples ajp13
JkMount /jsp-examples/* ajp13
JkMount /balancer ajp13
JkMount /balancer/* ajp13
JkMount /host-manager ajp13
JkMount /host-manager/* ajp13
JkMount /tomcat-docs ajp13
JkMount /tomcat-docs/* ajp13
JkMount /manager ajp13
JkMount /manager/* ajp13
</VirtualHost>
If all went well, you should be able to access your Tomcat server webapps on the regular HTTP port used by your Apache installation.
Cheers!
Tags: apache, configuration, connector, java, jsp, mod_jk, performance, server, servlet, tomcat
Posted in Work | No Comments »
Friday, April 11th, 2008
I’ve previously written on the benefits of static analysis of java code with the use of PMD and FindBugs. I was recently turned on to a new tool that performs similar testing of code within the Eclipse IDE.
When I first found this tool it was free, since that time it’s come out of beta and is now a little costly, but it may still be worth it due to the functionality it provides.
The premise of this tool is a little different than other ones, while it covers much of the same need, it also performs many tests that I would previously use CheckStyle to do. This only provides them at runtime and in a common manner within the IDE.
REFERENCES:
Cheers!
Tags: analysis, code, eclipse, ide, java, javadoc, performance, plugin, standards, static
Posted in WebStandards, Work | No Comments »
Thursday, February 21st, 2008
I typically use the open-source Eclipse IDE for most of my Java and PHP work. For my corporate work, this means that I use IBM’s packaged RAD and WSAD offerings that are based on various versions of the Eclipse framework.
When working on Internationalized (I18n) applications, most experienced Java architects rely on ResourceBundles to store the various text that is needed for different languages, problem is that editing these files becomes problematic, especially when dealing with multi-byte character sets as are often used in Unicode (non Latin-1, aka ISO-8859-1) languages.
The best editor I’ve found for this case is, as you may have guessed, free for download.
Here’s the links:
Cheers!
Tags: eclipse, free, i18n, java, l10n, rad, unicode, utf-8, wsad
Posted in WebStandards, Work | No Comments »
Monday, August 20th, 2007
I had an adventure tracking this one down lately, it seems that if your IDE saves files as UTF-8, the java compiler can’t always resolve the files.
Here’s the errors from the console output:
[INFO] ————————————————————————
[ERROR] BUILD FAILURE
[INFO] ————————————————————————
[INFO] Compilation failure
C:\Sandbox\Jars\example.jar\src\main\java\com\giantgeek\Example.java:[1,0] ‘class’ or ‘interface’ expected
C:\Sandbox\Jars\example.jar\src\main\java\com\giantgeek\Example.java:[1,1] illegal character: \187
C:\Sandbox\Jars\example.jar\src\main\java\com\giantgeek\Example.java:[1,2] illegal character: \191
Those character codes (\187 \191) may look a little familiar to some people, as they represent the Byte Order Mark (BOM) that prefixes a UTF-8 formatted file. If you look at them in a file editor (or text editor that doesn’t interpret UTF-8) they will look odd.
They look like “an i (two dots over), double right arrow, upside down question mark”.
Simple solution is to re-edit and save the file as ISO-8859-1.
An alternate approach that is available in some instances is to use the arguments to javac to allow the file encoding.
References:
Cheers!
Tags: compiler, java, unicode, utf-8
Posted in Work | No Comments »
Monday, May 14th, 2007
Occasionally, there comes a need to “look under the hood” of the code in a JAR file. While java is a compiled language, it isn’t quite machine code, but rather exists in a psuedo-code form to be used by the Java Virtual Machine’s JIT (Just in Time) compiler.
A lot can be learned from looking at other source code, unfortunately when using decompiled code you don’t get the original variable names or javadoc, but you can often better understand the API’s and performance issues in particular code.
I’m personally fond of DJ Decompiler, but I list several here for your use:
Cheers!
Tags: api, decompile, eclipse, free, java, reverse
Posted in Work | No Comments »
Thursday, May 3rd, 2007
In my “day job” I do lot’s of code reviews. I’m a big fan of Agile Programming and JUnits, recently I was introduced to the world of code coverage tools available (for free!) to Java developers.
IMHO, here’s the three front-runners.
Personally I prefer the Eclipse integration provided by ECLEMMA, but I agree that no one tool is ever ‘best’ for all scenarios.
Some background on this topic if you are interested in learning more:
Happy coding.
Tags: cobertura, coverage, eclipse, emma, java, junit, testing
Posted in Work | No Comments »
Friday, January 12th, 2007
I recently found out about ’static analysis’ of Java code. I’ve found two of these tools that are both free and easy to use. Both provide review of java bytecode and look for common development errors and inefficiencies…
FindBugs is based on the concept of bug patterns. A bug pattern is a code idiom that is often an error. Bug patterns arise for a variety of reasons:
- Difficult language features
- Misunderstood API methods
- Misunderstood invariants when code is modified during maintenance
- Garden variety mistakes: typos, use of the wrong boolean operator
PMD scans Java source code and looks for potential problems like:
- Possible bugs – empty try/catch/finally/switch statements
- Dead code – unused local variables, parameters and private methods
- Suboptimal code – wasteful String/StringBuffer usage
- Overcomplicated expressions – unnecessary if statements, for loops that could be while loops
- Duplicate code – copied/pasted code means copied/pasted bugs
Both integrate easily within Eclipse based (and other IDE’s) is typically done with the use of a simple plugin.
FindBugs can also run as a Java WebStart (JNLP) application, however a different UI is shown for JRE 1.4 vs. 1.5 and above (look out!).
More information:
While no tool can identify all problems, these will help you find some troublesome problems and give you areas to take a deeper look at.
Happy reviewing and fixing.
Tags: bug, code, eclipse, findbugs, ide, java, pmd
Posted in Work | No Comments »