简体   繁体   中英

Weblogic Application server logs JSP error on servlet mapping to HTML file

I got a Weblogic (12c) application server and deploy an EAR (contining my WAR) to it. In the web.xml I have a servlet-mapping to redirect to a HTML page like the following:

<?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>

This seems working but in my server log I got folloing error message:

####<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)

based on other SO posts I assumed that that should work - but what is this error message saying?
Is this not allowed - to redirect to a HTML page in the jsp-file tag?
What is the right way of doing this in a WAR file?

On my local Tomcat (8.5) it seem to work without that error in logs (deployed WAR).
In Weblogic I first get an error but every further request is working ...

HTML file (one version I tested):

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

Here you specifiy a jsp file, but you are passing a html file.

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

Hence your error:

weblogic.servlet.jsp.CompilationException: Failed to compile JSP /webapp/index.html

You need to swap out index.html for a jsp file to fix this. You can only use a jsp file for the <jsp-file> tag

EDIT:

I am mistaken. Apparently you can have a html page inside the tag but you need to make sure that it is directly inside your context root.

So in order to fix this, you need to move your .html file to your context root and use the tag like this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM