xiaoxing tech

October 14, 2008

Can not find test class ‘*****.java’ in project ‘

Filed under: JSP, Java, Spring, tomcat — xiaoxing @ 3:51 pm

I am following the Spring Framework tutorial here: http://static.springframework.org/docs/Spring-MVC-step-by-step/
While doing “1.9. Write a test for the Controller“, I ran into this error: Can not find test class ‘*****.java’ in project ‘
And, it seemed that a jar is missing: import javax.servlet.*** not successful
I suspect servlet-api.jar is missing.

My appserver.lib is ${appserver.home}/server/lib (defined in build.properties),
and in build.xml, it says:         <fileset dir=”${appserver.lib}”>             <include name=”servlet*.jar” />         </fileset>
while in appserver.lib, there is no file called: servlet-api.jar
I copied THE file from ${appserver.home}\common\lib to ${appserver.home}/server/lib,
problem solved.

A more elegant way (instead of putting the same file in two folders) of resolving this issue should exist.
Anyone gives me a hint?

August 12, 2008

Set up an HTTPS server on top of Tomcat

Filed under: tomcat — xiaoxing @ 10:39 am

Creating an SSL Certificate and Configuring Tomcat with SSL Connection (for Tomcat 6, Java 1.5 and Win XP SP2):
(from here: http://lemontz.blogspot.com/2007/01/opening-tomcat-ssl-connection.html)

  1. In command prompt, go to your Java home directory and go into the bin folder.
  2. Type in the following:
    keytool -genkey -alias tomcat -keyalg RSA

    This will open up the keytool from the JDK. It will create a SSL
    certificate for you. For tomcat, the default password is ‘changeit’ (case
    sensitive).

  3. Once the certificate has been created successfully, a file called .keystore should have been created in your user home directory i.e. something similar to this on Win XP:
    C:\Documents and Settings\xxzao\.keystore

    Copy this file into your top most root directory of your tomcat installation directory i.e. on Win XP:

    C:\

  4. Now go into the Tomcat installation directory and go into the folder conf and open you the file server.xml with an editor.
    (C:\Program Files\Apache Software Foundation\Tomcat 6.0\conf\server.xml)
  5. After this section “<!– Define a SSL HTTP/1.1 Connector on port 8443″, add the following:
    <!– xxz custom stuff starts here for https aug 12 2008 –>

        <Connector
               port=”8443″ minSpareThreads=”5″ maxSpareThreads=”75″
               enableLookups=”true” disableUploadTimeout=”true”
               acceptCount=”100″  maxThreads=”200″
               scheme=”https” secure=”true” SSLEnabled=”true”
               keystoreFile=”${user.home}/.keystore” keystorePass=”changeit”
               clientAuth=”false” sslProtocol=”TLS”/>

    <!– Define a blocking Java SSL Coyote HTTP/1.1 Connector on port 8443 –>

    <Connector protocol=”org.apache.coyote.http11.Http11Protocol”
               port=”8443″ minSpareThreads=”5″ maxSpareThreads=”75″
               enableLookups=”true” disableUploadTimeout=”true”
               acceptCount=”100″  maxThreads=”200″
               scheme=”https” secure=”true” SSLEnabled=”true”
               keystoreFile=”${user.home}/.keystore” keystorePass=”changeit”
               clientAuth=”false” sslProtocol=”TLS”/>

    <!– Define a non-blocking Java SSL Coyote HTTP/1.1 Connector on port 8443 –>

    <Connector protocol=”org.apache.coyote.http11.Http11NioProtocol”
               port=”8443″ minSpareThreads=”5″ maxSpareThreads=”75″
               enableLookups=”true” disableUploadTimeout=”true”
               acceptCount=”100″  maxThreads=”200″
               scheme=”https” secure=”true” SSLEnabled=”true”
               keystoreFile=”${user.home}/.keystore” keystorePass=”changeit”
               clientAuth=”false” sslProtocol=”TLS”/>

    <!– xxz custom stuff ends here for https aug 12 2008 –>

  6. Restart Tomcat and you should be able to see the Tomcat splash page when you access https://localhost:8443.
    Note: Use IE7 or Safari instead of Firefox.

Troubleshoot:
The best place to troubleshoot is always in the Tomcat log (yes! log is a wonderful thing which I have discovered since I entered the workfoce!!!).

If the following line is found in the log:
java.io.FileNotFoundException: C:\.keystore (The system cannot find the file specified)
This means it can’t find the .keystore file. Make sure the file is in the correct location (see above in the log that it expects the file to be found in the top most directory of your Tomcat installation folder).

If the following line is found in the log:
java.io.IOException: Keystore was tampered with, or password was incorrect
This means that the password you have entered is incorrect. The default password for Tomcat is ‘changeit’. A custom password can be used by setting the correct attribute for the connector element in server.xml. A new certificate must be created in order to fix this.

For more information:
This is only a summary of the steps I did in order to set up SSL connection for my Tomcat. I followed the following to help me to set up my SSL connection (which is where I got my information from):

Which has much more detailed information in there.

Blog at WordPress.com.