apache jboss中的JSP部署问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2045578/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 18:37:03  来源:igfitidea点击:

JSP deploy problem in jboss

javaapachejspjbossmod-jk

提问by mengmenger

I have Jboss 4.0.4GA setup in Linux. after I start my jboss without problem, I tried to access JSP page in browser, got error:

我在 Linux 中安装了 Jboss 4.0.4GA。在我没有问题地启动我的 jboss 后,我尝试在浏览器中访问 JSP 页面,出现错误:

The XML page cannot be displayed 
Cannot view XML input using XSL style sheet. Please correct the error

and then click the Refresh button, or try again later.


A name was started with an invalid character. Error processing resource 'https://uappdev.marvell.com/login/index.jsp'. Lin...

<%@ page import="com.marvell.macroip.util.Constants" %> -^

The XML page cannot be displayed 
Cannot view XML input using XSL style sheet. Please correct the error

然后单击刷新按钮,或稍后再试。


名称以无效字符开头。处理资源“ https://uappdev.marvell.com/login/index.jsp”时出错。林...

<%@ page import="com.marvell.macroip.util.Constants" %> -^

and I find out the converted servlets class files is not in [jboss home]/work/jboss.web/localhost/_/org... directory. No errors in Jboss log file.

我发现转换后的 servlets 类文件不在 [jboss home]/work/jboss.web/localhost/_/org... 目录中。Jboss 日志文件中没有错误。

Can anybody help me to resolve this problem? I already spend a lot time one this problem, but no luck.

有人可以帮我解决这个问题吗?我已经花了很多时间解决这个问题,但没有运气。

here is my web.xml:

