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

Liferay模块集成非Maven仓库第三方库失败求助

Hey there! Let's work through this dependency issue you're hitting with your Liferay module and that third-party openBIS jar. The error Unresolved requirement: Import-Package: ch.ethz.sis.openbis.generic.asapi.v3 means the OSGi framework is trying to pull that package from another bundle, but it can't find it—because you've got the package in your local jar that hasn't been properly embedded into your module's bundle. Here's how to fix it:

Step 1: Fix Your Bundle Configuration (Simplest Approach: Use Gradle's Embed Feature)

Instead of manually configuring bnd properties, let Liferay's Gradle plugin handle embedding the jar for you—it's less error-prone. Update your build.gradle dependencies block like this:

dependencies {
    compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "2.0.0"
    compileOnly group: "com.liferay.portal", name: "com.liferay.util.taglib", version: "2.0.0"
    compileOnly group: "javax.portlet", name: "portlet-api", version: "2.0"
    compileOnly group: "javax.servlet", name: "javax.servlet-api", version: "3.0.1"
    compileOnly group: "jstl", name: "jstl", version: "1.2"
    compileOnly group: "org.osgi", name: "osgi.cmpn", version: "6.0.0"
    // Configure the local jar to be embedded into your bundle
    compile files('lib/openBIS-API-V3-16.05.7-r1522065804.jar') {
        exclude group: '*', module: '*'
        embed = true
    }
}

This tells Gradle to package the local jar directly into your module's OSGi bundle, and automatically sets up the necessary bnd properties to make the jar's classes available to your code.

Step 2: If You Prefer Manual BND Configuration

If you want to stick with manual bnd setup, adjust your bnd.bnd to explicitly include the openBIS packages in your bundle and prevent OSGi from trying to import them:

Bundle-Name: my-dbdisplayer-project
Bundle-SymbolicName: de.mpi.prototype.dbdisplayer
Bundle-Version: 1.0.0
Export-Package: \
    de.mpi.prototype.dbdisplayer.constants
// Include the openBIS packages as private (not exported) in your bundle
Private-Package: \
    ch.ethz.sis.openbis.generic.asapi.v3,\
    ch.*  // Use a more specific path if you want to limit what's included
// Make sure the local jar is on the bundle classpath
Bundle-Classpath: ., lib/openBIS-API-V3-16.05.7-r1522065804.jar
// Embed the jar into the bundle
-includeresource: lib/openBIS-API-V3-16.05.7-r1522065804.jar
// Tell OSGi not to try importing these packages
-noimport: ch.ethz.sis.openbis.generic.asapi.v3

Note: BND syntax is sensitive to spaces after commas, so double-check those!

Step 3: Clean, Rebuild, and Deploy

After updating your configs, run these commands to ensure old build artifacts don't cause issues:

./gradlew clean build
blade deploy

If you still run into problems, use the Liferay OSGi console to diagnose further:

  1. Run blade sh to enter the console
  2. Use lb to check your bundle's status
  3. Run diag 505 (replace 505 with your bundle ID) to get detailed dependency resolution info

Quick Check Before Deploying

Verify the openBIS jar actually contains the missing package by running this command in your module's root directory:

jar tf lib/openBIS-API-V3-16.05.7-r1522065804.jar | grep ch.ethz.sis.openbis.generic.asapi.v3

You should see a list of classes in that package—if not, double-check you have the correct jar file.


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.27 10:00:36