Date serialization and shading

I am experiencing the same issue as this one.

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

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>

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