适用于Wildfly 16的OSGi客户端

时间:2019-05-15 13:36:21

标签: java osgi wildfly java-11

我有一个正常工作的OSGi客户端,它通过Java 8连接到Wildfly8。

要实现这一点,我们在野生蝇的客户端JAR上有一个带有Eclipse-BuddyPolicy: registered的包装程序捆绑包,而所有带有API的捆绑包都带有Eclipse-BuddyPolicy: global

我将项目更新为Java 11和Wildfly16。现在上述情况不再起作用。

反而我得到

javax.naming.CommunicationException: EJBCLIENT000062: Failed to look up "org.acme.ear/GreatModule/RemoteInterface!org.acme.api.RemoteInterface?stateless" [Root exception is java.lang.ClassNotFoundException: org.acme.api.RemoteInterface]
    at org.jboss.ejb.client.EJBRootContext.lookupNative(EJBRootContext.java:148)
    at org.wildfly.naming.client.AbstractContext.lookup(AbstractContext.java:84)
    at org.wildfly.naming.client.WildFlyRootContext.lookup(WildFlyRootContext.java:144)
    at java.naming/javax.naming.InitialContext.lookup(InitialContext.java:409)
    ... 77 more
Caused by: java.lang.ClassNotFoundException: org.acme.api.RemoteInterface
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    at org.eclipse.osgi.internal.framework.ContextFinder.loadClass(ContextFinder.java:135)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:398)
    at org.jboss.ejb.client.EJBRootContext.lookupNative(EJBRootContext.java:146)
    ... 83 more

调用bean的代码是这样的(仅在OSGi上下文中调用):

    final Properties properties = new Properties();
    properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory");
    properties.put(Context.PROVIDER_URL, "remote+http://localhost:8080/");
    properties.put(Context.SECURITY_PRINCIPAL, "test");
    properties.put(Context.SECURITY_CREDENTIALS, "test");
    final InitialContext context = new InitialContext(properties);

    final RemoteInterface result = (RemoteInterface) context
            .lookup("org.acme.ear/GreatModule/RemoteInterface!org.acme.api.RemoteInterface?stateless");
    System.out.println(result);

我什至不知道从哪里开始调试这个问题。

如何为Wildfly 16创建OSGi客户端?

0 个答案:

没有答案