我无法从代码中找到有关启动和使用 Apache Felix的信息.
我想做一些我能够(或无法))与Apache Felix的Shell一起做的事情.
例如,如何启动模块?
请帮忙.
我有一个捆绑,宣布激活器.此激活器创建一个JFrame并显示它.
作为插件项目在Eclipse上运行它工作正常.当我戴上菲利克斯时,它不再起作用了.它显示:java.lang.NoClassDefFoundError:com/griep/ui/MainFrame
但是当然,MainFrame位于激活器的同一束中,作为公共类.我不明白为什么类加载器没有找到类.
谁知道发生了什么?
根据这篇文章,IDEA使用Osmorc来运行OSGi框架.反过来,它使用Pax Runner来启动不同的框架实现.
IDEA 11中的工具链只能运行Apache Felix 3.0.2,但我必须运行4.0.2版本.可能吗?IDEA还有其他OSGi框架发射器吗?
我需要将REST客户端集成到使用Apache Felix实现的现有OSGi应用程序中.REST服务基于JAX-RS的RESTeasy实现(版本2.3.2.Final).我创建了一个单独的包,其中包含客户端的依赖项,导出所需的RESTeasy包并将其导入到使用客户端的包中,但遗憾的是我无法在OSGi上下文中使用它.
我尝试了两种不同的方法.第一个使用通用ClientRequest:
ClientRequest request = new ClientRequest(MyService.URL_TEST+"/stats");
request.body(javax.ws.rs.core.MediaType.APPLICATION_XML, stats);
ClientResponse<String> response = request.post(String.class);
Run Code Online (Sandbox Code Playgroud)
我在这种情况下得到的错误非常奇怪:
[java] java.lang.RuntimeException: java.lang.ClassCastException:
org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor cannot be cast to
org.jboss.resteasy.client.ClientExecutor
Run Code Online (Sandbox Code Playgroud)
我知道ApacheHttpClient4Executor实现了ClientExecutor接口.
当我尝试在RESTeasy周围使用我自己的REST客户端包装时,如下所示:
MyService myService = MyServiceClient.getInstance();
myService.saveStatistics(stats);
Run Code Online (Sandbox Code Playgroud)
我得到一个不同的例外:
[java] java.lang.LinkageError: ClassCastException: attempting to
castjar:file:/D:/Development/Eclipses/eclipse_4.2_j2ee_x64/lib/jaxrs-api-2.3.2.Final.jar
!/javax/ws/rs/ext/RuntimeDelegate.classtobundle:
//78.0:1/javax/ws/rs/ext/RuntimeDelegate.class
Run Code Online (Sandbox Code Playgroud)
据我所知,LinkageError很可能与RESTeasy使用一些类加载器技巧初始化RuntimeDelegate的方式有关,这可能属于OSGi框架的限制.我怀疑首先提到的java.lang.ClassCastException具有相同的源.
有没有办法让RESTeasy在OSGi中运行?
PS:关于RESTeasy的类似问题的讨论,但在OSGi之外:java.lang.LinkageError:ClassCastException
更新: 这些是包含在restclient包中的库:activation-1.1.jar commons-codec-1.2.jar commons-httpclient-3.1.jar commons-io-2.1.jar commons-logging-1.0.4.jar flexjson-2.1. jar httpclient-4.1.2.jar httpcore-4.1.2.jar javassist-3.12.1.GA.jar jaxb-api-2.2.3.jar jaxb-impl-2.2.4.jar jaxrs-api-2.3.2. Final.jar jcip-annotations-1.0.jar jettison-1.3.1.jar jsr250-api-1.0.jar junit-4.10.jar log4j-1.2.14.jar resteasy-jaxb-provider-2.3.2.Final.jar resteasy -jaxrs-2.3.2.Final.jar resteasy-jettison-provider-2.3.2.Final.jar scannotation-1.0.3.jar slf4j-api-1.6.4.jar slf4j-log4j12-1.6.4.jar myservice- common-0.1.0.3.jar my-service-client-0.1.0.3-SNAPSHOT.jar stax-api-1.0-2.jar xmlpull-1.1.3.1.jar xpp3_min-1.1.4c.jar xstream-1.4.2.jar …
我正在使用OSGi-(felix),SpringDM,hibernate,maven的项目.当我安装bundle时,没关系,我运行bundle id时的输出是:
LastModified 1384619994484
Headers [Manifest-Version=1.0, Bundle-Vendor=NguyenVinhLinh, Bnd-LastModified=1384619954778, Tool=Bnd-2.1.0.20130426-122213, Bundle-Name=DrugManager, Built-By=nguyenvinhlinh, Import-Package=org.hibernate,org.hibernate.classic,org.hibernate.criterion,org.springframework.beans.factory;version="[2.5,3)",org.springframework.core.io;version="[2.5,3)",org.springframework.transaction.annotation;version="[2.5,3)", Bundle-SymbolicName=DrugManagerDAO, Export-Package=drug,drugGroup,model;version="1.0.0", Bundle-Version=1.0.0, Build-Jdk=1.7.0_45, Created-By=Apache Maven Bundle Plugin, Bundle-ManifestVersion=2]
BundleContext null
Revisions [169.0]
BundleId 169
SymbolicName DrugManagerDAO
RegisteredServices null
ServicesInUse null
Version 1.0.0
Location file:/home/nguyenvinhlinh/Projects/felix-framework-4.2.1/bundle/DrugManager-1.0.jar
State 2
Bundle 169|Installed | 1|DrugManagerDAO (1.0.0)
Run Code Online (Sandbox Code Playgroud)
这就是我看到的,当我开始这个包时:
org.osgi.framework.BundleException: Unresolved constraint in bundle DrugManagerDAO [169]: Unable to resolve 169.0: missing requirement [169.0] osgi.wiring.package; (osgi.wiring.package=org.hibernate)
Run Code Online (Sandbox Code Playgroud)
这是我的beans.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:osgi="http://www.springframework.org/schema/osgi"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/osgi
">
<tx:annotation-driven …Run Code Online (Sandbox Code Playgroud) 我正试图在广阔的企业OSGi编程生态系统中感到舒服,但我发现很难概述这个技术堆栈是如何组合在一起的,哪些技术相互依赖,哪些技术解决了什么任务,以及如何它们都符合我迄今为止所理解的有限术语.
例如:Apache Felix,Equinox,Karaf,Jira OSGi,Spring DM,Aries Blueprint,Gemini Blueprint,iPOJO,Camel等之间的关系是什么......
我知道Equinox基于Felix,而Blueprint变体和iPOJO在某种程度上与组件管理有关,但是声明服务呢?DS是Blueprint的替代品,还是Blueprint是Declarative Services的实现?
总的来说,我很困惑,我真的需要简单概述一般OSGi技术的相关性.
有谁知道OSGi生态系统存在这样的概述 - 也许是图形化的?
最好的祝福.
我尝试根据一些示例实现自己的类加载器。但是,我认为它不能按预期方式工作(无法重新加载Jar文件等。我很少看到推荐使用OSGI或Apache Felix来处理Jar文件加载的参考。是否有加载Jar,实例化Jar中的类的示例?
关于我要完成的工作的更多详细信息。我有一个Java命令行应用程序,该应用程序实际上可以连续运行。我希望它能够在运行时动态引用JAR文件,并在运行时实例中引用这些jar中的类。这些罐子可能包含1个或多个支持类。这些Jar实质上是自定义的工作单元,可以通过连续运行的主应用程序中的某些事件条件执行这些Jar。..由于这是一个多客户端程序,所以我想让jars成为可插入类型的工作单元。
我目前的方向是为“客户端”提供编码接口,然后让他们将类打包在jar文件中。然后,应用程序将执行已配置的(数据库)jar路径,并从Jar中运行类。这适用于加载jar和类,但是,我希望能够从本质上热部署这些jar。
总而言之,我想创建一个JAR文件,其中包含支持功能的类。一个定义的类,它将在运行时从Jar(从主循环应用程序)中引用。在主应用程序运行时更改JAR文件的功能。
如果要使用第三方库,则最好使用Apache Felix。
谢谢
我想我是使用Apache Felix 4弄清楚的。这是加载jar /类的最佳方法吗?还是有更好更好的方法。到目前为止,我的研究并未指出一种解决方案。谢谢。
FrameworkFactory ff = new FrameworkFactory ();
Map<String,Object> config = new HashMap<String,Object>();
config.put("org.osgi.framework.storage", "c:\\temp\\myclientBundles");
config.put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,
"packages needed,more packages needed");
config.put(Constants.FRAMEWORK_STORAGE_CLEAN, "true");
Framework fwk = ff.newFramework(config);
fwk.start();
BundleContext bc = fwk.getBundleContext();
Bundle bundle = bc.installBundle("file:C:\\my_client.jar");
bundle.start();
bundle.update();
Class clazz = bundle.loadClass("client.work.process");
Job pc = (Job) clazz.newInstance();
pc.startWork(someConfigObject);
bundle.stop();
fwk.stop();
Run Code Online (Sandbox Code Playgroud) 我一直无法使用我的SCR插件工作.我已经搜索了尽可能多的只能找到与我需要使用的结构不相似的例子.下面的POM片段.这几乎是CQ项目原型生成的默认值.所有依赖都在那里,所以可能不是那样.这是构建的输出:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building project Bundle 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ project-bundle ---
[INFO] Deleting C:\project-path\target
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ bundle ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\project-path\src\main\resources
[INFO]
[INFO] --- …Run Code Online (Sandbox Code Playgroud) 我正在运行AEM 6.1的实例,并且在安装捆绑软件时遇到问题。我正在通过Maven安装捆绑软件(可能不相关,但不排除它)。
捆绑软件在安装后将不会定期启动。我得到以下与未启动的捆绑包相关的堆栈跟踪。
*ERROR* [Background Update org.mybundle.bundle (392)] org.apache.felix.http.jetty Cannot install or update bundle from /media/ephemeral0/aemtmp/install24
98177112217878414.tmp (org.osgi.framework.BundleException: Unable to acquire global lock for resolve.)
org.osgi.framework.BundleException: Unable to acquire global lock for resolve.
at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4101)
at org.apache.felix.framework.Felix.startBundle(Felix.java:2114)
at org.apache.felix.framework.Felix.updateBundle(Felix.java:2481)
at org.apache.felix.framework.BundleImpl.update(BundleImpl.java:995)
at org.apache.felix.webconsole.internal.core.UpdateHelper.doRun(UpdateHelper.java:60)
at org.apache.felix.webconsole.internal.core.BaseUpdateInstallHelper.doRun(BaseUpdateInstallHelper.java:93)
at org.apache.felix.webconsole.internal.core.UpdateHelper.doRun(UpdateHelper.java:70)
at org.apache.felix.webconsole.internal.core.BaseUpdateInstallHelper.run(BaseUpdateInstallHelper.java:123)
at java.lang.Thread.run(Thread.java:745)
Run Code Online (Sandbox Code Playgroud)
有没有人看到这个问题并知道解决方案?
我遇到了maven-bundle-plugin生成的MANIFEST.MF问题.出于某种原因,当我在<Import-Package>字段中列出版本号时,OSGi框架不会加载我的包.
我已经尝试并注意到如果我删除清单中的版本号,那么捆绑包已正确加载.
如何指示maven-bundle-plugin跳过版本号?
目前,它生成:
Import-Package: com.ghc.ghTester.expressions,org.apache.ws.security.proc
essor;version="[1.5,2)",org.apache.ws.security;version="[1.5,2)",org.ap
ache.ws.security.message;version="[1.5,2)",org.apache.ws.security.compo
nents.crypto;version="[1.5,2)",org.apache.ws.security.message.token;ver
sion="[1.5,2)"
Run Code Online (Sandbox Code Playgroud)
但我需要它来生成:
Import-Package:com.ghc.ghTester.expressions,org.apache.ws.security.proc essor,org.apache.ws.security,org.apache.ws.security.message,org.apache.ws.security.components.crypto,org.apache.ws.security.message.token
我的插件配置是:
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>3.0.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${pom.groupId}.${pom.artifactId};singleton:=true</Bundle-SymbolicName>
<Bundle-Name>${pom.name}</Bundle-Name>
<Bundle-Version>${pom.version}</Bundle-Version>
<Bundle-ClassPath>{maven-dependencies},.</Bundle-ClassPath>
<Embed-Dependency>*;scope=compile</Embed-Dependency>
<Export-Package/> <!-- nothing for this bundle to export -->
<Import-Package>com.ghc.ghTester.expressions,org.apache.ws.*</Import-Package>
</instructions>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
如果我尝试加载版本,我会收到以下错误:
org.osgi.framework.BundleException: Could not resolve module: com.rit.message-level-security [978]
Unresolved requirement: Import-Package: org.apache.ws.security; version="[1.0.0,3.0.0)"
at org.eclipse.osgi.container.Module.start(Module.java:434)
at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:393)
at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:412)
at com.ghc.ghTester.Activator.installTempBundle(Activator.java:157)
Run Code Online (Sandbox Code Playgroud) apache-felix ×10
osgi ×10
java ×5
maven ×3
aem ×1
classloader ×1
eclipse ×1
equinox ×1
helios ×1
jar ×1
jira ×1
module ×1
resteasy ×1
spring-dm ×1
web-services ×1