【问题标题】:java.lang.ClassCastException: com.sun.xml.internal.ws.client.sei.SEIStub cannot be cast to org.apache.cxf.frontend.clientproxy AEM OSGijava.lang.ClassCastException:com.sun.xml.internal.ws.client.sei.SEIStub 无法转换为 org.apache.cxf.frontend.clientproxy AEM OSGi
【发布时间】:2017-04-01 16:13:21
【问题描述】:

我正在尝试在 AEM 的 osgi 环境中使用fuelsdk。我收到此错误 -

java.lang.ClassCastException: com.sun.xml.internal.ws.client.sei.SEIStub 无法转换为 org.apache.cxf.frontend.ClientProxy

这是因为 OSGi 在其中嵌入了fuelsdk 的依赖项的包之前加载了系统包。捆绑包得到解决;此错误发生在运行时。

如何强制 OSGi 类加载器在运行时选择 org.apache.cxf.frontend.ClientProxy 而不是 com.sun.xml.internal.ws.client.sei.SEIStub?

我可以使用'uses'指令的组合吗?和/或导入/导出包?

有人建议我使用 -

创建客户端
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.getInInterceptors().add(new LoggingInInterceptor());
factory.getOutInterceptors().add(new LoggingOutInterceptor());
factory.setServiceClass(HelloWorld.class);
factory.setAddress("http://localhost:9000/helloWorld");
soapClient = (Client) factory.create();

我想知道我应该在 factory.setServiceClass() 中使用哪个类;

我应该在 factory.setAddress( ) 中使用哪个地址;是端点地址吗? -- https://webservice.s6.exacttarget.com/Service.asmx

非常感谢您的帮助 谢谢

【问题讨论】:

    标签: osgi aem osgi-fragment embedded-osgi


    【解决方案1】:

    您可以尝试更新<your installation>/crx-quickstart/conf/sling.properties 中的org.osgi.framework.bootdelegation 属性

    org.osgi.framework.bootdelegation= org.apache.cxf.*, ${org.apache.sling.launcher.bootdelegation}

    你可以阅读更多关于sling.propertieshere的信息

    更新 - 您可以强制您的包使用自定义包而不是 Java 包,为此您必须将 org.apache.cxf.* 包包装在具有附加属性的自定义包中 -

    1. 创建一个自定义包来包装您的 org.apache.cxf.*
    2. 在自定义包 POM 中,将 maven-bundle 插件配置为(注意带有 ;myidentifier="true";mandatory:="myidentifier" 的 Export-Package,在此处提供正确的标识符名称,如果 * 不起作用,您可能还必须在包级别执行此操作)

          <plugin>
              <groupId>org.apache.felix</groupId>
              <artifactId>maven-bundle-plugin</artifactId>
              <configuration>
                  <instructions>
                      <Export-Package>
                         org.apache.cxf.*;myidentifier="true";mandatory:="myidentifier"
                      </Export-Package>
      
                      <Private-Package>
      
                      </Private-Package>
      
                      <Import-Package>
                          *
                      </Import-Package>
      
                      <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
      
                      <Bundle-Activator>${project.artifactId}.Activator</Bundle-Activator>
      
                      <Include-Resource>
                          {maven-resources}
                      </Include-Resource>
      
                      <Embed-Dependency>
                          <!-- list of jar's to embed, exposing the Exporting packages. Comma separated-->
                      </Embed-Dependency>
      
                      <Embed-Transitive>true</Embed-Transitive>
                  </instructions>
              </configuration>
          </plugin>
      
    3. 无论何时需要使用这些包,都必须更新 maven-bundle 插件并明确指定导入 -

    &lt;Import-Package&gt;org.apache.cxf.*;myidentifier="true",*&lt;/Import-Package&gt;

    我们正在使用这种方法在与 AEM 一起打包的少数捆绑包(如 Guava)上使用更高版本,AEM 附带 Guava 15,而我们公开 Guava 18 而不会干扰系统对 Guava 15 的使用

    你可以阅读更多关于它here

    【讨论】:

    • 不幸的是;它没有效果。错误在这一行——soapClient = ClientProxy.getClient(soap);错误发生在运行时;捆绑包正确解析。 java.lang.ClassCastException:com.sun.xml.internal.ws.client.sei.SEIStub 无法转换为 org.apache.cxf.frontend.ClientProxy 我可以强制捆绑类加载器选择 org.apache.cxf.frontend.ClientProxy而不是 com.sun.xml.internal.ws.client.sei.SEIStub 仅用于此捆绑包?
    • 感谢您提出的方法;虽然我们现在遇到了一个新错误,但这有助于向前推进。并且还学到了一个与 OSGi 相关的新东西。
    • 嗨@cqsapientuser,您是如何解决java.lang.ClassCastException: com.sun.xml.internal.ws.client.sei.SEIStub cannot be cast to org.apache.cxf.frontend.ClientProxy 的问题的。任何反馈都会非常有帮助。
    猜你喜欢
    • 2017-11-06
    • 2012-12-15
    • 1970-01-01
    • 1970-01-01
    • 2015-09-26
    • 2018-01-16
    • 1970-01-01
    • 2019-06-28
    • 1970-01-01
    相关资源
    最近更新 更多