Skip to content

Commit e27482a

Browse files
authored
IGNITE-26385 Add check for ignite-json module is enabled with ignite-rest-http (#12464)
1 parent f2a6e55 commit e27482a

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

docs/_docs/quick-start/restapi.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ include::includes/prereqs.adoc[]
2929
include::includes/install-ignite.adoc[]
3030

3131
Once that's done, you will need to enable HTTP connectivity.
32-
To do this, copy the `ignite-rest-http` module from `{IGNITE_HOME}/libs/optional/` to the `{IGNITE_HOME}/libs` folder.
32+
To do this, copy the `ignite-rest-http` and `ignite-json` modules from `{IGNITE_HOME}/libs/optional/` to the `{IGNITE_HOME}/libs` folder.
3333

3434
== Starting a Node
3535

docs/_docs/restapi.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ Internally, Ignite uses Jetty to provide HTTP server features. See <<Configurati
2222

2323
== Getting Started
2424

25-
To enable HTTP connectivity, make sure that the `ignite-rest-http` module is enabled.
26-
If you use the binary distribution, copy the `ignite-rest-http` module from `IGNITE_HOME/libs/optional/` to the `IGNITE_HOME/libs` folder.
25+
To enable HTTP connectivity, make sure that the `ignite-rest-http` and `ignite-json` modules are enabled.
26+
If you use the binary distribution, copy the `ignite-rest-http` and `ignite-json` modules from `IGNITE_HOME/libs/optional/` to the `IGNITE_HOME/libs` folder.
2727
See link:setup#enabling-modules[Enabling modules] for details.
2828

2929
Explicit configuration is not required; the connector starts up automatically and listens on port `8080`. You can check if it works with curl:

modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestProtocol.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import org.jetbrains.annotations.Nullable;
5050
import org.xml.sax.SAXException;
5151

52+
import static org.apache.ignite.IgniteCommonsSystemProperties.IGNITE_HOME;
5253
import static org.apache.ignite.IgniteSystemProperties.IGNITE_JETTY_HOST;
5354
import static org.apache.ignite.IgniteSystemProperties.IGNITE_JETTY_LOG_NO_OVERRIDE;
5455
import static org.apache.ignite.IgniteSystemProperties.IGNITE_JETTY_PORT;
@@ -71,6 +72,9 @@ public class GridJettyRestProtocol extends GridRestProtocolAdapter {
7172
}
7273
}
7374

75+
/** Object mapper class name. */
76+
private static final String IGNITE_OBJECT_MAPPER = "org.apache.ignite.internal.jackson.IgniteObjectMapper";
77+
7478
/** Jetty handler. */
7579
private GridJettyRestHandler jettyHnd;
7680

@@ -93,6 +97,11 @@ public GridJettyRestProtocol(GridKernalContext ctx) {
9397
@Override public void start(GridRestProtocolHandler hnd) throws IgniteCheckedException {
9498
assert ctx.config().getConnectorConfiguration() != null;
9599

100+
if (!checkJacksonEnabled())
101+
throw new IgniteCheckedException("Can't find ignite-json module in classpath, which is required for REST API " +
102+
"functionality. Copy ignite-json module from " + IGNITE_HOME + "/libs/optional/ to " + IGNITE_HOME +
103+
"/libs folder.");
104+
96105
String jettyHost = System.getProperty(IGNITE_JETTY_HOST, ctx.config().getLocalHost());
97106

98107
try {
@@ -330,6 +339,20 @@ private AbstractNetworkConnector getJettyConnector() throws IgniteCheckedExcepti
330339
httpSrv.getConnectors().length + "connectorsExpected=1]");
331340
}
332341

342+
/**
343+
* Check if ignite-json module enabled.
344+
*/
345+
private static boolean checkJacksonEnabled() {
346+
try {
347+
Class.forName(IGNITE_OBJECT_MAPPER);
348+
349+
return true;
350+
}
351+
catch (Exception e) {
352+
return false;
353+
}
354+
}
355+
333356
/**
334357
* Stops Jetty.
335358
*/

0 commit comments

Comments
 (0)