Apache Ignite 2.11.0启用ignite-rest-HTTP模块启动报错:No matching constructor class org.eclipse.jetty.server.Server
解决Ignite 2.11.0启用REST HTTP模块时的"No matching constructor"错误
这个坑我之前踩过!核心原因是Ignite 2.11.0升级了内置的Jetty版本到11.x,而Jetty 11的org.eclipse.jetty.server.Server构造器和2.10.0用的Jetty 9.x完全不兼容——你之前在2.10.0里用的jetty.xml配置用了过时的构造参数,导致启动时反射找不到匹配的构造方法。下面是具体的修复步骤:
1. 更新你的jetty.xml配置
Jetty 11不再支持直接给Server构造器传入端口参数,必须通过ServerConnector来配置端口。把原来的jetty.xml替换成适配Jetty 11的结构:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <!-- Jetty服务实例 --> <bean id="server" class="org.eclipse.jetty.server.Server"/> <!-- HTTP基础配置 --> <bean id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration"> <property name="sendServerVersion" value="false"/> </bean> <!-- 端口配置连接器 --> <bean id="connector" class="org.eclipse.jetty.server.ServerConnector"> <constructor-arg ref="server"/> <constructor-arg ref="httpConfig"/> <property name="port" value="8080"/> <!-- 替换成你需要的REST端口 --> </bean> </beans>
2. 确认模块与配置的关联正确
- 确保
ignite-rest-http模块已经放在Ignite安装目录的libs/或libs/optional/目录下,不要在其他目录重复放置该模块的JAR文件,避免依赖冲突。 - 检查
default-config.xml中的connectorConfiguration配置,确保指向正确的jetty.xml路径:<bean class="org.apache.ignite.configuration.IgniteConfiguration"> <!-- 其他已有的配置项 --> <property name="connectorConfiguration"> <bean class="org.apache.ignite.configuration.ConnectorConfiguration"> <property name="jettyPath" value="conf/jetty.xml"/> <!-- 改为你的jetty.xml实际路径 --> </bean> </property> </bean>
3. 验证JDK环境
你用的OpenJDK 8是符合要求的(Jetty 11支持JDK 8+),但要确保启动Ignite时没有添加干扰类加载的JVM参数,比如--module-path这类模块化参数,可能会影响Jetty类的正常加载。
4. 可选:直接用官方模板配置
Ignite 2.11.0的examples/config目录下有适配新版本Jetty的jetty-rest.xml模板,你可以直接复制这个文件到你的配置目录,修改端口后使用,能省掉手动配置出错的麻烦。
按照以上步骤调整后,重新启动Ignite,应该就能正常启用REST HTTP模块了。
内容的提问来源于stack exchange,提问作者Tom
相关产品推荐
相关产品推荐

