Сервер приложений Weblogic регистрирует ошибку JSP при отображении сервлета в файл HTML - PullRequest
0 голосов
/ 31 октября 2018

Я получил сервер приложений Weblogic (12c) и развернул на нем EAR (ограничивающий мою WAR). В файле web.xml у меня есть отображение сервлета для перенаправления на страницу 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, я предположил, что это должно сработать - но что говорит это сообщение об ошибке?
Разрешено ли это - перенаправлять на HTML-страницу в теге jsp-файла?
Как правильно сделать это в файле 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 голосов
/ 31 октября 2018

Здесь вы указываете jsp-файл, но вы передаете html-файл.

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

Отсюда ваша ошибка:

weblogic.servlet.jsp.CompilationException: не удалось скомпилировать JSP /webapp/index.html

Вам нужно заменить файл index.html на файл jsp, чтобы это исправить. Вы можете использовать только jsp-файл для тега <jsp-file>

РЕДАКТИРОВАТЬ:

Я ошибаюсь. Очевидно, у вас может быть html-страница внутри тега, но вы должны убедиться, что она находится непосредственно в вашем корне контекста.

Таким образом, чтобы это исправить, вам нужно переместить ваш файл .html в корневой каталог контекста и использовать тег, подобный следующему:

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