Announcement Announcement Module
Collapse
No announcement yet.
Spring Roo and JBoss Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Roo and JBoss

    I am building an application using Spring roo which deploys perfectly to Tomcat, but I also have a requirement to deploy it to JBoss. After battling through some issues with the persistence.xml file being loaded by JBoss I have gotten things to load without errors, but now when trying to access the normal roo generated JSPs all of my entities throw an error saying:

    Code:
    16:37:22,546 ERROR [STDERR] java.lang.IllegalArgumentException: org.hibernate.hq
    l.ast.QuerySyntaxException: Predicate is not mapped [select o from Predicate o]
    16:37:22,546 ERROR [STDERR]     at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:601)
    16:37:22,546 ERROR [STDERR]     at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:96)
    16:37:22,546 ERROR [STDERR]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    16:37:22,546 ERROR [STDERR]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    16:37:22,546 ERROR [STDERR]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    16:37:22,546 ERROR [STDERR]     at java.lang.reflect.Method.invoke(Method.java:597)
    16:37:22,546 ERROR [STDERR]     at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:365)
    16:37:22,546 ERROR [STDERR]     at $Proxy438.createQuery(Unknown Source)
    16:37:22,546 ERROR [STDERR]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    ...truncated...
    What could be causing this?
    Last edited by jej2003; Nov 2nd, 2009, 05:00 PM.

  • #2
    I have not tested the application on JBoss app server recently but given that Roo applications are just standard Spring + JPA applications I am a little baffled that this does not work out of the box (especially when using Hibernate).

    The exception you are seeing indicates that the Entity manager is not available in the view. We use the OpenEntityManagerInViewFilter to do this (look into web.xml). Maybe there is an issue there?

    -Stefan

    Comment


    • #3
      Thanks for the reply, but I have the OpenEntityManagerInViewFilter defined in my web.xml

      Code:
          <filter>
              <filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
              <filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
          </filter>
          <filter-mapping>
              <filter-name>springSecurityFilterChain</filter-name>
              <url-pattern>/*</url-pattern>
          </filter-mapping>
      
      	<filter-mapping>
              <filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
              <url-pattern>/*</url-pattern>
          </filter-mapping>
      this is baffling to me as well, as it works fine in Tomcat. The only modification I had to get this to run in JBoss was to use JBoss' classloader isolation and rename my persistence.xml to persistence-spring.xml and modify my applicationContext.xml to reflect the change
      Code:
      <property name="persistenceXmlLocation" value="classpath*:META-INF/persistence-spring.xml"/>
      Any other thoughts?

      Comment


      • #4
        hmm...at first look it seems the classloader isolation may not be working. I just tried to remove the hibernate annotation jars which are in jboss/common so it would use the jars that are present in my war and it threw an exception saying it could not find one of the hibernate classes (which is in the jar deployed with the application). Perhaps I am going about this the wrong way, what is the process for deploying to JBoss?

        Comment


        • #5
          I just created the sample RSVP Wedding application on the Getting Started with Roo page and have the same issue there...

          Code:
          org.hibernate.hql.ast.QuerySyntaxException: Rsvp is not mapped [select o from Rsvp o]
          org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:601)
          org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:96)
          sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          java.lang.reflect.Method.invoke(Method.java:597)
          org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:365)
          $Proxy140.createQuery(Unknown Source)
          sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          java.lang.reflect.Method.invoke(Method.java:597)
          org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:224)
          $Proxy148.createQuery(Unknown Source)
          com.wedding.domain.Rsvp_Roo_Entity.ajc$interMethod$com_wedding_domain_Rsvp_Roo_Entity$com_wedding_domain_Rsvp$findRsvpEntries(Rsvp_Roo_Entity.aj:97)
          com.wedding.domain.Rsvp.findRsvpEntries(Rsvp.java:1)
          com.wedding.domain.Rsvp_Roo_Entity.ajc$interMethodDispatch1$com_wedding_domain_Rsvp_Roo_Entity$com_wedding_domain_Rsvp$findRsvpEntries(Rsvp_Roo_Entity.aj)
          com.wedding.web.RsvpController_Roo_Controller.ajc$interMethod$com_wedding_web_RsvpController_Roo_Controller$com_wedding_web_RsvpController$list(RsvpController_Roo_Controller.aj:52)
          com.wedding.web.RsvpController.list(RsvpController.java:1)
          sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          java.lang.reflect.Method.invoke(Method.java:597)
          org.springframework.web.bind.annotation.support.HandlerMethodInvoker.doInvokeMethod(HandlerMethodInvoker.java:654)
          org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:160)
          org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:378)
          org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:366)
          org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:781)
          org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:726)
          org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:636)
          org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:545)
          javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
          javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
          org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
          org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:638)
          org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:444)
          org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:382)
          org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:310)
          org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl.doRewrite(NormalRewrittenUrl.java:195)
          org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:159)
          org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:141)
          org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:90)
          org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:417)
          org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
          org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:71)
          org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
          org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
          org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
          org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
          org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
          org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          org.springframework.web.filter.ShallowEtagHeaderFilter.doFilterInternal(ShallowEtagHeaderFilter.java:57)
          org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
          org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
          org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
          org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
          org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
          org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
          org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
          org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
          org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
          org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
          org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
          org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
          org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
          org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
          org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
          org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
          org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
          org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
          org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
          org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
          org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
          java.lang.Thread.run(Thread.java:619)
          There has to be something fundamental that I am messing up here.... Is there any place in specific that I should be digging to get more information?

          Comment


          • #6
            so a workaround....

            for some reason in tomcat everything works, but in JBoss I have to explicitly list all of the classes that I want scanned for annotations via the class tag in my persistence.xml file. I would still be interested to know why this is....

            Comment

            Working...
            X