Announcement Announcement Module
Collapse
No announcement yet.
error trying to scan <jar-file>, How to solve it. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • error trying to scan <jar-file>, How to solve it.

    I use two project to develop an Eclipse RCP application. one is the plugin project, which provide business and data management service. the another is a RCP project. The RCP project calls the services provided by the plugin project.

    But when I launch the application, it throws
    Code:
    ...
    java.lang.RuntimeException: error trying to scan <jar-file>: bundleresource://5/
    ...
    The environment: JDK 1.6, Spring 2.5, Hibernate 3.2.1, Eclipse 3.2.1.

    The following are the Spring context file and the stack trace.
    Code:
    
    .......
        <aop:aspectj-autoproxy proxy-target-class="true"/>
        
        <!-- The bean that is responsible for the resolution of the property reference in the file. -->
        <bean id="property" class="com.parallelvisioninc.model.PropertyFileLoader">
            <property name="path" value="parallelvisioninc.properties"/>
        </bean>
    
        <!-- The property definition that will be referenced in the file. -->
        <bean id="property.databaseDialect" class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/>
        <bean id="property.driverClassName" class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/>
        <bean id="property.url"             class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/>
        <bean id="property.username"        class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/>
        <bean id="property.password"        class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/>
        <bean id="property.showsql"         class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/>
    
        <!-- data source must be defined first before reference. -->
        <bean id="localDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
            <property name="driverClassName" ref="property.driverClassName"/>
            <property name="url"      ref="property.url"/>
            <property name="username" ref="property.username"/>
            <property name="password" ref="property.password"/>
         </bean>
    
        <bean id="persistenceUnitManager" class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
               <property name="persistenceXmlLocations">
                  <list>
                    <value>classpath*:META-INF/persistence.xml</value>
                  </list>
               </property>
               <property name="dataSources">
                   <map>
                      <entry key="localDataSource" value-ref="localDataSource"/>
                   </map>
               </property>
         </bean>
    
         <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
            <property name="persistenceUnitManager" ref="persistenceUnitManager"/>
            <property name="persistenceUnitName" value="parallelvisioninc" />
            <property name="jpaVendorAdapter">
               <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                  <!--property name="database" value="HSQL" /-->
                  <property name="database" ref="property.databaseDialect" />
                  <property name="showSql"  ref="property.showsql" />
                  <property name="generateDdl" value="true" />
               </bean>
            </property>
         </bean>
    
        <bean id="entityManager" class="org.springframework.orm.jpa.support.SharedEntityManagerBean">
          <property name="entityManagerFactory" ref="entityManagerFactory"/>
        </bean>
    
        <!-- Transaction manager for a single JPA EntityManagerFactory (alternative to JTA) -->
        <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
            <property name="entityManagerFactory" ref="entityManagerFactory"/>
        </bean>
    
        <tx:annotation-driven transaction-manager="transactionManager"/>
    
        <!-- JPA annotations bean post processor -->
        <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>
    .......
    
    Code:
    
    !MESSAGE Error creating bean with name 'property' defined in class path resource [parallelvisionincContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.config.internalTransactionAdvisor': Cannot create inner bean '(inner bean)' of type [org.springframework.transaction.interceptor.TransactionInterceptor] while setting bean property 'transactionInterceptor'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [parallelvisionincContext.xml]: Cannot resolve reference to bean 'entityManagerFactory' while setting bean property 'entityManagerFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [parallelvisionincContext.xml]: Invocation of init method failed; nested exception is java.lang.RuntimeException: error trying to scan <jar-file>: bundleresource://5/
    !STACK 0
    
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547)
    	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:413)
    	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:76)
    	at com.parallelvisioninc.model.Context.initialize(Context.java:39)
    	at com.parallelvisioninc.model.Context.getContext(Context.java:31)
    	at com.parallelvisioninc.ui.app.ApplicationWorkbenchAdvisor.initialize(ApplicationWorkbenchAdvisor.java:28)
    	at org.eclipse.ui.application.WorkbenchAdvisor.internalBasicInitialize(WorkbenchAdvisor.java:172)
    	at org.eclipse.ui.internal.Workbench.init(Workbench.java:1069)
    	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1847)
    	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:419)
    	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    	at com.parallelvisioninc.ui.app.Application.run(Application.java:18)
    	at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78)
    	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
    	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
    	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
    	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
    	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:597)
    	at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336)
    	at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
    	at org.eclipse.core.launcher.Main.run(Main.java:977)
    	at org.eclipse.core.launcher.Main.main(Main.java:952)
    .....
    

  • #2
    More information from the Eclipse team. This stack trace is omitted in this post. The attached is the full stack trace. Thanks for your help.
    The bottom of the trace gives some important information:

    Caused by: java.lang.RuntimeException: error trying to scan <jar-file>: bundleresource://55/
    at org.hibernate.ejb.Ejb3Configuration.scanForClasses (Ejb3Configuration.java:635)
    at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3 Configuration.java:350)
    at org.hibernate.ejb.HibernatePersistence.createConta inerEntityManagerFactory(HibernatePersistence.java :126)
    at org.springframework.orm.jpa.LocalContainerEntityMa nagerFactoryBean.createNativeEntityManagerFactory( LocalContainerEntityManagerFactoryBean.java:221)
    at org.springframework.orm.jpa.AbstractEntityManagerF actoryBean.afterPropertiesSet(AbstractEntityManage rFactoryBean.java:251)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1390)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1359)
    ... 82 more
    Caused by: java.lang.RuntimeException: Archive browser cannot handle protocol: bundleresource://55/
    at org.jboss.util.file.ArchiveBrowser.getBrowser(Arch iveBrowser.java:93)
    at org.hibernate.ejb.Ejb3Configuration.scanForClasses (Ejb3Configuration.java:626)
    ... 88 more


    It looks like Spring is trying to find a class where the URL associated with the class is one generated by Eclipse. bundleentry: is a scheme used to scan Jar files in Eclipse.

    I don't know anything about Spring, but something is messed up in it's class loading. You might try some Spring newsgroups and given them this stack trace with this explanation.

    Comment


    • #3
      I struggle hardly to want to know if it is a configuration problem, or the issue caused by Spring.

      Now I have additional information:
      (1)Eclipse RCP and Hibernate work well together.
      (2)After modifying org.jboss.util.file.ArchiveBrowser.getBrowser to not throw the RuntimeException, but return a empty collection for its unknown protocol. At the same time configure the annotated classes in persistence.xml (or Hibernate cannot find the entities), my application now runs well.

      Does anyone kindly tell me if I configure Spring or Eclipse incorrectly?

      Thanks in advances!

      Comment


      • #4
        Originally posted by guofeng View Post
        I struggle hardly to want to know if it is a configuration problem, or the issue caused by Spring.

        Now I have additional information:
        (1)Eclipse RCP and Hibernate work well together.
        (2)After modifying org.jboss.util.file.ArchiveBrowser.getBrowser to not throw the RuntimeException, but return a empty collection for its unknown protocol. At the same time configure the annotated classes in persistence.xml (or Hibernate cannot find the entities), my application now runs well.

        Does anyone kindly tell me if I configure Spring or Eclipse incorrectly?

        Thanks in advances!
        It's nothing to do with Spring, seems to be a bug in the Hibernate Entity Manager code not coping with spaces in file names. See here (and it obviously has not been fixed, despite the comment saying it has):

        http://forum.hibernate.org/viewtopic.php?p=2312088

        Comment


        • #5
          For this issue met by me, it is not caused by the white space in the file path (The file path in my test environment has no white space). It is caused by that the ArchiveBrowser.getBrowser() does not understand the "bundleresource:" protocol (it only supports "file" and "jar" protocol in its code) and it thrown the RuntimeException.

          As I mentioned in my last post, if I only use RCP and Hibernate, my application works well. It only occurrs when I integrate Spring's JPA support with Hibernate in RCP. For this reason, I think it might be caused by Spring. I think Spring mgiht change the classloader the application uses (and that might be why I have to configure the annotated classes in persistence.xml, or Hibernate won't find them).

          The following is the code after I made the change to ArchiveBrowser.getBrowser():
          Code:
             public static Iterator getBrowser(URL url, Filter filter)
             {
                ArchiveBrowserFactory factory = (ArchiveBrowserFactory)factoryFinder.get(url.getProtocol());
                //if (factory == null) throw new RuntimeException("Archive browser cannot handle protocol: " + url);
                if (factory == null)
              	  return new ArrayList().iterator() ;
          
                return factory.create(url, filter);
             }
          Thanks for your kind response.

          Comment

          Working...
          X