Announcement Announcement Module
Collapse
No announcement yet.
Roo example doenst work for me (NoSuchBeanDefinitionException but it is defined) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Roo example doenst work for me (NoSuchBeanDefinitionException but it is defined)

    Hi,

    I tried today to make my own Spring Roo Project based on the Tutorial i found here.

    The spring roo part ( creating the project, defining entites and attributes and controllers) was easily and quickly done.
    But then i tried to deploy it on my tc Server and got the following exception:

    Code:
    org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'entityManagerFactory' is defined
            at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:504)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1041)
            at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:273)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
            at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1008)
            at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.lookupEntityManagerFactory(OpenEntityManagerInViewFilter.java:151)
            at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.lookupEntityManagerFactory(OpenEntityManagerInViewFilter.java:135)
            at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:94)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
            at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
            at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
            at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
            at java.lang.Thread.run(Thread.java:619)
    But the EntityManagerFactoryBean is defined in the generated applicationContext.xml which is in src/main/resources/META-INF/spring

    Code:
    <beans>
    ...
    	<bean class="org.apache.commons.dbcp.BasicDataSource"
    		destroy-method="close" id="dataSource">
    		<property name="driverClassName" value="${database.driverClassName}" />
    		<property name="url" value="${database.url}" />
    		<property name="username" value="${database.username}" />
    		<property name="password" value="${database.password}" />
    	</bean>
    	<bean class="org.springframework.orm.jpa.JpaTransactionManager"
    		id="transactionManager">
    		<property name="entityManagerFactory" ref="entityManagerFactory" />
    	</bean>
    	<tx:annotation-driven mode="aspectj"
    		transaction-manager="transactionManager" />
    	<bean
    		class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
    		id="entityManagerFactory">
    		<property name="dataSource" ref="dataSource" />
    	</bean>
    
    
    ...
    </beans>
    The Idea that I have right now is that maybe this file isnt taken into account but because everything was generated through roo I think this just can't be the cause.


    Does anyone has an idea why the entityManagerFactory bean can not be found?

    I would appreciate every help!

    Thanks in advance

    Greetz
    ccamr

  • #2
    Have you done manually changes in Java or XML files, before you tried to deploy it? Or is it really just a Roo generated project?

    Could you please paste the content of your roo.log or even better, could you attach a backup of your project (I really like the backup feature, so helpful in these kind of scenarios). It is in chapter 2.13. if you have not yet read so far just look it up.

    Regards
    Nils

    Comment


    • #3
      Hi,

      no i didn't change anything its what Roo produced what causes the error.

      my log file contains the following:

      Code:
      // Spring Roo 1.0.2.RELEASE [rev 638] log opened at 2010-05-13 18:29:01
      project --topLevelPackage de.cmr.test --projectName test --java 6
      // Spring Roo 1.0.2.RELEASE [rev 638] log closed at 2010-05-13 18:29:01
      // Spring Roo 1.0.2.RELEASE [rev 638] log opened at 2010-05-13 18:29:04
      hint
      persistence setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY 
      // [failed] entity --class ~.domain.Test
      entity --class ~.domain.moep
      field number --fieldName id --type java.lang.Long
      field string --fieldName name
      hint
      hint controllers
      controller all --package ~.web
      hint
      // Spring Roo 1.0.2.RELEASE [rev 638] log closed at 2010-05-13 19:50:33
      // Spring Roo 1.0.2.RELEASE [rev 638] log opened at 2010-05-13 20:14:10
      backup
      And the backup is attached.

      Maybe you can find what i'm missing.

      Greets
      ccamr

      Comment


      • #4
        Hi,

        so I used to run your project from the backup, as well as created a new one from your script. Interesting thing is, both projects work on tc-server (in STS) if and only if I use mvn eclipse:eclipse and then import the project into STS as an existing project.

        If I import the project to eclipse as an existing maven project and try to run it on tc-server, I do get the same errors as you. In my case there are problems with the project import from maven (as my STS is not set up correctly). In the console tabs, there is one console for Maven, that one contains a whole bunch of messages that dependencies can not be resolved and that a proper compile (including aspect weaving) is not possible. It is very likely that this causes the problems with the entityManager later.

        Which way of project import into STS did you use? And could you check if you have the same problems with your embedded Maven in STS. If so, I would suggest you to do one of the following:
        • set up your STS/embedde Maven correctly (in my case the problem is, that STS points to a JRE not a JDK, and that results in some problems for Maven)
        • Use mvn eclipse:eclipse and import the then existing project into eclipse
        • Package your project from command line and run it on a different server (mvn package jetty:run)

        I hope this helps you so far.
        Regards Nils

        Comment


        • #5
          This really helped thank you its seems that the maven integration caused the error.

          But this behaviour is certainly not intended or is it?

          Thanks!

          Greets
          ccamr

          Comment

          Working...
          X