You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

从WebSphere 9迁移至Liberty Profile时Rest服务启动异常求助

解决WebSphere 9迁移至Liberty Profile时Rest服务初始化异常问题

Hey Rafał, sorry to hear you're stuck on this migration issue. Let's break down what's happening and walk through the fixes:

问题根源

The error NoSuchMethodException: org.apache.cxf.ws.policy.PolicyDataEngineImpl.<init>() points directly to a CXF version conflict. Liberty Profile comes with its own integrated CXF stack for handling JAX-RS services, but if your application bundles its own CXF libraries, they'll clash with Liberty's native implementation.

The version of PolicyDataEngineImpl in your app's jars doesn't have the no-arg constructor that Liberty's extension loader expects, leading to the initialization failure.

解决方案

Here are the actionable steps to fix this:

  • Remove packaged CXF dependencies from your app
    Liberty provides all necessary CXF/JAX-RS components out of the box. If you're using Maven/Gradle, mark all CXF-related dependencies as provided so they aren't bundled into your WAR/EAR. For Maven, that looks like:

    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxrs</artifactId>
        <version>your-cxf-version</version>
        <scope>provided</scope>
    </dependency>
    <!-- Repeat this for all other CXF dependencies like cxf-rt-ws-policy, etc. -->
    
  • Validate Liberty's JAX-RS feature setup
    Check your server.xml to ensure you're using the correct, unconflicted JAX-RS feature:

    <featureManager>
        <feature>jaxrs-2.0</feature> <!-- Use jaxrs-2.1 if your app requires it -->
        <feature>servlet-3.1</feature> <!-- Match your app's servlet version -->
    </featureManager>
    

    Avoid enabling multiple JAX-RS features or adding custom CXF bus configurations that override Liberty's default setup.

  • Simplify your RestApplicationConfig
    If your RestApplicationConfig servlet has manual registrations for CXF buses or policy-related beans, remove them. Liberty handles JAX-RS context and policy engine management automatically—let the container take care of these components instead of instantiating them yourself.

  • Clear Liberty's server cache
    Stale cached class files can cause weird classloader issues. Stop your Liberty server, delete these directories, then restart:

    • wlp/usr/servers/[your-server-name]/workarea
    • wlp/usr/servers/[your-server-name]/temp

总结

The core fix here is ensuring your application doesn't bundle its own CXF libraries—letting Liberty use its native, compatible implementation will resolve the constructor mismatch and get your Rest services up and running.

内容的提问来源于stack exchange,提问作者darkstar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 08:40:51