Announcement Announcement Module
Collapse
No announcement yet.
Spring 2.5.5 JBoss 4.2.2 Hibernate-Annotations (Urgent !) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring 2.5.5 JBoss 4.2.2 Hibernate-Annotations (Urgent !)

    Hello Spring-Freaks,

    I have a problem that occured after updating my hibernate libraries and I do not how to solve that problems. Before the update ofHibernate-Annotations up to 3.3.x und Spring up to 2.5.5it all worked well (before Spring 2.0.8)
    Any help would be appreciated.

    The Error-Message I see starting JBoss (4.2.2) says, that my DataSource PostgresDS
    cannot be found by JDNI but JBoss says that the Datasource was bound.

    Used libraries (as far as Spring and Hibernate are concerned):
    spring-2.5.5.jar
    spring-core-2.5.5.jar
    spring-beans-2.5.3.jar
    spring-context-2.5.3.jar
    spring-web-2.5.5.jar
    hibernate-3.2.6.ga.jar
    hibernate-annotations-3.3.1.GA.jar
    hibernate-commons-annotations-3.3.0.ga.jar
    hibernate-entitymanager-3.3.1.ga.jar
    hibernate-validator-3.0.0.ga.jar
    persistence-api-1.0.jar
    ejb3-persistence-1.0.1.GA.jar

    The JBoss-Output (shortened):

    14:51:57,129 INFO [Server] Starting JBoss (MX MicroKernel)...
    [...]
    14:52:22,571 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=DefaultD S' to JNDI name 'javaefaultDS'
    [...]
    14:52:23,664 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=ConnectionFactoryBinding,name=J msXA' to JNDI name 'java:JmsXA'
    14:52:23,763 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=Postgres DS' to JNDI name 'java:PostgresDS'
    [...]
    14:52:31,313 INFO [STDOUT] 2008-09-21 14:52:31,311 DEBUG (org.springframework.beans.factory.support.Default ListableBeanFactory:447) - Retrieved dependent beans for bean 'org.springframework.transaction.annotation.Annota tionTransactionAttributeSource#0': [org.springframework.transaction.config.internalTra nsactionAdvisor]
    14:52:31,330 INFO [STDOUT] 2008-09-21 14:52:31,317 ERROR (org.springframework.web.context.ContextLoader:215 ) - Context initialization failed
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'personService': Injection of persistence methods failed; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.springframework.jdbc.datasource.lookup.DataSou rceLookupFailureException: Failed to look up JNDI DataSource with name 'java:/PostgresDS'; nested exception is javax.naming.NameNotFoundException: JNDI object with [java:/PostgresDS] not found: JNDI implementation returned null

    at org.springframework.orm.jpa.support.PersistenceAnn otationBeanPostProcessor.postProcessPropertyValues (PersistenceAnnotationBeanPostProcessor.java:324)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:998)
    [ ... ]
    Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.springframework.jdbc.datasource.lookup.DataSou rceLookupFailureException: Failed to look up JNDI DataSource with name 'java:/PostgresDS'; nested exception is javax.naming.NameNotFoundException: JNDI object with [java:/PostgresDS] not found: JNDI implementation returned null
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1337)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:473)
    [...]
    Caused by: org.springframework.jdbc.datasource.lookup.DataSou rceLookupFailureException: Failed to look up JNDI DataSource with name 'java:/PostgresDS'; nested exception is javax.naming.NameNotFoundException: JNDI object with [java:/PostgresDS] not found: JNDI implementation returned null
    at org.springframework.jdbc.datasource.lookup.JndiDat aSourceLookup.getDataSource(JndiDataSourceLookup.j ava:47)
    at org.springframework.orm.jpa.persistenceunit.Persis tenceUnitReader.parsePersistenceUnitInfo(Persisten ceUnitReader.java:282)
    ...

    My persistence.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence xmlns="..." version="1.0">
    <persistence-unit name="HouseMan" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence </provider>
    <!-- <non-jta-data-source>java:/PostgresDS</non-jta-data-source> -->
    <jta-data-source>java:/PostgresDS</jta-data-source>
    <class>net.magiccode.houseman.model.User</class>
    <class>net.magiccode.houseman.model.Right</class>
    <class>net.magiccode.houseman.model.UserGroup</class>
    <class>net.magiccode.houseman.model.BankAccount</class>
    <class>net.magiccode.houseman.model.Person</class>
    <class>net.magiccode.houseman.model.Address</class>
    <class>net.magiccode.houseman.model.RentalObject </class>
    <class>net.magiccode.houseman.i18n.Language</class>
    <class>net.magiccode.houseman.i18n.I18nText</class>
    <class>net.magiccode.houseman.i18n.MultiLingualTex t</class>
    <class>net.magiccode.houseman.i18n.LanguageFactory </class>
    <properties>
    <property name="jboss.entity.manager.factory.jndi.name" value="persistence-units/JpaPersistence"/>
    <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
    <property name="hibernate.show_sql" value="true" />
    <property name="hibernate.format_sql" value="true" />
    <property name="hibernate.connection.driver_class" value="org.postgresql.Driver" />
    <property name="hibernate.connection.url" value="jdbcostgresql://localhost:5432/houseman" />
    <property name="hibernate.connection.username" value="volker" />
    <property name="hibernate.connection.password" value="abulafia" />
    <property name="hibernate.archive.autodetection" value="class" />
    <property name="hibernate.default_schema" value="public" />
    <property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.DefaultComponentSafeNamin gStrategy"/>
    <property name="hibernate.archive.autodetection" value="class"/>
    <property name="hibernate.hbm2ddl.auto" value="read-write" />
    <property name="hibernate.hbm2ddl.auto" value="update" />
    </properties>
    </persistence-unit>
    </persistence>


    My applicationContext.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="...schema/beans"
    xmlns:xsi="..."
    xmlns:aop="..."
    xmlns:tx="..."
    xsi:schemaLocation="...">
    <bean class="org.springframework.orm.jpa.support.Persist enceAnnotationBeanPostProcessor" />
    <bean id="personService" class="net.magiccode.houseman.service.PersonServic eImpl" />
    <bean id="userService" class="net.magiccode.houseman.service.UserServiceI mpl" />
    <bean id="rightService" class="net.magiccode.houseman.service.RightService Impl" />
    <bean id="groupService" class="net.magiccode.houseman.service.GroupService Impl" />
    <bean id="languageService" class="net.magiccode.houseman.service.LanguageServ iceImpl" />
    <bean id="i18nTextService" class="net.magiccode.houseman.service.I18nTextServ iceImpl" />

    <bean id="RentalObjectService" class="net.magiccode.houseman.service.RentalObject ServiceImpl" />
    <bean id="LanguageFactory" class="net.magiccode.houseman.i18n.LanguageFactory " />

    <bean id="personAction" scope="prototype"
    class="net.magiccode.houseman.action.PersonAction" >
    <constructor-arg ref="personService" />
    </bean>
    <bean id="languageAction" scope="prototype"
    class="net.magiccode.houseman.action.LanguageActio n">
    <constructor-arg ref="languageService" />
    </bean>
    <bean id="userAction" scope="prototype"
    class="net.magiccode.houseman.action.UserAction">
    <constructor-arg ref="userService" />
    </bean>
    <bean id="rightsAction" scope="prototype"
    class="net.magiccode.houseman.action.RightsAction" >
    <constructor-arg ref="rightService" />
    </bean>
    <bean id="groupAction" scope="prototype"
    class="net.magiccode.houseman.action.GroupAction">
    <constructor-arg ref="groupService" />
    </bean>


    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerE ntityManagerFactoryBean">
    <property name="persistenceUnitName" value="HouseMan" />
    <property name="jpaProperties">
    <props>
    <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.a uto}</prop>
    </props>
    </property>
    <property name="jpaVendorAdapter">
    <bean
    class="org.springframework.orm.jpa.vendor.Hibernat eJpaVendorAdapter">
    <property name="database" value="POSTGRESQL" />
    <property name="showSql" value="true" />
    <property name="generateDdl" value="true" />
    </bean>
    </property>
    </bean>
    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionM anager">
    <property name="entityManagerFactory" ref="entityManagerFactory" />
    </bean>
    <bean id="dataSource"
    class="org.springframework.jdbc.datasource.DriverM anagerDataSource">
    <property name="driverClassName" value="org.postgresql.Driver" />
    <property name="url" value="jdbcostgresql://localhost/houseman" />
    <property name="username" value="volker" />
    <property name="password" value="abulafia" />
    </bean>
    <tx:annotation-driven transaction-manager="transactionManager" />
    </beans>

  • #2
    Please use the code tags when you post your configuration files....

    Why do you have a JNDI datasource in one place and a driver manager datasource for your entity manager?

    Comment


    • #3
      Solved

      Thanks for pushing my nose on that. Haven't seen it though watching the code for hours.....
      Sometimes it's better to make a break..

      Comment

      Working...
      X