Category Archives: Java

How to create and drop databases dynamically from Java/JSP code

JDBC drivers allow developers to perform DDL SQL commands in their Java/JSP code including CREATE and DROP of databases. In this example we present a simple JSP page that will allow you to test these functionality. In cPanel environment the … Continue reading

Posted in Databases, Java | Leave a comment

How to call Java executable from PHP?

For PHP to find Java and see related environment variables you need to set the variables explicitly in your PHP code or use Java related variables predefined in your .bashrc or similar shell resource file. As fastcgi subprocesses do not … Continue reading

Posted in Java, PHP/Perl/Python | Leave a comment

How to recover from java.lang.ClassNotFoundException: javax.faces.webapp.FacesServlet

If you build a JSF based application that works fine in your local development environment but fails to work after uploading to production server you may find the java.lang.ClassNotFoundException: javax.faces.webapp.FacesServlet error in your application server log. SEVERE: Error loading WebappClassLoader      … Continue reading

Posted in Java, Tomcat | Leave a comment

How to use your existing PEM/OpenSSL key and cerificate with Java keystore

Easy method for importing PEM key and certificates into Java keystore with JDK6+. In this tutorial we have x509 PEM OpenSSL certifcate used in Apache2 and related private key. Now we want to use them directly in Tomcat by importing … Continue reading

Posted in Java, Tomcat | Leave a comment

Hibernate and the famous ‘Communications link failure’ and ‘last packet sent successfuly’ issue solved with C3P0

With pure hibernate applications longer period of database inactivity can cause first database connection to fail. Subsequent web page refreshes will usually work fine. Why this happens? Usually, MySQL global parameter wait_timeout is set to 28800 (i.e. 8 hours). If … Continue reading

Posted in Java, JBoss, Tomcat | Leave a comment

Increasing Tomcat logging verbosity for quick problem resolution

Increasing logging verbosity of a Java application can be helpful in quick problem identification and resolution as error messages with default Tomcat logging settings can be quite vague. Default logger in Tomcat 6 and 7 is java.util.logging logger. Previously Log4J … Continue reading

Posted in Java, Tomcat | Leave a comment

Web application (WAR) deployment on shared hosting server

3 simple steps (prepare DB, update DB credentials, upload WAR) explained in detail to have your web application (WAR) deployed and made accessible on our shared hosting servers. For our guide we will use database based, WAR packaged application. It … Continue reading

Posted in Control Panels, Databases, Java, Tomcat | Leave a comment

How locale setting can break unicode/UTF-8 in Java/Tomcat

To avoid Java/Tomcat unicode issues after moving to a new environment you need to verify locale settings, especially LC_ALL. After migrating a complete Tomcat based site as cPanel tarball to another host we lost ability to download files containing unicode … Continue reading

Posted in Java, Tomcat | Leave a comment

How to connect to remote JVM with JProfiler

We show 2 methods of installing JProfiler agent and accessing JVM to be profiled from remote location. JProfiler is an award-winning all-in-one Java profiler and an alternative to jvisualvm. JProfiler’s GUI helps you detect performance bottlenecks, memory leaks and resolve … Continue reading

Posted in Java, Tomcat | Leave a comment

MySQL case-sensitivity and java.sql.SQLException: Can’t create table

MySQL case-sensitivity can cause create temporary table error for an application developed on Windows and run on Linux. Tomcat log: java.sql.SQLException: Can’t create table ‘xxxxx_1.#sql-5dc6_2dd2f85′ (errno: 121) MySQL server log: 120727 10:19:54 [Warning] Invalid (old?) table or database name ‘#sql-5dc6_2dd2f85′ … Continue reading

Posted in Databases, Java | Leave a comment