| 1 | ## Using the shaded JAR |
| 2 | |
| 3 | The default driver JAR depends on [Netty](http://netty.io/), which is |
| 4 | used internally for networking. |
| 5 | |
| 6 | This explicit dependency can be a problem if your application already |
| 7 | uses another Netty version. To avoid conflicts, we provide a "shaded" |
| 8 | version of the JAR, which bundles the Netty classes under a different |
| 9 | package name: |
| 10 | |
| 11 | ```xml |
| 12 | <dependency> |
| 13 | <groupId>com.datastax.cassandra</groupId> |
| 14 | <artifactId>cassandra-driver-core</artifactId> |
| 15 | <version>3.1.4</version> |
| 16 | <classifier>shaded</classifier> |
| 17 | <!-- Because the shaded JAR uses the original POM, you still need |
| 18 | to exclude this dependency explicitly: --> |
| 19 | <exclusions> |
| 20 | <exclusion> |
| 21 | <groupId>io.netty</groupId> |
| 22 | <artifactId>*</artifactId> |
| 23 | </exclusion> |
| 24 | </exclusions> |
| 25 | </dependency> |
| 26 | ``` |
| 27 | |
| 28 | If you also use the mapper, you need to remove its dependency to the |
| 29 | non-shaded JAR: |
| 30 | |
| 31 | ```xml |
| 32 | <dependency> |
| 33 | <groupId>com.datastax.cassandra</groupId> |
| 34 | <artifactId>cassandra-driver-core</artifactId> |
| 35 | <version>3.1.4</version> |
| 36 | <classifier>shaded</classifier> |
| 37 | <exclusions> |
| 38 | <exclusion> |
| 39 | <groupId>io.netty</groupId> |
| 40 | <artifactId>*</artifactId> |
| 41 | </exclusion> |
| 42 | </exclusions> |
| 43 | </dependency> |
| 44 | <dependency> |
| 45 | <groupId>com.datastax.cassandra</groupId> |
| 46 | <artifactId>cassandra-driver-mapping</artifactId> |
| 47 | <version>3.1.4</version> |
| 48 | <exclusions> |
| 49 | <exclusion> |
| 50 | <groupId>com.datastax.cassandra</groupId> |
| 51 | <artifactId>cassandra-driver-core</artifactId> |
| 52 | </exclusion> |
| 53 | </exclusions> |
| 54 | </dependency> |
| 55 | ``` |
| 56 | |
| 57 | ### Limitations |
| 58 | |
| 59 | When using the shaded jar, it is not possible to configure the Netty layer. |
| 60 | |
| 61 | Extending [NettyOptions] is not an option because `NettyOptions` API |
| 62 | exposes Netty classes, and as such it should only be extended |
| 63 | by clients using the non-shaded version of driver. |
| 64 | Attempting to extend `NettyOptions` with shaded Netty classes is not supported, |
| 65 | and in particular for OSGi applications, |
| 66 | it is likely that such a configuration would lead to compile and/or runtime errors. |
| 67 | |
| 68 | Also, with shaded Netty classes, it is not possible to benefit |
| 69 | from [Netty native transports]. |
| 70 | |
| 71 | It is therefore normal to see the following log line when the driver starts and |
| 72 | detects that shaded Netty classes are being used: |
| 73 | |
| 74 | Detected shaded Netty classes in the classpath; native epoll transport will not work properly, defaulting to NIO. |
| 75 | |
| 76 | |
| 77 | [NettyOptions]:http://docs.datastax.com/en/drivers/java/3.0/com/datastax/driver/core/NettyOptions.html |
| 78 | [Netty native transports]:http://netty.io/wiki/native-transports.html |