我是OSGi的新手。我写了JIRA插件,Apache Felix Bundle。我的捆绑包使用Sprring Framework RestTemplate和Jackson XML进行简单的REST API调用。
所以我使用其他包(在OSGi包含上可用):Apache ServiceMix :: Bundles :: spring-web
将<Import-Package>
设置为com.fasterxml.jackson.*; version="[2,3)";resolution:="optional"
我在OSGi容器上安装了jackson-databind,jackson-core和jackson-annotations(全部在2.6.5版本中),以提供缺少的可选依赖项。
我的github上提供了完整的源代码。
当我安装我的插件时一切正常,但在运行时我收到错误:
2016-03-09 10:47:55,431 http-nio-2990-exec-11 ERROR achomont 647x10800x1 1wof9hv 0:0:0:0:0:0:0:1 /secure/CreateWorklog.jspa [c.a.event.internal.AsynchronousAbleEventDispatcher] There was an exception thrown trying to dispatch event [WorklogCreatedEvent{worklog=com.atlassian.jira.issue.worklog.WorklogImpl2@555b9717}] from the invoker [SingleParameterMethodListenerInvoker{method=public void com.company.soft.mycompany.work.log.plugin.listeners.WorkLogIssueListener.onWorklogEvent(com.atlassian.jira.event.worklog.WorklogEvent), listener=com.company.soft.mycompany.work.log.plugin.listeners.WorkLogIssueListener@7491b5aa}]
java.lang.RuntimeException: com/fasterxml/jackson/core/JsonProcessingException
at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:54)
at com.atlassian.event.internal.AsynchronousAbleEventDispatcher$1$1.run(AsynchronousAbleEventDispatcher.java:48)
at com.google.common.util.concurrent.MoreExecutors$DirectExecutorService.execute(MoreExecutors.java:299)
at com.atlassian.event.internal.AsynchronousAbleEventDispatcher.dispatch(AsynchronousAbleEventDispatcher.java:107)
at com.atlassian.event.internal.EventPublisherImpl.invokeListeners(EventPublisherImpl.java:160)
at com.atlassian.event.internal.EventPublisherImpl.publish(EventPublisherImpl.java:79)
at java.util.Optional.ifPresent(Optional.java:159)
at com.atlassian.jira.issue.worklog.DefaultTimeTrackingIssueUpdater.dispatchEvent(DefaultTimeTrackingIssueUpdater.java:242)
at com.atlassian.jira.issue.worklog.DefaultTimeTrackingIssueUpdater.doUpdate(DefaultTimeTrackingIssueUpdater.java:221)
at com.atlassian.jira.issue.worklog.DefaultTimeTrackingIssueUpdater.updateIssue(DefaultTimeTrackingIssueUpdater.java:202)
at com.atlassian.jira.issue.worklog.DefaultTimeTrackingIssueUpdater.updateIssueOnWorklogCreate(DefaultTimeTrackingIssueUpdater.java:89)
at com.atlassian.jira.issue.worklog.DefaultWorklogManager.create(DefaultWorklogManager.java:68)
at com.atlassian.jira.bc.issue.worklog.DefaultWorklogService.create(DefaultWorklogService.java:724)
at com.atlassian.jira.bc.issue.worklog.DefaultWorklogService.createAndAutoAdjustRemainingEstimate(DefaultWorklogService.java:381)
at com.atlassian.jira.web.action.issue.CreateWorklog.doExecute(CreateWorklog.java:100)
... 1 filtered
at com.atlassian.jira.action.JiraActionSupport.execute(JiraActionSupport.java:63)
... 7 filtered
at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
... 74 filtered
at com.atlassian.labs.httpservice.resource.ResourceFilter.doFilter(ResourceFilter.java:59)
... 38 filtered
at com.atlassian.jira.security.JiraSecurityFilter.doFilter(JiraSecurityFilter.java:70)
... 37 filtered
at com.atlassian.fastdev.AutoReloadFilter.doFilter(AutoReloadFilter.java:63)
... 55 filtered
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/JsonProcessingException
at com.company.soft.mycompany.connector.impl.MycompanyConnectorImpl.sendWorklogData(MycompanyConnectorImpl.java:80)
at com.company.soft.mycompany.connector.impl.MycompanyConnectorImpl.sendWorklogData1(MycompanyConnectorImpl.java:96)
at com.company.soft.mycompany.connector.impl.MycompanyConnectorImpl.sendWorklogDataWithCheck(MycompanyConnectorImpl.java:100)
at com.company.soft.mycompany.connector.impl.MycompanyConnectorImpl.sendAddWorkLogData(MycompanyConnectorImpl.java:65)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
... 1 filtered
at java.lang.reflect.Method.invoke(Method.java:497)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:56)
at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:60)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133)
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:70)
at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:53)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.eclipse.gemini.blueprint.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:57)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133)
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
at com.sun.proxy.$Proxy2639.sendAddWorkLogData(Unknown Source)
at com.company.soft.mycompany.work.log.plugin.listeners.WorkLogIssueListener.sendWorkLogData(WorkLogIssueListener.java:115)
at com.company.soft.mycompany.work.log.plugin.listeners.WorkLogIssueListener.onWorklogEvent(WorkLogIssueListener.java:63)
... 3 filtered
at java.lang.reflect.Method.invoke(Method.java:497)
at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:36)
... 235 more
Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.core.JsonProcessingException not found by org.apache.servicemix.bundles.spring-web [13]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532)
at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 267 more
看起来OSGi包含不明白 com.fasterxml.jackson.core
现在可用。
Apache ServiceMix :: Bundles :: spring-web
?我希望有人可以帮助我。
答案 0 :(得分:1)
如果您的捆绑包具有可选导入,并且您允许它在没有将导入连接到导出器的情况下解析,那么这种情况将持续到您执行“刷新”操作。 OSGi尝试将bundle import / export连接尽可能保持静态,因为重新计算它可能很昂贵,并且还强制bundle重新启动。
因此,如果您希望OSGi连接到现在可用的导入,则需要刷新。这可以通过键入refresh
命令在Gogo shell中完成。