Je travaille sur une webapp où je démarre le framework osgi dans un écouteur de contexte de servlet (Eclipse Equinox version 3.10.0). La webapp s'exécute dans Tomcat 8 avec Java 7. J'ai développé et installé 2 faisceaux simples fonctionnant bien tant qu'ils utilisent leurs classes internes. Mais lorsque je tente d'importer des packages de webapp dans les faisceaux avec la configuration system.package.extra, faisceaux ne parviennent pas à résoudre ces paquets:Comment compiler le projet du plugin Eclipse en référençant des paquets système supplémentaires à partir de la webapp sous-jacente?
java.lang.Error: Unresolved compilation problems:
The import xxx.xxxxxxxx cannot be resolved
Le cadre déclare le système de paquets supplémentaires ainsi:
public void contextInitialized(ServletContextEvent cntxt) {
Iterator<FrameworkFactory> frameworkFactoryIt = ServiceLoader.load(FrameworkFactory.class).iterator();
boolean frameworkStarted = false;
while (frameworkFactoryIt.hasNext() && !frameworkStarted) {
FrameworkFactory frameworkFactory = frameworkFactoryIt.next();
Map<String, String> config = new HashMap<String, String>();
config.put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA, "xxx.xxxxxxxx,...");
config.put(Constants.FRAMEWORK_STORAGE, "https://stackoverflow.com/users/peveuve/osgi-cache");
config.put(Constants.FRAMEWORK_STORAGE_CLEAN, "true");
framework = frameworkFactory.newFramework(config);
framework.start();
....
le faisceau MANIFEST ressemble à ce qui suit:
Import-Package: org.osgi.framework;version="1.3.0",
xxx.xxxxxxxx;resolution:=optional,
le paquet importé est rendue facultative pour éviter toute erreur dans le plug-in Eclipse projec t. Je n'utilise pas le versioning.
Lorsque la liste des en-têtes cadres, je remarquais il y a un espace entre les paquets du système et mes paquets de système supplémentaires dans l'Export-Package:
...,org.xml.sax.helpers, xxx.xxxxxxxx,...
Comme il est ajouté par le cadre lui-même, je suppose ce n'est pas un problème, mais qui sait.
Voici la pleine stacktrace:
!SESSION 2016-02-26 16:07:35.175 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.7.0_79
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=fr_FR
!ENTRY com.amfinesoft.kheops.service.user 4 0 2016-02-26 16:07:35.176
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.ServiceException: Exception in com.amfinesoft.kheops.service.user.UserServiceFactory.getService()
at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.factoryGetService(ServiceFactoryUse.java:222)
at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.getService(ServiceFactoryUse.java:111)
at org.eclipse.osgi.internal.serviceregistry.ServiceConsumer$2.getService(ServiceConsumer.java:45)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:496)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.getService(ServiceRegistry.java:461)
at org.eclipse.osgi.internal.framework.BundleContextImpl.getService(BundleContextImpl.java:619)
at com.amfinesoft.kheops.consumer.user.UserConsumerActivator.start(UserConsumerActivator.java:24)
at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:771)
at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:1)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:764)
at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:721)
at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:936)
at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:319)
at org.eclipse.osgi.container.Module.doStart(Module.java:571)
at org.eclipse.osgi.container.Module.start(Module.java:439)
at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:454)
at org.eclipse.osgi.container.ModuleContainer.applyDelta(ModuleContainer.java:717)
at org.eclipse.osgi.container.ModuleContainer.resolveAndApply(ModuleContainer.java:491)
at org.eclipse.osgi.container.ModuleContainer.resolve(ModuleContainer.java:437)
at org.eclipse.osgi.container.ModuleContainer.resolve(ModuleContainer.java:427)
at org.eclipse.osgi.container.Module.start(Module.java:416)
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1582)
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1562)
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1533)
at org.eclipse.osgi.container.SystemModule.startWorker(SystemModule.java:242)
at org.eclipse.osgi.container.Module.doStart(Module.java:571)
at org.eclipse.osgi.container.Module.start(Module.java:439)
at org.eclipse.osgi.container.SystemModule.start(SystemModule.java:172)
at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:393)
at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:412)
at org.eclipse.osgi.launch.Equinox.start(Equinox.java:115)
at com.amfinesoft.kheops.service.starter.OSGIServletContextListener.contextInitialized(OSGIServletContextListener.java:60)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4812)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5255)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.Error: Unresolved compilation problems:
The import com.eclipsesource cannot be resolved
The import com.eclipsesource cannot be resolved
The import kheops cannot be resolved
The import kheops cannot be resolved
The import kheops cannot be resolved
The import system cannot be resolved
The type UserServiceImpl must implement the inherited abstract method UserServiceIntf.listOfUsers(KCommand, KBrowser)
KCommand cannot be resolved to a type
KCommand cannot be resolved to a type
KBrowser cannot be resolved to a type
JsonArray cannot be resolved to a type
JsonArray cannot be resolved to a type
The method getTrees() is undefined for the type DBUserFinder
The method getTrees() is undefined for the type DBUserContainer
JsonValue cannot be resolved
Logger cannot be resolved
KCommandProcessor cannot be resolved
at com.amfinesoft.kheops.service.user.impl.UserServiceImpl.<init>(UserServiceImpl.java:7)
at com.amfinesoft.kheops.service.user.UserServiceFactory.getService(UserServiceFactory.java:14)
at com.amfinesoft.kheops.service.user.UserServiceFactory.getService(UserServiceFactory.java:1)
at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse$1.run(ServiceFactoryUse.java:212)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.factoryGetService(ServiceFactoryUse.java:210)
... 41 more
Toute idée pourquoi une telle erreur se produit?
Comment compiler un projet de plug-in Eclipse lorsqu'il fait référence à des packages système supplémentaires à partir de l'application Web sous-jacente?
Y a-t-il une plage de versions dans l'en-tête Import-Package? Si oui, une version correspondant doit être définie dans la propriété system.package.extra. –
Aucune gamme de versions, juste des noms de paquets. Cela aurait été une question facile autrement! – peveuve
Pourriez-vous fournir la pile complète? pourquoi l'exception "Problèmes de compilation non résolus"? –