질문&답변
클라우드/리눅스에 관한 질문과 답변을 주고 받는 곳입니다.
리눅스 분류

[질문] 아파치 + 톰캣 연동시 사용자 계정에서 서블릿이 동작하지 않습니다.

작성자 정보

  • BombBang 작성
  • 작성일

컨텐츠 정보

본문

안녕하십니까?

아무리 검색해 가면서 해결을 해보려 해도 해결이 되지 않아 질문을 올리게 되었습니다.

리눅스 사용자 계정에서 *.jsp는 잘 돌아가는데, servlet이 돌아가지 않아서 도움을 구하고자 질문을 올립니다. 예를 들면, http://hostip/~userid/servlet/ServletName 또는 http://hostip/~userid/testDir/servlet/ServletName 등으로 접근해서 서블릿을 돌려 보고자 하는데 잘 안되는군요.

환경은 Apache 2.0.55 + Tomcat 5.5.17 + mod_jk 1.2.15 + J2SDK 1.5.0_07 이며 설정을 다음과 같이 하였습니다.

 

### httpd.conf ###

...

LoadModule jk_module          modules/mod_jk.so

# Where to find workers.properties
JkWorkersFile conf/workers.properties
# Where to put jk logs
JkLogFile logs/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel debug
# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"
# Send JSPs for context /jsp-examples to worker named default
JkMount /jsp-examples/*.jsp worker1
# Send servlets-examples to worker named default
JkMount /servlets-examples/* worker1

JkAutoAlias /usr/local/apache-tomcat-5.5.17/webapps
JkMount /*.jsp worker1
JkMount /servlet/* worker1

JkUnMount /*.gif worker1
JkUnMount /*.jpg worker1
JkUnMount /*.bmp worker1
JkUnMount /*.jpeg worker1

...

Alias /jsp-examples "/usr/local/tomcat/webapps/jsp-examples/"

<Directory "/usr/local/tomcat/webapps/jsp-examples">
    Options FollowSymLinks
    AllowOverride None
    Allow from all
</Directory>

<Directory "/usr/local/tomcat/webapps/jsp-examples/WEB-INF">
    AllowOverride None
    deny from all
</Directory>

Alias /servlets-examples "/usr/local/tomcat/webapps/servlets-examples/"

<Directory "/usr/local/tomcat/webapps/servlets-examples">
    Options FollowSymLinks
    AllowOverride None
    Allow from all
</Directory>

<Directory "/usr/local/tomcat/webapps/servlets-examples/WEB-INF">
    AllowOverride None
    deny from all
</Directory>

### web.xml ###

...

    <servlet>
        <servlet-name>default</servlet-name>
        <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
        <init-param>
            <param-name>debug</param-name>
            <param-value>0</param-value>
        </init-param>
        <init-param>
            <param-name>listings</param-name>
            <param-value>false</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
...

    <servlet>
        <servlet-name>invoker</servlet-name>
        <servlet-class>
          org.apache.catalina.servlets.InvokerServlet
        </servlet-class>
        <init-param>
            <param-name>debug</param-name>
            <param-value>0</param-value>
        </init-param>
        <load-on-startup>2</load-on-startup>
    </servlet>
...

    <servlet>
        <servlet-name>jsp</servlet-name>
        <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
        <init-param>
            <param-name>fork</param-name>
            <param-value>false</param-value>
        </init-param>
        <init-param>
            <param-name>xpoweredBy</param-name>
            <param-value>false</param-value>
        </init-param>
        <load-on-startup>3</load-on-startup>
    </servlet>
...

    <!-- The mapping for the default servlet -->
    <servlet-mapping>
        <servlet-name>default</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

    <!-- The mapping for the invoker servlet -->

    <servlet-mapping>
        <servlet-name>invoker</servlet-name>
        <url-pattern>/servlet/*</url-pattern>
    </servlet-mapping>

    <!-- The mapping for the JSP servlet -->
    <servlet-mapping>
        <servlet-name>jsp</servlet-name>
        <url-pattern>*.jsp</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>jsp</servlet-name>
        <url-pattern>*.jspx</url-pattern>
    </servlet-mapping>
...

    <security-constraint>
      <display-name>Default Servlet</display-name>
      <!-- Disable direct alls on the Default Servlet -->
      <web-resource-collection>
        <web-resource-name>Disallowed Location</web-resource-name>

    <url-pattern>/servlet/org.apache.catalina.servlets.DefaultServlet/*</url-pattern>
        <http-method>DELETE</http-method>
        <http-method>GET</http-method>
        <http-method>POST</http-method>
        <http-method>PUT</http-method>
      </web-resource-collection>
      <auth-constraint>
        <role-name></role-name>
      </auth-constraint>
    </security-constraint>

### server.xml ###

...

    <Connector port="8009"
               enableLookups="false" redirectPort="8443" protocol="AJP/1.3"
                                URIEncoding="EUC-KR"/>

...

      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>
...

      <Host name="localhost" appBase="webapps"
       unpackWARs="true" autoDeploy="true"
       xmlValidation="false" xmlNamespaceAware="false">

                        <Listener className="org.apache.catalina.startup.UserConfig"
                                directoryName="public_html"
                                userClass="org.apache.catalina.startup.PasswdUserDatabase" />
...

 

### workers.properties ###

workers.apache_log=/usr/local/apache/logs
workers.catalina_home=/usr/local/apache-tomcat-5.5.17
workers.java_home=/usr/java/jdk1.5.0_07
ps=/


worker.list=worker1

worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
worker.worker1.lbfactor=1
worker.worker1.cachesize=10
worker.worker1.cache_timeout=600
worker.worker1.socket_keepalive=1
worker.worker1.socket_timeout=60


그리고, 서블릿 *.class 파일은은 계정내 public_html 안에 WEB-INF/classes 디렉토리에 넣고 WEB-INF 디렉토리에는 별도로 web.xml 파일을 생성해서 다음의 내용도 추가해 보았습니다.

<?xml version="1.0" encoding="ISO-8859-1"?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    version="2.4">

<servlet>
 <servlet-name>HelloServlet</servlet-name>
 <servlet-class>HelloServlet</servlet-class>
</servlet>

<servlet-mapping>
 <servlet-name>HelloServlet</servlet-name>
 <url-pattern>/servlet/HelloServlet</url-pattern>
</servlet-mapping>


</web-app>

사용자 계정에서 JSP랑 JDBC 연동은 잘 되는데, 서블릿만 돌아가질 않고 있습니다. 명쾌한 해법 좀 주시면 감사드립니다. ㅠㅠ

관련자료

댓글 0
등록된 댓글이 없습니다.

공지사항


뉴스광장


  • 현재 회원수 :  60,083 명
  • 현재 강좌수 :  36,024 개
  • 현재 접속자 :  143 명