Calling Exported Classes of an OSGi Bundle from BeanShell

Confluence User - 27 Apr, 2019

I just developed an OSGi bundle package to be used in BeanShell Scripts. It's a web service client, not Joget plugin. I make it a bundle to preventing library version conflict. However, my exported classes are not available at runtime environment of BeanShell.

What am I missing here?

 

pom.xml

<?xml version="1.0" encoding="UTF-8"?>

<!--suppress NonOsgiMavenDependency -->
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>iq.earthlink.client</groupId>
    <artifactId>earthlink-api-client</artifactId>
    <version>1.0</version>
    <packaging>bundle</packaging>


    <properties>
        <kotlin.version>1.3.31</kotlin.version>
        <retrofit.version>2.5.0</retrofit.version>
        <junit.version>5.4.2</junit.version>

        <!-- Absence of this means you are using platform specific encoding -->
        <!-- More information: https://stackoverflow.com/q/10335815/5631308 -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>

        <jvm.source>1.8</jvm.source>
        <jvm.target>1.8</jvm.target>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.1</version>
                <configuration>
                    <skipTests>true</skipTests>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-maven-plugin</artifactId>
                <version>${kotlin.version}</version>
                <executions>
                    <execution>
                        <id>compile</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>test-compile</id>
                        <phase>test-compile</phase>
                        <goals>
                            <goal>test-compile</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <jvmTarget>1.8</jvmTarget>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>4.2.0</version>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Export-Package>iq.earthlink.client.*</Export-Package>
                        <Import-Package>!*</Import-Package>
                        <Embed-Dependency>*;scope=compile|runtime;inline=false</Embed-Dependency>
                        <Embed-Transitive>true</Embed-Transitive>
                        <Embed-Directory>dependency</Embed-Directory>
                    </instructions>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib-jdk8</artifactId>
            <version>${kotlin.version}</version>
        </dependency>
        <dependency>
            <groupId>com.squareup.retrofit2</groupId>
            <artifactId>retrofit</artifactId>
            <version>${retrofit.version}</version>
        </dependency>
        <dependency>
            <groupId>com.squareup.retrofit2</groupId>
            <artifactId>converter-gson</artifactId>
            <version>${retrofit.version}</version>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-test-junit5</artifactId>
            <version>${kotlin.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

</project>
osgi-bundle;beanshell

2


29 Apr, 2019
confluenceUser
confluenceUser

Hi, I believe BeanShell scripts will not be able to access classes within OSGI libraries. You could either encapsulate the behavior you require within a web service that can be called, or include the JAR library in the tomcat or joget lib directories.

29 Apr, 2019
confluenceUser
confluenceUser

Hello Anders, Well, there should be a way. I would truly appreciate if you check this out with your team

RELATED QUESTIONS

Your answer


To answer a question you'll need an account.

Print