我正在使用maven shade插件将模式“com.sun.jersey”更改为shadedPattern“route66.com.sun.jersey”。
我在我的代码中使用com.sun.jersey:jersey-client:1.19.3并在hadoop上运行它。但hadoop系统lib jars有旧版本的jersey-client。所以我不得不将模式“com.sun.jersey”更改为shadedPattern“route66.com.sun.jersey”以避免发现类未找到异常。以下是我的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>
我甚至使用ServicesResourceTransformer来确保META_INF / services中存在的所有类名也正确更改。
即使在此之后我也会收到错误
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)
知道这里有什么问题吗?
答案 0 :(得分:0)
此问题正在发生,因为META-INF / services / com.sun.jersey *文件未重命名为shadedPattern。
关于maven shade插件存在未解决的问题。
现在我跟随Rename files inside a jar using some maven plugin中提到的黑客来解决我的问题。