我使用IntelliJ,并且在Web浏览器中运行它时,它返回503错误:
Problem accessing / MySampleApplication.html. Reason:
Service Unavailable"*
该错误应该在 XML 文件中的某个位置,并且servlet路径似乎有问题。
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.8.0//EN"
"http://gwtproject.org/doctype/2.8.0/gwt-module.dtd">
<module rename-to="MySampleApplication">
<inherits name='com.google.gwt.user.User'/>
<entry-point class='com.mySampleApplication.client.MySampleApplication'/>
<servlet path='/MySampleApplicationService' class='com.mySampleApplication.server.ServiceImpl'/>>
/>
</module>
Code server started in 12.55 s ms
2019-03-06 13:09:20.410:INFO:oejs.Server:main: Started @13836ms
Loading modules
com.mySampleApplication.MySampleApplication
Validating <servlet> tags for module 'MySampleApplication'
For additional info see: file:/Users/simonemettesorensen/Downloads/gwt-2.8.2/doc/helpInfo/servletMappings.html
[WARN] Module declares a servlet class 'com.mySampleApplication.server.ServiceImpl' with a mapping to '/MySampleApplication/MySampleApplicationService', but the web.xml has no corresponding mapping; please add the following lines to your web.xml:
<servlet-mapping>
<servlet-name>com.mySampleApplication.MySampleApplication Service</servlet-name>
<url-pattern>/MySampleApplication/MySampleApplicationService</url-pattern>
</servlet-mapping>
2019-03-06 13:09:20.549:INFO:oejs.Server:main: jetty-9.2.z-SNAPSHOT
Starting Jetty on port 8888
[WARN] Failed startup of context c.g.g.d.s.j.WebAppContextWithReload@41aa7994{/,file:/Users/simonemettesorensen/Library/Caches/IntelliJIdea2018.2/gwt/%C3%B8velsemedrpc.9e5e27b2/oevelseMedRPC.6c3e6f2f/run/www/,STARTING}{/Users/simonemettesorensen/Library/Caches/IntelliJIdea2018.2/gwt/øvelsemedrpc.9e5e27b2/oevelseMedRPC.6c3e6f2f/run/www}
java.lang.NullPointerException
at java.lang.String.compareTo(String.java:1155)
at org.eclipse.jetty.servlet.ServletHolder.compareTo(ServletHolder.java:209)
at org.eclipse.jetty.servlet.ServletHolder.compareTo(ServletHolder.java:70)
at java.util.ComparableTimSort.countRunAndMakeAscending(ComparableTimSort.java:321)
at java.util.ComparableTimSort.sort(ComparableTimSort.java:188)
at java.util.Arrays.sort(Arrays.java:1246)
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:865)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:298)
at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1349)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1342)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:741)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:505)
at com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload.doStart(JettyLauncher.java:550)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
at org.eclipse.jetty.server.handler.RequestLogHandler.doStart(RequestLogHandler.java:140)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
at org.eclipse.jetty.server.Server.start(Server.java:387)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
at org.eclipse.jetty.server.Server.doStart(Server.java:354)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:760)
at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:636)
at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:923)
at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:706)
at com.google.gwt.dev.DevMode.main(DevMode.java:432)
2019-03-06 13:09:22.470:INFO:oejs.ServerConnector:main: Started ServerConnector@1006dd06{HTTP/1.1}{127.0.0.1:8888}
2019-03-06 13:09:22.470:INFO:oejs.Server:main: Started @15896ms
Dev Mode initialized. Startup URL:
http://127.0.0.1:8888/MySampleApplication.html
[ERROR] 503 - GET /MySampleApplication.html (127.0.0.1) 312 bytes
Request Headers
Host: 127.0.0.1:8888
Connection: keep-alive
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding: gzip, deflate, br
Accept-Language: da-DK,da;q=0.9,en-US;q=0.8,en;q=0.7
Response headers
Date: Wed, 06 Mar 2019 12:09:22 GMT
Cache-Control: must-revalidate,no-cache,no-store
Content-Type: text/html; charset=ISO-8859-1
Content-Length: 312
如果我添加了它,它将由于意外错误而无法运行:“ servlet映射:
<servlet-mapping>
<servlet-name>com.mySampleApplication.MySampleApplication Service</servlet-name>
<url-pattern>/MySampleApplication/MySampleApplicationService</url-pattern>
</servlet-mapping>
我将非常感谢您的帮助。
答案 0 :(得分:0)
Simone,欢迎来到GWT世界!
如果该servlet使用GWT-RPC,我强烈建议您考虑创建JSON端点。前进的RPC部分将被删除,JSON是标准的并且可以保证未来发展。 waaaaaaay更加易于调试和模拟,从而大大简化了GWT的工作。
答案 1 :(得分:0)
您需要用<servlet>
中的*.gwt.xml
(和<servlet-mapping>
)将<servlet>
文件中的WEB-INF/web.xml
(标准servlet映射,而不是特定于GWT,就像其他任何非GWT Servlet开发一样)