# Date serialization and shading

**URL:** <https://discuss.elastic.co/t/date-serialization-and-shading/249944>\
**Category:** Elasticsearch\
**Created:** [September 25, 2020, 9:35am UTC](https://discuss.elastic.co/t/date-serialization-and-shading/249944 "2020-09-25T09:35:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jnioche](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jnioche/32/13090_2.png) [@jnioche](https://discuss.elastic.co/u/jnioche)\
**Post date:** [September 25, 2020, 9:35am UTC](https://discuss.elastic.co/t/date-serialization-and-shading/249944/1 "2020-09-25T09:35:30Z")

</div>

I am experiencing the same issue as [this one](https://discuss.elastic.co/t/high-level-rest-client-java-and-date-serialization/169869/7).

I copied the code snippet provided by @baz and am able to run it without problems with `mvn compile exec:java` or from Eclipse but when building the uber jar with Maven shade I am getting

> Exception in thread "main" java.lang.IllegalArgumentException: cannot write time value xcontent for unknown value of type class java.util.Date  
> at org.elasticsearch.common.xcontent.XContentBuilder.timeValue(XContentBuilder.java:751)  
> at org.elasticsearch.common.xcontent.XContentBuilder.timeField(XContentBuilder.java:719)  
> at Snippet.main(Snippet.java:21)

The shade plugin is configured as follows

```
    			<plugin>
    				<groupId>org.apache.maven.plugins</groupId>
    				<artifactId>maven-shade-plugin</artifactId>
    				<version>3.1.0</version>
    				<executions>
    					<execution>
    						<phase>package</phase>
    						<goals>
    							<goal>shade</goal>
    						</goals>
    						<configuration>
    							<createDependencyReducedPom>false</createDependencyReducedPom>
    							<transformers>
    								<transformer
    									implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
    								<transformer
    									implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
    									<mainClass>org.apache.storm.flux.Flux</mainClass>
    									<manifestEntries>
    										<Change></Change>
    										<Build-Date></Build-Date>
    										<Implementation-Version>1.15.0</Implementation-Version>
    									</manifestEntries>
    								</transformer>
    							</transformers>
    						    <relocations>
    								<relocation>
    									<pattern>org.apache.http</pattern>
    									<shadedPattern>hidden.org.apache.http</shadedPattern>
    								</relocation>
    								<relocation>
    									<pattern>org.apache.logging</pattern>
    									<shadedPattern>hidden.org.apache.logging</shadedPattern>
    								</relocation>
    								<relocation>
    									<pattern>org.apache.commons.codec</pattern>
    									<shadedPattern>hidden.org.apache.commons.codec</shadedPattern>
    								</relocation>
    								<relocation>
    									<pattern>org.apache.commons.logging</pattern>
    									<shadedPattern>hidden.org.apache.commons.logging</shadedPattern>
    								</relocation>
    							</relocations>
    						</configuration>
    					</execution>
    				</executions>
    			</plugin>

```

Thanks

---

<div class="post-metadata">

**Author:** ![jnioche](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jnioche/32/13090_2.png) [@jnioche](https://discuss.elastic.co/u/jnioche)\
**Post date:** [September 25, 2020, 10:07am UTC](https://discuss.elastic.co/t/date-serialization-and-shading/249944/2 "2020-09-25T10:07:17Z")

</div>

I managed to get it back to work with

```
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-shade-plugin</artifactId>
			<version>3.2.4</version>
			<configuration>
				<createDependencyReducedPom>true</createDependencyReducedPom>
				<filters>
					<filter>
						<artifact>*:*</artifact>
						<excludes>
							<exclude>META-INF/*.SF</exclude>
							<exclude>META-INF/*.DSA</exclude>
							<exclude>META-INF/*.RSA</exclude>
						</excludes>
					</filter>
					<filter>
						<!-- https://issues.apache.org/jira/browse/STORM-2428 -->
						<artifact>org.apache.storm:flux-core</artifact>
						<excludes>
							<exclude>org/apache/commons/**</exclude>
							<exclude>org/apache/http/**</exclude>
							<exclude>org/yaml/**</exclude>
						</excludes>
					</filter>
				</filters>
			</configuration>
			<executions>
				<execution>
					<phase>package</phase>
					<goals>
						<goal>shade</goal>
					</goals>
					<configuration>
						<createDependencyReducedPom>false</createDependencyReducedPom>
						<transformers>
							<transformer
								implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
							<transformer
								implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
								<mainClass>org.apache.storm.flux.Flux</mainClass>
								<manifestEntries>
									<Change></Change>
									<Build-Date></Build-Date>
									<Implementation-Version>1.15.0</Implementation-Version>
								</manifestEntries>
							</transformer>
						</transformers>
					</configuration>
				</execution>
			</executions>
		</plugin>
```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 23, 2020, 10:07am UTC](https://discuss.elastic.co/t/date-serialization-and-shading/249944/3 "2020-10-23T10:07:28Z")

</div>

Closed on October 23, 2020, 10:07am UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
