[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:
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:
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:
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.
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:
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 ...