You are here

missing servlet.jar on my cp_root

Submitted by vandresv on Sat, 02/18/2012 - 22:14

Forums:

Hello, I am trying for the first time to write a servlet to integrate on my luminis site.
I am using the /servlets-examples/helloworld.html that comes with luminis installation.
As you can see javac complains a lot when trying to compile the program. I can't find a servlet.jar on my system, but I found a servlet-api.jar. I set CLASSPATH to point to where the jar file is, but fails the same.
Please advise,
Thank you very much
Andres

--output:
[lumadmin@mipionerotest custom]$ export CLASSPATH=/opt/luminis/products/tomcat/tomcat-cp/common/lib/
[lumadmin@mipionerotest custom]$ javac myHello.java
myHello.java:2: package javax.servlet does not exist
import javax.servlet.*;
^
myHello.java:3: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
myHello.java:5: cannot find symbol
symbol: class HttpServlet
public class myHello extends HttpServlet {
^
myHello.java:7: cannot find symbol
symbol : class HttpServletRequest
location: class myHello
public void doGet(HttpServletRequest request, HttpServletResponse response)
^
myHello.java:7: cannot find symbol
symbol : class HttpServletResponse
location: class myHello
public void doGet(HttpServletRequest request, HttpServletResponse response)
^
myHello.java:8: cannot find symbol
symbol : class ServletException
location: class myHello
throws IOException, ServletException
^
6 errors

General:

Luminis Version:

I had to add the classpath including the servlet-api.jar. Something like this:

javac -classpath /opt/luminis/products/tomcat/tomcat-cp/common/lib/servlet-api.jar myHello.java

It compiled without complaining.

Andres

BTW, this is a Luminis 4.2.2.34 installation.

I've never had luck with specifying a directory of jars as a CLASSPATH component. The documentation says it should work, but it doesn't. I usually end up writing a script to build a CLASSPATH that will work. For example:

#!/bin/bash
CP='/opt/luminis/lib/sct-rt-2.0.0.jar'
WSPATH='/opt/luminis/webapps/webservice/WEB-INF/lib/'

for f in $(ls -1Af ${WSPATH}); do
    if [[ "${f}" != ".." || "${f}" != "." ]]; then
        CP=${CP}:${WSPATH}${f}
    fi
done

# Because Luminis has some older libraries that Groovy also uses
# we need to re-load the Groovy supplied libraries
CP=${CP}:~/JavaDev/groovy/embeddable/groovy-all-1.8.5.jar

./groovy/bin/groovy -cp ${CP} test.groovy

Have you tried the cpclasspath script that comes with the portal?
In a fresh shell try : . $CP_ROOT/bin/./cpclasspath
Then try compiling your code again. This has worked for all my development on 4.2.3.88 which included some of the classes you're missing.

-Tom

At the top of the script I have an entry to source the

.cprc

Then I have

export CLASSPATH=".:$CP_WEBINF/lib/ojdbc.jar:$CP_WEBINF/lib/uportal.jar"

Although, normally this is for calling java rather than javac

I use Eclipse IDE for all of my build and src code development.

Derek
University of Leeds, UK