IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Spring Java Discussion :

[OSGi] error trying to scan <jar-file>: bundleresource://57/


Sujet :

Spring Java

  1. #1
    Membre Expert Avatar de willoi
    Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    1 355
    Détails du profil
    Informations personnelles :
    Âge : 52
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Décembre 2006
    Messages : 1 355
    Par défaut [OSGi] error trying to scan <jar-file>: bundleresource://57/
    Je travaillle sur appllication Eclipse RCP avec Spring , JPA et Hibernate

    J'ai l'erreur suivante losque je lance lle contexte Spring:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    38
    39
    40
    41
    42
    43
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [persistence-context.xml]: Invocation of init method failed; nested exception is java.lang.RuntimeException: error trying to scan <jar-file>: bundleresource://57/
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1362)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:540)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:485)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:169)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:170)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:407)
    	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:735)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:369)
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:122)
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:102)
    	at fr.turbomeca.dsi.gr2.ui.Application.initSpringContext(Application.java:22)
    	at fr.turbomeca.dsi.gr2.ui.Application.start(Application.java:37)
    	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:169)
    	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
    	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
    	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363)
    	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:508)
    	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447)
    	at org.eclipse.equinox.launcher.Main.run(Main.java:1173)
    	at org.eclipse.equinox.launcher.Main.main(Main.java:1148)
    Caused by: java.lang.RuntimeException: error trying to scan <jar-file>: bundleresource://57/
    	at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:619)
    	at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:341)
    	at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:126)
    	at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:221)
    	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:251)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1390)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1359)
    	... 28 more
    Caused by: java.lang.RuntimeException: NOT IMPLEMENTED
    	at org.jboss.util.file.ArchiveBrowser.getBrowser(Unknown Source)
    	at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:610)
    	... 34 more
    Voici comment est executé le classe loader :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    	private static final String[] CONFIG_FILES = { "persistence-context.xml",
    	        "service-context.xml", "security-context.xml" };
     
    	private static ApplicationContext applicationContext;
    	private void initSpringContext() throws Exception {
    		try {
    			applicationContext = new ClassPathXmlApplicationContext(CONFIG_FILES, true);
    		} catch(RuntimeException re) {
    			re.printStackTrace();
    		}
    		System.out.println("Application context : " + applicationContext);
    	}

    Voici le fichier persistence-context.xml :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    <?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:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context"
    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/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
    		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
     
    	<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
     
    		<property name="dataSource" ref="dataSourceOracle" />
    		<property name="persistenceUnitName" value="jpaPU" />
    		<!-- 
    		<property name="loadTimeWeaver">
        		<bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/>
      		</property>
      		-->
    	    <property name="jpaVendorAdapter" ref="jpaVendorAdapterORACLE" />
    	</bean>
     
     	<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>
    <!--  
     
        <bean id="jpaVendorAdapterHSQL" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
        	<property name="database" value="HSQL" />
          	<property name="databasePlatform" value="org.hibernate.dialect.HSQLDialect" />
          	<property name="showSql" value="true" />
          	<property name="generateDdl" value="true" />
        </bean>
    	<bean id="dataSourceHsql" class="org.springframework.jdbc.datasource.DriverManagerDataSource" >
    		<property name="driverClassName" value="org.hsqldb.jdbcDriver" />
    		<property name="url" value="jdbc:hsqldb:file:/eclipse_wrk/turbomeca/database/gr2db" />
    		<property name="username" value="sa" />
    		<property name="password" value="" />
    		<property name="connectionProperties">
    			<props>
    				<prop key="shutdown">true</prop>
    			</props>
    		</property>
    	</bean>
    -->
        <bean id="jpaVendorAdapterORACLE" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
        	<property name="database" value="ORACLE" />
          	<property name="databasePlatform" value="org.hibernate.dialect.Oracle9Dialect" />
          	<property name="showSql" value="true" />
          	<property name="generateDdl" value="true" />
        </bean>
     
     	<bean id="dataSourceOracle" class="org.springframework.jdbc.datasource.DriverManagerDataSource" >
    		<property name="driverClassName" value="oracle.jdbc.OracleDriver" />
    		<property name="url" value="jdbc:oracle:thin:@XXX" />
    		<property name="username" value="XXX" />
    		<property name="password" value="XXX" />
    	</bean>
     
     
    	<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    		<property name="entityManagerFactory" ref="entityManagerFactory" />
    	</bean>
     
    	<tx:annotation-driven />
     
    </beans>
    J'ajoute que quand j'eceute ce class loader hors du projet Eclipse RCP cela fonctionne parfaitement.
    J'ai bien intégré toutes les dépendances, ainsi que le driver Oracle.

  2. #2
    Expert confirmé
    Avatar de djo.mos
    Profil pro
    Inscrit en
    Octobre 2004
    Messages
    4 666
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2004
    Messages : 4 666
    Par défaut
    Bonjour.
    Apparamment, c'est un problème causé par les conventions de nommage d'eclipse RCP des bundles (le préfixe numérique comme //57/, etc.), mais je n'en suis pas sur vu que je n'ai jamais fait d'eclipse RCP.

    Ceci pourrait peut être t'aider:
    http://forum.springframework.org/showthread.php?t=22234

    Bonne chance.

    P.S.: Tu n'as pas besoin d'un load time weaver avec Hibernate.

  3. #3
    Membre Expert Avatar de willoi
    Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    1 355
    Détails du profil
    Informations personnelles :
    Âge : 52
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Décembre 2006
    Messages : 1 355
    Par défaut
    Bon a priori c'est un bug reconnu mais toujours pas solutionné qui empeche de faire fonctionner
    Eclipse RCP +Spring +Jpa +Hibernate
    Car ArchiveBrowser attend un protocole que le bundle eclipse n'est pas capable de lui fournir correctement.

    Nous allons essayer de remplacer Hibernate par TopLink ...

    djo.mos --> P.S.: Tu n'as pas besoin d'un load time weaver avec Hibernate.
    que veux dire cette dernière remarque ?

  4. #4
    Expert confirmé
    Avatar de djo.mos
    Profil pro
    Inscrit en
    Octobre 2004
    Messages
    4 666
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2004
    Messages : 4 666
    Par défaut
    Dans ton fichier de configuration de Spring, tu as déclaré un load time weaver:
    Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    <!-- 
    		<property name="loadTimeWeaver">
        		<bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/>
      		</property>
      		-->

    Mais maintenant que je le dis, je viens de remarquer q'il est commenté

    Donc, en utilisant hibernate comme implémentation JPA, on n'a pas besoin du Load Time Weaver (il ne faut pas déclarer ce bloc dans le ficher de config de spring).
    Par contre, lorsque tu utilises Toplink, il t'en faudra un.

  5. #5
    Membre averti
    Profil pro
    Inscrit en
    Août 2004
    Messages
    35
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Août 2004
    Messages : 35
    Par défaut Resolu pour moi avec hibernate
    En effet le protocole bundleresource n est pas reconnu
    j ai resolu mon probleme en surchargant une classe, c est pas top classe mais ca fonctionne en attendant que le bug soit regle


    donc : New Class -> package = org.jboss.util.file, ClassName = ArchiveBrowser et colle le bout de code ci dessous.

    (tips:sur eclipse 3.3 tu copie le code et colle en cliquant sur le src, ca cree tous seul la classe)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
     
    package org.jboss.util.file;
     
    import java.io.File;
    import java.io.IOException;
    import java.net.JarURLConnection;
    import java.net.URI;
    import java.net.URISyntaxException;
    import java.net.URL;
    import java.util.ArrayList;
    import java.util.Iterator;
     
    import org.eclipse.osgi.framework.internal.core.BundleURLConnection;
     
    public class ArchiveBrowser {
     
    	public interface Filter {
    		boolean accept(String filename);
    	}
     
    	public static Iterator getBrowser(URL url, Filter filter) {
     
    		if (url.getProtocol().startsWith("bundleresource")) {
     
    			BundleURLConnection con;
    			try {
    				con = (BundleURLConnection) url.openConnection();
    				url = con.getFileURL();
    			} catch (IOException e) {
    				e.printStackTrace();
    			}
     
     
    		}
     
    		if (url.getProtocol().equals("file")) {
    			File f = null;
    			try {
    				f = new File(new URI(url.toString()));
    			} catch (URISyntaxException e) {
    				throw new RuntimeException("Not a valid URL: " + url, e);
    			}
    			if (f.isDirectory()) {
    				return new DirectoryArchiveBrowser(f, filter);
    			} else {
    				return new JarArchiveBrowser(f, filter);
    			}
    		} else if (url.getProtocol().startsWith("jar")) {
    			if (url.toString().endsWith("!/")) {
    				try {
    					return new JarArchiveBrowser((JarURLConnection) url
    							.openConnection(), filter);
    				} catch (IOException e) {
    					throw new RuntimeException("Unable to browse url: " + url,
    							e);
    				}
    			} else {
    				try {
    					return new JarStreamBrowser(url.openStream(), filter);
    				} catch (IOException e) {
    					throw new RuntimeException("Unable to browse url: " + url,
    							e);
    				}
    			}
     
    		} else
    			throw new RuntimeException(
    					"Archive browser cannot handle protocol: " + url);
    	}
     
    }

    en creant org.jboss.util.file.ArchiveBrowser on surcharge l api fournit par jboss ....


    enjoy,

    JuJu ...

Discussions similaires

  1. Réponses: 0
    Dernier message: 06/08/2014, 10h58
  2. [Data] error trying to scan <jar-file>
    Par friedman1987 dans le forum Spring
    Réponses: 2
    Dernier message: 15/04/2011, 02h14
  3. problème avec jar file
    Par jayjay.f dans le forum AWT/Swing
    Réponses: 17
    Dernier message: 04/12/2006, 00h40
  4. Comment lire un jar file dans javascript ?
    Par Battosaiii dans le forum Général JavaScript
    Réponses: 4
    Dernier message: 04/10/2006, 13h23
  5. prblème création Jar file
    Par phileme dans le forum Eclipse Java
    Réponses: 2
    Dernier message: 16/06/2006, 21h19

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo