Announcement Announcement Module
Collapse
No announcement yet.
JPA - Working around a Jboss bug Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JPA - Working around a Jboss bug

    Hi,
    I'm using Spring 2.5.2, Hibernate EM 3.3.1, running on Websphere 6.1. I think I'm running in to this jboss bug: http://jira.jboss.org/jira/browse/JBCOMMON-38

    Since I'm using Websphere 6.1, "WEB-INF/classes/META-INF/persistence.xml" is in a directory with spaces. As a result, PersistenceUnitInfo.getPersistenceUnitRootUrl() ends up with a "%20" in it. (See the debug below to see exactly what PersistenceUnitInfo contains. I think the error is do to the resulting value of persistenceUnitRootUrl.

    Other than installing Websphere to a dir without a space,can anyone suggest a way to avoid this problem? (WAS is enough of a PITA without trying to install it to a non-default location.)

    Thanks very much for any help!

    Here is the error:

    Code:
    [4/8/08 22:52:52:312 CDT] 00000016 SystemOut     O 22:52:52,296  INFO Version:15 - Hibernate EntityManager 3.3.1.GA
    [4/8/08 22:52:52:390 CDT] 00000016 SystemOut     O 22:52:52,390 DEBUG Ejb3Configuration:302 - Processing PersistenceUnitInfo [
    	name: com.myjob.obc.core
    	persistence provider classname: org.hibernate.ejb.HibernatePersistence
    	classloader: 
    com.ibm.ws.classloader.CompoundClassLoader@1ec01ec0
       Local ClassPath: C:\Program Files\IBM\SDP70\runtimes\base_v61\profiles\AppSrv01\installedApps\LHX00CND71506Q9Node01Cell\MyApp-0_0_1_war.ear\MyApp-0.0.1.war\WEB-INF\classes;<lots of jars here>
       Delegation Mode: PARENT_FIRST
    	Temporary classloader: org.springframework.instrument.classloading.SimpleThrowawayClassLoader@66b666b6
    	excludeUnlistedClasses: true
    	JTA datasource: null
    	Non JTA datasource: com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource@83f75dc6
    	Transaction type: JTA
    	PU root URL: file:/C:/Program%20Files/IBM/SDP70/runtimes/base_v61/profiles/AppSrv01/installedApps/LHX00CND71506Q9Node01Cell/MyApp-0_0_1_war.ear/MyApp-0.0.1.war/WEB-INF/classes/
    	Jar files URLs []
    	Managed classes names [
    		com.myjob.obc.core.domain.Member]
    	Mapping files names []
    	Properties []
    [4/8/08 22:52:52:406 CDT] 00000016 SystemOut     O 22:52:52,390 DEBUG Ejb3Configuration:553 - Detect class: true; detect hbm: true
    ...
    [4/8/08 22:52:52:468 CDT] 00000016 SystemOut     O 22:52:52,437 ERROR ContextLoader:214 - Context initialization failed
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0' defined in ServletContext resource [/WEB-INF/spring/jpa-context.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'obcEntityManagerFactory' defined in ServletContext resource [/WEB-INF/spring/jpa-context.xml]: Invocation of init method failed; nested exception is java.lang.RuntimeException: java.util.zip.ZipException: Bad file descriptor C:\Program%20Files\IBM\SDP70\runtimes\base_v61\profiles\AppSrv01\installedApps\LHX00CND71506Q9Node01Cell\MyApp-0_0_1_war.ear\MyApp-0.0.1.war\WEB-INF\classes
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:470)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:404)
    	at java.security.AccessController.doPrivileged(AccessController.java:192)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:375)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:263)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:170)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:260)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:184)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:163)
    	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:881)
    	at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:597)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:366)
    	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:254)
    	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:198)
    	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
    	at 
        ...
    	at com.ibm.wsspi.runtime.component.WsComponentImpl$_AsynchInitializer.run(WsComponentImpl.java:342)
    	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1473)
    Caused by: 
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'obcEntityManagerFactory' defined in ServletContext resource [/WEB-INF/spring/jpa-context.xml]: Invocation of init method failed; nested exception is java.lang.RuntimeException: java.util.zip.ZipException: Bad file descriptor C:\Program%20Files\IBM\SDP70\runtimes\base_v61\profiles\AppSrv01\installedApps\LHX00CND71506Q9Node01Cell\MyApp-0_0_1_war.ear\MyApp-0.0.1.war\WEB-INF\classes
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1302)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:463)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:404)
    	at java.security.AccessController.doPrivileged(AccessController.java:192)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:375)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:263)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:170)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:260)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:184)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:163)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:309)
    	at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:270)
    	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.detectPersistenceExceptionTranslators(PersistenceExceptionTranslationInterceptor.java:122)
    	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.<init>(PersistenceExceptionTranslationInterceptor.java:78)
    	at org.springframework.dao.annotation.PersistenceExceptionTranslationAdvisor.<init>(PersistenceExceptionTranslationAdvisor.java:70)
    	at org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor.setBeanFactory(PersistenceExceptionTranslationPostProcessor.java:97)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1290)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:463)
    	... 31 more
    Caused by: 
    java.lang.RuntimeException: java.util.zip.ZipException: Bad file descriptor C:\Program%20Files\IBM\SDP70\runtimes\base_v61\profiles\AppSrv01\installedApps\LHX00CND71506Q9Node01Cell\MyApp-0_0_1_war.ear\MyApp-0.0.1.war\WEB-INF\classes
    	at org.jboss.util.file.JarArchiveBrowser.<init>(JarArchiveBrowser.java:74)
    	at org.jboss.util.file.FileProtocolArchiveBrowserFactory.create(FileProtocolArchiveBrowserFactory.java:48)
    	at org.jboss.util.file.ArchiveBrowser.getBrowser(ArchiveBrowser.java:64)
    	at org.hibernate.ejb.Ejb3Configuration.scanForXmlFiles(Ejb3Configuration.java:606)
    	at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:351)
    	at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:126)
    	at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:227)
    	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:281)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1333)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1299)
    	... 48 more
    Caused by: 
    java.util.zip.ZipException: Bad file descriptor C:\Program%20Files\IBM\SDP70\runtimes\base_v61\profiles\AppSrv01\installedApps\LHX00CND71506Q9Node01Cell\MyApp-0_0_1_war.ear\MyApp-0.0.1.war\WEB-INF\classes
    	at java.util.zip.ZipFile.open(Native Method)
    	at java.util.zip.ZipFile.<init>(ZipFile.java:238)
    	at java.util.jar.JarFile.<init>(JarFile.java:168)
    	at java.util.jar.JarFile.<init>(JarFile.java:133)
    	at org.jboss.util.file.JarArchiveBrowser.<init>(JarArchiveBrowser.java:69)
    	... 57 more

  • #2
    Here is my spring config:

    Code:
        <!-- JPA EntityManagerFactory -->
        <bean id="obcEntityManagerFactory"
            class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
            <property name="dataSource" ref="obcDataSource" />    
            <property name="persistenceUnitName" value="com.myjob.obc.core"/>
            <property name="jpaVendorAdapter">
                <bean
                    class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">            
                    <property name="database" value="ORACLE" />
                    <property name="generateDdl" value="false" />
                    <property name="showSql" value="true" />
                </bean>
            </property>
            <property name="jpaProperties" ref="obcJpaProps" />
        </bean>
    
        <bean id="obcJpaProps"
            class="org.springframework.beans.factory.config.PropertiesFactoryBean">
            <property name="properties">
                <props>
    
                    <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>              
                    <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
                    <prop key="hibernate.cache.use_second_level_cache">true</prop>
                    <prop key="hibernate.cache.use_query_cache">true</prop>
                    <prop key="hibernate.show_sql">true</prop>
                </props>
            </property>
        </bean>
        
        <bean id="transactionManager" class="org.springframework.transaction.jta.WebSphereUowTransactionManager"/>
    Here is my persistent unit:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence xmlns="http://java.sun.com/xml/ns/persistence"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0"
    	xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
    
        <persistence-unit name="com.myjob.obc.core" transaction-type="JTA">
    
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
    		
    		<class>com.myjob.obc.core.domain.Member</class>
    		
    		<exclude-unlisted-classes>true</exclude-unlisted-classes>		
    	</persistence-unit>
    </persistence>

    Comment


    • #3
      I'm a newbie and don't use your development platform but i think that for the moment perhaps there is a solution:
      while wait an upgrade that fix the problem do you have tried to create a logical link of file of your projects without spaces?

      Note:
      I don't try this solution it's only an idea.
      I hope that this resolve your problem without the necessity of reinstall your environment.

      Comment


      • #4
        We had a similar problem: the program worked fine under WAS 6.1 FP 13 but failed under FP 15.

        The message that we were getting was

        [02/04/08 14:00:29:321 BST] 0000002d SystemOut O 2008-04-02 14:00:
        29,306 [ERROR] ContextLoader.initWebApplicationContext(214) - Context
        initialization failed
        org.springframework.beans.factory.BeanDefinitionSt oreException: Could not resolve bean definition resource pattern [classpath*: spring/applicationContext-*.xml]; nested exception is java.util.zip.ZipException: Bad file descriptor D:\Program%20Files\IBM\WebSphere\AppServer\profiles\AppSrv01\install edApps\Box08Cell01\ArtistOnline.ear\M2ArtistOnline-3.0.war\WEB-INF\lib\M2ArtistCore-3.0.jar

        Note the %20 where a blank should be.

        We found that the recently published interim fix PK64379 '6.1.0.15: ClassLoader.getResource encodes spaces in URLs' ( http://www-1.ibm.com/support/docview...ct180websphere ) fixes it.
        Last edited by RProctor; Apr 22nd, 2008, 11:57 AM. Reason: typo

        Comment


        • #5
          Same problem... but it seems to have been fixed!

          That JBoss bug is causing my JPA tests to fail whenever the project directory contains a space (e.g. "C:\workspace\My Project").

          After searching the Hibernate JIRA, it seems this bug has been fixed (in the Hibernate EntityManager at least) as EJB-333 in 3.3.2.CR1.

          So if you upgrade your project to use that version of hibernate-entitymanager or later, you should be able to have spaces in your paths (yet to test this myself).

          Comment

          Working...
          X