Announcement Announcement Module
Collapse
No announcement yet.
Roo Solr Addon Problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Roo Solr Addon Problem

    Hello all,
    This is my first Project working with Roo. I am trying to perform a simple integration with Apache Solr to index my data. I'm using the solr addon that comes packaged with Roo, and I've been following the documentation as listed on the Spring Roo documentation pages. I've stripped down my code at a very simple example, but I'm unable to get a simple example working.

    Here are my versions:

    Code:
        <properties>
            <aspectj.version>1.6.12</aspectj.version>
            <java.version>1.6</java.version>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <roo.version>1.2.1.RELEASE</roo.version>
            <slf4j.version>1.6.4</slf4j.version>
            <spring.version>3.1.0.RELEASE</spring.version>
        </properties>

    I've created a simple domain object that I want to add to the SOLR index:

    Code:
    @RooJavaBean
    @RooToString
    @RooJpaActiveRecord
    @RooSolrSearchable
    public class MyObject {
    
        private String name;
    
        private String description;
    
        private String example;
    
        @Temporal(TemporalType.TIMESTAMP)
        @DateTimeFormat(style = "M-")
        private Date birthday;
    
        private Boolean valid;
    }
    Roo creates the MyObject_Roo_SolrSearch.aj ITD just fine. However when I run the application, I get an exception when trying to create a new MyObject instance...

    Code:
    Internal Error
    
    Sorry, we encountered an internal error.
    
    Details
    
    Post-processor tried to replace bean instance of type [com.myapp.test.domain.MyObject] with (proxy) object of type [$Proxy42] - not supported for aspect-configured classes!
    org.springframework.beans.factory.wiring.BeanConfigurerSupport.checkExposedObject(BeanConfigurerSupport.java:170)
    org.springframework.beans.factory.wiring.BeanConfigurerSupport.configureBean(BeanConfigurerSupport.java:142)
    org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect.configureBean(AnnotationBeanConfigurerAspect.aj:59)
    org.springframework.beans.factory.aspectj.AbstractDependencyInjectionAspect.ajc$afterReturning$org_springframework_beans_factory_aspectj_AbstractDependencyInjectionAspect$2$1ea6722c(AbstractDependencyInjectionAspect.aj:89)
    com.myapp.test.domain.MyObject.<init>(MyObject.java:16)
    com.myapp.test.web.MyObjectController_Roo_Controller.ajc$interMethod$com_myapp_test_web_MyObjectController_Roo_Controller$com_myapp_test_web_MyObjectController$createForm(MyObjectController_Roo_Controller.aj:37)
    com.myapp.test.web.MyObjectController.createForm(MyObjectController.java:1)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    java.lang.reflect.Method.invoke(Unknown Source)
    org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:212)
    org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
    org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
    org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:900)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:827)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:147)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    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:243)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928)
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
    org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539)
    org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:300)
    java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    java.lang.Thread.run(Unknown Source)
    I looked into the exception a little and found this link: http://olafsblog.sysbsb.de/why-confi...he-same-class/ It appears that there is some type of conflict between the @Configurable and the @Transaction annotations. Does this also apply to the @Async annotations.

    When I move the indexMyObjects(Collection<MyObject> myobjects) and the deleteIndex(MyObject myObject) methods into my domain object and remove the @Async annotation, everything works fine. (Except for the fact that the SOLR indexing is now done in the same request thread.) I would like to know why the @Async annotation on the method doesn't seem to work correct?

  • #2
    Hi

    Although I don't have a great deal to add I thought I would comment on my experience - more to see if there are other people with experience of Solr with Roo that might be able to shed more light on things.

    As chrisharm found the default aspect generated by Roo fails and the @Async is the cause. It seems reasonable there would be problems - I'm not sure what the @Async annotation does but you would assume it inserts a proxy that creates a new thread to execute the required logic in the background. Combining that with an Aspect and weaving it all together doesn't sound easy.

    My question would be why does Spring Roo try and create this at all? It would seem that a better pattern might be to create a service or Helper class that supported the Aysnc methods to index the entity objects. Adding more and more functionality to the ActiveRecord entities seems to break a few general design rules such as single responsibility. And as it doesn't if run...

    Comment


    • #3
      Link to JIRA issue ROO-3079 - does not seem to be fixed

      https://jira.springsource.org/browse/ROO-3079

      Looking at this issue the bug seems to have been 'fixed'. It certainly doesn't work for me although I am running against Spring 3.2.0 and the issue describes (and may have been tested) against 3.0.5.

      I can see that it is neat to use the @PostUpdate and other annotations to manage the index, something that could be easily overlooked. However the main index method would almost always be overridden you would think, especially as it indexes all strings as string not text, which defeats the purpose somewhat.

      It has been really useful to very quickly get a search working with Solr - I'm just not sure how useful the code produces by Roo is.

      Anyone on the Roo team - have there been other thoughts about this?

      Chris
      Last edited by cdmein; Jul 18th, 2013, 11:00 PM.

      Comment

      Working...
      X