这是我的 web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
  <filter>
    <filter-name>AuthenticationFilter</filter-name>
    <filter-class>com.marvell.macroip.web.util.AuthenticationFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>AuthenticationFilter</filter-name>
    <url-pattern>/extract/*</url-pattern>    
  </filter-mapping>
  <filter-mapping>
    <filter-name>AuthenticationFilter</filter-name>    
    <url-pattern>/admin/*</url-pattern>
  </filter-mapping>
  <listener>
    <listener-class>com.marvell.macroip.web.util.PublicSessionListener</listener-class>
  </listener>
  <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param>
      <param-name>debug</param-name>
      <param-value>2</param-value>
    </init-param>
    <init-param>
      <param-name>config</param-name>
      <param-value>/WEB-INF/struts-config.xml</param-value>
    </init-param>
    <init-param>
      <param-name>application</param-name>
      <param-value>com.marvell.macroip.web.ApplicationResources</param-value>
    </init-param>
    <init-param>
      <param-name>detail</param-name>
      <param-value>2</param-value>
    </init-param>
    <init-param>
      <param-name>validate</param-name>
      <param-value>true</param-value>
    </init-param>
    <load-on-startup>2</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
  </servlet-mapping>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>
  <error-page>
    <error-code>400</error-code>
    <location>/error/index.jsp?code=400</location>
  </error-page>
  <error-page>
    <error-code>401</error-code>
    <location>/error/index.jsp?code=401</location>
  </error-page>
  <error-page>
    <error-code>403</error-code>
    <location>/error/index.jsp?code=403</location>
  </error-page>
  <error-page>
    <error-code>404</error-code>
    <location>/error/index.jsp?code=404</location>
  </error-page>
  <error-page>
    <error-code>405</error-code>
    <location>/error/index.jsp?code=405</location>
  </error-page>
  <error-page>
    <error-code>408</error-code>
    <location>/error/index.jsp?code=408</location>
  </error-page>
  <error-page>
    <error-code>410</error-code>
    <location>/error/index.jsp?code=410</location>
  </error-page>
  <error-page>
    <error-code>411</error-code>
    <location>/error/index.jsp?code=411</location>
  </error-page>
  <error-page>
    <error-code>412</error-code>
    <location>/error/index.jsp?code=412</location>
  </error-page>
  <error-page>
    <error-code>413</error-code>
    <location>/error/index.jsp?code=413</location>
  </error-page>
  <error-page>
    <error-code>414</error-code>
    <location>/error/index.jsp?code=414</location>
  </error-page>
  <error-page>
    <error-code>415</error-code>
    <location>/error/index.jsp?code=415</location>
  </error-page>
  <error-page>
    <error-code>500</error-code>
    <location>/error/index.jsp?code=500</location>
  </error-page>
  <error-page>
    <error-code>501</error-code>
    <location>/error/index.jsp?code=501</location>
  </error-page>
  <error-page>
    <error-code>502</error-code>
    <location>/error/index.jsp?code=502</location>
  </error-page>
  <error-page>
    <error-code>503</error-code>
    <location>/error/index.jsp?code=503</location>
  </error-page>
  <error-page>
    <error-code>506</error-code>
    <location>/error/index.jsp?code=506</location>
  </error-page>
  <taglib>
    <taglib-uri>/WEB-INF/for-loop.tld</taglib-uri>
    <taglib-location>/WEB-INF/for-loop.tld</taglib-location>
  </taglib>
  <taglib>
    <taglib-uri>/WEB-INF/root.tld</taglib-uri>
    <taglib-location>/WEB-INF/root.tld</taglib-location>
  </taglib>
  <taglib>
    <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
    <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
  </taglib>
  <taglib>
    <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
    <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
  </taglib>
  <taglib>
    <taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
    <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
  </taglib>
  <taglib>
    <taglib-uri>/WEB-INF/struts-nested.tld</taglib-uri>
    <taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
  </taglib>
  <security-constraint>
    <display-name>MacroIP Login</display-name>
    <web-resource-collection>
      <web-resource-name>MacroIP Login</web-resource-name>
      <url-pattern>/login/*</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
      <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
  </security-constraint>
  <security-constraint>
    <display-name>Extract</display-name>
    <web-resource-collection>
      <web-resource-name>Extract</web-resource-name>
      <url-pattern>/extract/*</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
      <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
  </security-constraint>
  <security-constraint>
    <display-name>Admin</display-name>
    <web-resource-collection>
      <web-resource-name>Admin</web-resource-name>
      <url-pattern>/admin/*</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
      <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
  </security-constraint>
</web-app>

jsp page:

jsp页面:

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page import="com.marvell.macroip.util.Constants" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/logic-ext.tld" prefix="logic-ext" %>
<bean:parameter id="logout" name="logout" value="false"/>

<html>
<head>
<title>Tracking System</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script language="JavaScript" type="text/JavaScript" src="/includes/imgChange.js"></script>
<script language="JavaScript" type="text/JavaScript" src="/includes/css_bCheck.js"></script>
<script language="javascript" type="text/javascript" src="/includes/sifr.js">// flash insert code</script>
</head>

<body bgcolor="#eeeeee" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
              <table width="470" border="0" cellspacing="0" cellpadding="0">
                   <tr valign="middle">
<td align="right" bgcolor="#ebebeb" class="smallgrey"><span class="red">*</span>User Name &nbsp;</td>
                   <td>
<html:text property="userName" styleClass="formElement" size="29" disabled="false" style="width:290px"/>
                  </td>
                </tr>

                <tr valign="middle">
                  <td align="right" bgcolor="#ebebeb" class="smallgrey"><span class="red">*</span>Password&nbsp;</td>
                  <td>
                  <html:password property="password" maxlength="35" redisplay="false" styleClass="formElement" size="29" disabled="false" style="width:290px"/>
                  </td>
                </tr>
              </table>

              <table width="440" border="0" cellspacing="0" cellpadding="0">

                <tr>
                  <td align="right">
                    <input type="image" alt="Submit" border="0" />
                  </td>                        
                </tr>
              </table>

if i try this jsp page, it will be blank page or display the original jsp code in browser.

如果我尝试这个jsp页面,它将是空白页面或在浏览器中显示原始jsp代码。

   <html><head><title>JSP Test</title> 
   <%! 
   String message = "Hello, World."; 
   %> 
   </head> 
   <body> 
   <h2><%= message%></h2> 
   <%= new java.util.Date() %> 
   </body></html>

回答by mengmenger

I did find out the solution. from what jsight said "Yeah, I figured it was internal... I was just wondering if perhaps the apache->jboss process (or something else) isn't actually hitting the page that you think it is. Eg, you'd see a problem like this if apache were serving the page itself (misconfigured apache) instead of redirecting to jboss. Or possibly if you were hitting something other than a .jsp (some other permutation of the url). – jsight"

我确实找到了解决方案。来自 jsight 所说的“是的,我认为它是内部的......我只是想知道 apache->jboss 进程(或其他东西)是否实际上没有点击你认为的页面。例如,你会如果 apache 为页面本身提供服务(错误配置的 apache)而不是重定向到 jboss,就会看到这样的问题。或者,如果您遇到了 .jsp 以外的其他内容(url 的其他一些排列)。 – jsight”

I found out it should be apache+ssl trying to resolve jsp by itself instead passing jsp request to jboss. and then my coworker and I find out the mod_jk is not loaded properly in apache. therefore, add "JkMountCopy ALL" right after the mod-jk.conf loaded in httpd.conf file. and restart Apache, voila.... it worked!

我发现它应该是 apache+ssl 试图自己解析 jsp 而不是将 jsp 请求传递给 jboss。然后我和我的同事发现 mod_jk 没有在 apache 中正确加载。因此,在 httpd.conf 文件中加载的 mod-jk.conf 之后添加“JkMountCopy ALL”。并重新启动 Apache,瞧......它起作用了!

回答by BalusC

The problem is here that JSP's are not compiled nor executed as expected.

问题是 JSP 没有按预期编译或执行。

The one who's responsible for that is the JspServletwhich is configured in the web.xmlof the servlet container. In case of JBoss AS, that's Tomcat and its web.xmlis by default located in the /conffolder of the Tomcat installation. It mustcontain an active (i.e. not outcommented) <servlet>definition of the org.apache.jasper.servlet.JspServletand a <servlet-mapping>on the same servlet-namealong with an url-patternof *.jsp. Verify if anything is right.

对此负责的是在 servlet 容器的 中JspServlet配置的web.xml。如果是 JBoss AS,那就是 Tomcat,它web.xml默认位于/confTomcat 安装的文件夹中。它必须含有活性(即不是outcommented)<servlet>的定义org.apache.jasper.servlet.JspServlet和一个<servlet-mapping>在同一个servlet-name与沿url-pattern*.jsp。验证是否有任何正确。

Another cause might have been that the web.xmlof the webapplication itself (the one in the /WEB-INFfolder) has another Filteror Servleton exactly the same url-patternas the JspServlet(and is thus overriding it), but that's not the case after judging the web.xmlyou posted.

另一个原因可能是该web.xml的web应用本身(一个在/WEB-INF文件夹中)有另一个FilterServlet完全一样url-patternJspServlet(并因此覆盖它),但这不是判断以后的情况web.xml你贴。