[Plugin] Erreur ClassNotFoundException
Bonjour tout le monde,
Je développe actuellement un plugin Eclipse qui met en oeuvre un client REST, permettant de télécharger des fichiers de configuration (.xml).
J'ai dans un premier temps écrit mon client REST dans un main. J'ai lancé plusieurs fois ce programme et pas de souci, je récupère mes données dans un dossier zippé.
J'ai ensuite supprimé ma méthode main et mis le code de mon client REST, dans une méthode downloadData() (toujours dans la même classe).
Lorsque je lance mon projet plugin en Eclipse application, je lance mon IHM (contenant 2 boutons - 1 pour fermer la fenêtre, l'autre pour lancer le programme) je récupère quelques erreurs que je ne comprends absolument pas.
Pour commencer, voici le code de mon client REST (j'ai volontairement enlevé l'URL du service REST pour le post):
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| package clientrest;
import java.io.File;
import javax.ws.rs.core.MediaType;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
public class ClientRest {
public static void downloadData(){
try{
Client client = Client.create();
WebResource webResource = client.resource("URL DU REST SERVICE");
ClientResponse response = webResource.type(MediaType.APPLICATION_OCTET_STREAM).get(ClientResponse.class);
if (response.getStatus() != 200) {
throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
}
File output = response.getEntity(File.class);
output.renameTo(new File("d:\\Profiles\\mra\\Desktop\\TestRCP\\conf.zip"));
System.out.println(output.getPath());
System.out.println("Output from Server .... \n");
} catch(Exception e) {
e.printStackTrace();
}
}
} |
Voici une partie de mon code d'IHM:
Code:
1 2 3 4 5 6 7
| btnLaunch.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
progressBar.setVisible(true);
ClientRest.downloadData();
dispose();
}
}); |
Et enfin l'erreur que je récupère:
Citation:
Exception in thread "AWT-EventQueue-0" java.lang.ExceptionInInitializerError
at com.sun.jersey.api.client.PartialRequestBuilder.type(PartialRequestBuilder.java:92)
at com.sun.jersey.api.client.WebResource.type(WebResource.java:349)
at clientrest.ClientRest.downloadData(ClientRest.java:29)
at eclipsercp.editeurxml.menubarre.ihm.InterfaceDeLancement$2.actionPerformed(InterfaceDeLancement.java:149)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6525)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6290)
at java.awt.Container.processEvent(Container.java:2234)
at java.awt.Component.dispatchEventImpl(Component.java:4881)
at java.awt.Container.dispatchEventImpl(Container.java:2292)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4533)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
at java.awt.Container.dispatchEventImpl(Container.java:2278)
at java.awt.Window.dispatchEventImpl(Window.java:2750)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: com.sun.ws.rs.ext.RuntimeDelegateImpl cannot be found by javax.ws.rs.jsr311-api_1.1.1
at javax.ws.rs.ext.RuntimeDelegate.findDelegate(RuntimeDelegate.java:122)
at javax.ws.rs.ext.RuntimeDelegate.getInstance(RuntimeDelegate.java:91)
at javax.ws.rs.core.MediaType.<clinit>(MediaType.java:44)
... 40 more
Caused by: java.lang.ClassNotFoundException: com.sun.ws.rs.ext.RuntimeDelegateImpl cannot be found by javax.ws.rs.jsr311-api_1.1.1
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:439)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:352)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:344)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at javax.ws.rs.ext.FactoryFinder.newInstance(FactoryFinder.java:62)
at javax.ws.rs.ext.FactoryFinder.find(FactoryFinder.java:155)
at javax.ws.rs.ext.RuntimeDelegate.findDelegate(RuntimeDelegate.java:105)
... 42 more
Mon plugin contient les dependencies suivantes:
Citation:
org.eclipse.ui
org.eclipse.core.runtime
org.eclipse.jdt.core(3.11.2)
org.eclipse.jdt.launching(3.8.0)
org.eclipse.core.resources(3.10.1)
org.apache.commins.loggins(1.1.1)
ch.qos.logback.classic(1.0.7)
javax.servlet(3.1.0)
com.sun.jersey.client(1.19.0)
com.sun.jersey.servlet(1.19.0)
Je précise aussi que com.sun.jersey.client(1.19.0) contient bien javax.ws.rs.jsr211-api(1.1.1) (tout comme com.sun.jersey.servlet(1.19.0)) je ne l'ai donc pas ajouté dans les dependencies.
Je ne comprends rien à cette erreur. Pourquoi lorsque je le lance dans un main cela fonctionne et pas lorsque je lance mon plugin dans un Eclipse ? Manquerait-il des jar ?
Bref, je ne sais pas de quel coté chercher.
Merci d'avance pour votre aide.