Weblogic应用程序服务器将Servlet映射中的JSP错误记录到HTML文件

时间:2018-10-31 15:19:47

标签: java jsp redirect servlets weblogic

我有一个Weblogic(12c)应用程序服务器,并向其部署了EAR(继续执行我的WAR)。 在web.xml中,我有一个servlet映射来重定向到如下所示的HTML页面:

<?xml version="1.0"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
         version="3.0">
    <description>my webapp</description>
    <servlet>
        <servlet-name>servlet_name</servlet-name>
        <jsp-file>/webapp/index.html</jsp-file>
    </servlet>
  <servlet-mapping>
    <servlet-name>servlet_name</servlet-name>
    <url-pattern>/webapp/*</url-pattern>
  </servlet-mapping>
</web-app>

这似乎可行,但在我的服务器日志中出现以下错误消息:

####<Oct 31, 2018, 1:25:16,132 PM GMT> <Error> .... <[ServletContext@563785877[app:myApp module:myApp-client path:null spec-version:3.1]] Root cause of ServletException.
weblogic.servlet.jsp.CompilationException: Failed to compile JSP /webapp/index.html
Exception occurred while processing '/opt/oracle/product/fusionMy/myDomain/domains/myDomain/servers/myApp/tmp/_WL_user/myApp-client/sz8ux3/war/webapp/index.html'java.lang.NullPointerException
    at weblogic.jsp.internal.ProxySourceFile._check(ProxySourceFile.java:151)
    at weblogic.jsp.internal.SourceFile.masterCheck(SourceFile.java:782)
    at weblogic.jsp.internal.SourceFile.check(SourceFile.java:314)
    at weblogic.jsp.internal.SourceFile.check(SourceFile.java:335)
    at weblogic.jsp.internal.ProxySourceFile.codeGen(ProxySourceFile.java:229)
    at weblogic.jsp.internal.SourceFile.codeGen(SourceFile.java:327)
    at weblogic.jsp.internal.client.ClientUtilsImpl$CodeGenJob.run(ClientUtilsImpl.java:626)
    at weblogic.jsp.internal.client.Job.performJob(Job.java:85)
    at weblogic.jsp.internal.client.ThreadPool$WorkerThread.run(ThreadPool.java:219)
index.html: java.lang.NullPointerException

    at weblogic.servlet.jsp.JavelinxJSPStub.reportCompilationErrorIfNeccessary(JavelinxJSPStub.java:247)
    at weblogic.servlet.jsp.JavelinxJSPStub.compilePage0(JavelinxJSPStub.java:183)
    at weblogic.servlet.jsp.JavelinxJSPStub.access$000(JavelinxJSPStub.java:50)
    at weblogic.servlet.jsp.JavelinxJSPStub$1.run(JavelinxJSPStub.java:111)
    at java.security.AccessController.doPrivileged(Native Method)
    at weblogic.servlet.jsp.JavelinxJSPStub.compilePage(JavelinxJSPStub.java:108)
    at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:267)
    at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:218)
    at weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.java:414)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:304)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:247)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3679)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3649)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:326)
    at weblogic.security.service.SecurityManager.runAsForUserCode(SecurityManager.java:197)
    at weblogic.servlet.provider.WlsSecurityProvider.runAsForUserCode(WlsSecurityProvider.java:203)
    at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:71)
    at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2433)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2281)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2259)
    at weblogic.servlet.internal.ServletRequestImpl.runInternal(ServletRequestImpl.java:1691)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1651)
    at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:270)
    at weblogic.invocation.ComponentInvocationContextManager._runAs(ComponentInvocationContextManager.java:348)
    at weblogic.invocation.ComponentInvocationContextManager.runAs(ComponentInvocationContextManager.java:333)
    at weblogic.work.LivePartitionUtility.doRunWorkUnderContext(LivePartitionUtility.java:54)
    at weblogic.work.PartitionUtility.runWorkUnderContext(PartitionUtility.java:41)
    at weblogic.work.SelfTuningWorkManagerImpl.runWorkUnderContext(SelfTuningWorkManagerImpl.java:640)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:406)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:346)

基于其他SO帖子,我认为这应该可以工作-但是此错误消息在说什么?
是否不允许-重定向到jsp-file标记中的HTML页面?
在WAR文件中执行此操作的正确方法是什么?

在我的本地Tomcat(8.5)上,它似乎可以正常工作,而日志中没有该错误(部署了WAR)。 在Weblogic中,我首先收到一个错误,但每个其他请求都在工作...

HTML文件(我测试过的一个版本):

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Simple Test!</title>
  <base href="/webapp/">
</head>
<body>
    <h1>HALLO</h1>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

在这里您指定了一个jsp文件,但是您正在传递一个html文件。

 <jsp-file>/webapp/index.html</jsp-file>

出现错误:

  

weblogic.servlet.jsp.CompilationException:无法编译JSP   /webapp/index.html

您需要将index.html换成jsp文件才能解决此问题。您只能将jsp文件用于<jsp-file>标签

编辑:

我误会了。 Apparently您可以在标记内有一个html页面,但需要确保它直接位于上下文根目录内。

因此,要解决此问题,您需要将.html文件移动到上下文根目录,并使用如下标记:

<jsp-file>/index.html</jsp-file>