编译WSO2 Identity Server 6.1启动时OSGI依赖错误排查修复求助
近期从源码编译WSO2 Identity Server 6.1,启动服务时出现大量OSGI Bundle相关错误,核心日志如下:
2023-08-02 16:21:29,126] [] ERROR {Events.Framework} - FrameworkEvent ERROR org.osgi.framework.BundleException: Could not resolve module: org.wso2.identity.apps.common [515] Unresolved requirement: Import-Package: org.wso2.carbon.identity.oauth; version="[6.1.0,7.0.0)" -> Export-Package: org.wso2.carbon.identity.oauth; bundle-symbolic-name="org.wso2.carbon.identity.oauth"; bundle-version="6.11.21"; version="6.11.21"; uses="com.nimbusds.jwt,org.apache.commons.logging,org.wso2.carbon.core,org.wso2.carbon.core.common,org.wso2.carbon.identity.application.authentication.framework.model,org.wso2.carbon.identity.application.common,org.wso2.carbon.identity.application.common.model,org.wso2.carbon.identity.base,org.wso2.carbon.identity.oauth.dao,org.wso2.carbon.identity.oauth.dto,org.wso2.carbon.identity.oauth2,org.wso2.carbon.identity.oauth2.model,org.wso2.carbon.identity.openidconnect.model,org.wso2.carbon.user.core" org.wso2.carbon.identity.oauth [345] Unresolved requirement: Import-Package: waffle.util; version="[1.6.0,2.0.0)" Unresolved requirement: Import-Package: org.wso2.carbon.identity.oauth.dto; version="[6.1.0,7.0.0)" -> Export-Package: org.wso2.carbon.identity.oauth.dto; bundle-symbolic-name="org.wso2.carbon.identity.oauth"; bundle-version="6.11.21"; version="6.11.21" at org.eclipse.osgi.container.Module.start(Module.java:457) at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$1.run(ModuleContainer.java:1820) at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$2$1.execute(EquinoxContainerAdaptor.java:150) at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1813) at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1770) at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1735) at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1661) at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345)
已查阅多个论坛未找到解决方案,尝试启动Karaf控制台或OSGI控制台排查也未成功,恳请指导如何定位并修复这些依赖问题。
问题定位
从日志可明确核心故障:org.wso2.carbon.identity.oauth bundle无法解析waffle.util包的依赖,进而导致依赖它的org.wso2.identity.apps.common等bundle启动失败。Waffle是Windows集成认证组件,默认编译流程可能未正确引入该依赖。
修复步骤
1. 检查并补充Waffle依赖配置
进入org.wso2.carbon.identity.oauth模块的pom.xml文件,确认是否包含以下Waffle依赖配置:
<dependency> <groupId>com.github.waffle</groupId> <artifactId>waffle-jna</artifactId> <version>1.9.0</version> <!-- 匹配日志要求的[1.6.0,2.0.0)版本范围 --> <scope>provided</scope> </dependency>
若缺失,添加上述配置后重新编译该模块。
2. 验证编译产物中的Waffle Bundle
编译完成后,检查<IS_BUILD_HOME>/repository/components/plugins目录下是否存在com.github.waffle.waffle-jna_*.jar文件。若不存在:
- 确认Maven本地仓库
~/.m2/repository/com/github/waffle/waffle-jna/是否已拉取对应版本依赖 - 使用官方推荐命令重新编译:
mvn clean install -Dmaven.test.skip=true
3. 手动补充Waffle Bundle(临时修复)
若编译后仍缺失该Bundle,可手动下载waffle-jna-1.9.0.jar,将其放入<IS_BUILD_HOME>/repository/components/plugins目录,再重启服务器。
4. 替代OSGI控制台的排查方式
若Karaf/OSGI控制台无法启动,可通过以下方式获取更多依赖信息:
- 在启动脚本中添加参数
-Dosgi.debug=debug.properties,开启OSGI调试日志 - 查看
<IS_BUILD_HOME>/repository/logs/osgi.log,该日志会记录所有Bundle的启动状态与依赖细节
5. 确认编译环境一致性
确保使用的JDK(推荐11)、Maven版本(推荐3.8.x)与官方文档要求一致,避免因环境不匹配导致依赖拉取或编译异常。
内容的提问来源于stack exchange,提问作者Raghav

