gpt4 book ai didi

java - 在 Tomcat 上部署 Spark Java

转载 作者:行者123 更新时间:2023-11-28 22:06:21 28 4
gpt4 key购买 nike

我想在 tomcat 上部署 SparkJava。在 web.xml 中我有

<filter>
<filter-name>SparkFilter</filter-name>
<filter-class>spark.servlet.SparkFilter</filter-class>
<init-param>
<param-name>RestCheckerService</param-name>
<param-value>rest.RestCheckerService</param-value>
</init-param>
</filter>

<filter-mapping>
<filter-name>SparkFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

当我尝试部署 Spark 时出现此错误:

javax.servlet.ServletException: java.lang.NullPointerException
at spark.servlet.SparkFilter.getApplication(SparkFilter.java:92)
at spark.servlet.SparkFilter.init(SparkFilter.java:70)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
...
Caused by: java.lang.NullPointerException
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at spark.servlet.SparkFilter.getApplication(SparkFilter.java:89)

我的过滤器类

public class RestCheckerService implements SparkApplication{
...

@Override
public void init() {
...

Spark.get("/scheme/:groupName/:schemeName/:version", new Route() {
@Override
public Object handle(Request request, Response response) {
try {
return gson.toJson(clientDB.getScheme(request.params(":groupName"), request.params(":schemeName"), Integer.parseInt(request.params(":version"))));

} catch (DaoException e) {
return RestErrorCodes.ERROR;
}
}
});

}

可能是因为我用的是 Java7 而不是 Java8

最佳答案

替换

<param-name>RestCheckerService</param-name>

<param-name>applicationClass</param-name>

关于java - 在 Tomcat 上部署 Spark Java,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30248054/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com