0

I am changing pattern "com.sun.jersey" to shadedPattern "route66.com.sun.jersey" using maven shade plugin.

I am using com.sun.jersey:jersey-client:1.19.3 in my code and running it on hadoop. But hadoop system lib jars have older version of jersey-client. So I had to change pattern "com.sun.jersey" to shadedPattern "route66.com.sun.jersey" to avoid class not found exception. Following is the shading code in my pom.xml

    <execution>
    <phase>package</phase>
    <goals>
        <goal>shade</goal>
    </goals>
    <configuration>
        <shadedClassifierName>jar-with-dependencies</shadedClassifierName>
        <minimizeJar>false</minimizeJar>
        <keepDependenciesWithProvidedScope>false</keepDependenciesWithProvidedScope>
        <shadedArtifactAttached>true</shadedArtifactAttached>
        <relocations>
            <relocation>
                <pattern>com.sun.jersey</pattern>
                <shadedPattern>route66.com.sun.jersey</shadedPattern>
            </relocation>
        </relocations>
        <transformers>
            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                <mainClass>com.yahoo.infox.route66.udf.ContentExtractorUdf</mainClass>
            </transformer>
            <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
        </transformers>
        <filters>
            <filter>
                <artifact>*:*</artifact>
                <excludes>
                    <exclude>META-INF/*.SF</exclude>
                    <exclude>META-INF/*.DSA</exclude>
                    <exclude>META-INF/*.RSA</exclude>
                </excludes>
            </filter>
        </filters>
    </configuration>
</execution>

I am even using ServicesResourceTransformer to make sure all the class names present in META_INF/services are also changed properly.

Even after this i am getting error

SEVERE: The provider class, class route66.com.sun.jersey.multipart.impl.MultiPartReaderClientSide, could not be instantiated. Processing will continue but the class will not be    utilized
java.lang.IllegalArgumentException: The MultiPartConfig instance we expected is not present. Have you registered the MultiPartConfigProvider class?
    at route66.com.sun.jersey.multipart.impl.MultiPartReaderClientSide.<init>(MultiPartReaderClientSide.java:107)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
    at route66.com.sun.jersey.core.spi.component.ComponentConstructor._getInstance(ComponentConstructor.java:210)
    at route66.com.sun.jersey.core.spi.component.ComponentConstructor.getInstance(ComponentConstructor.java:180)
    at route66.com.sun.jersey.core.spi.component.ProviderFactory.__getComponentProvider(ProviderFactory.java:166)
    at route66.com.sun.jersey.core.spi.component.ProviderFactory.getComponentProvider(ProviderFactory.java:137)
    at route66.com.sun.jersey.core.spi.component.ProviderServices.getComponent(ProviderServices.java:283)
    at route66.com.sun.jersey.core.spi.component.ProviderServices.getServices(ProviderServices.java:163)
    at route66.com.sun.jersey.core.spi.factory.MessageBodyFactory.initReaders(MessageBodyFactory.java:176)
    at route66.com.sun.jersey.core.spi.factory.MessageBodyFactory.init(MessageBodyFactory.java:162)
    at route66.com.sun.jersey.api.client.Client.init(Client.java:343)
    at route66.com.sun.jersey.api.client.Client.access$000(Client.java:119)
    at route66.com.sun.jersey.api.client.Client$1.f(Client.java:192)
    at route66.com.sun.jersey.api.client.Client$1.f(Client.java:188)
    at route66.com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:193)
    at route66.com.sun.jersey.api.client.Client.<init>(Client.java:188)
    at route66.com.sun.jersey.client.apache4.ApacheHttpClient4.<init>(ApacheHttpClient4.java:151)
    at route66.com.sun.jersey.client.apache4.ApacheHttpClient4.<init>(ApacheHttpClient4.java:137)
    at route66.com.sun.jersey.client.apache4.ApacheHttpClient4.create(ApacheHttpClient4.java:181)

Any idea what's wrong here ?

1 Answers1

0

this issue is happening as META-INF/services/com.sun.jersey* files are not renamed to shadedPattern.

There is open issue on maven shade plugin on this.

For now i followed hack mentioned in Rename files inside a jar using some maven plugin to solve my issue.

Community
  • 1
  • 1