Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Spring Batch Admin UI with Grails?

  1. #1

    Default Spring Batch Admin UI with Grails?

    Hi guys,

    I've been trying to wire up the Batch Admin UI with my Grails app but so far have had limited success.

    We have an Integration/Batch job running in our Grails app. I'd like to see the Batch Admin UI to look at the status and outcomes of the job as they run.

    I've followed the steps outlined here: http://stackoverflow.com/questions/6...ng-application

    When I go to \myapp\batch I get the Batch Admin homepage, but if I click on any of the other links like \jobs\, I get a 404 error and it looks like the Grails application is looking for it in \views\jobs\. Could I use the UrlMappings.groovy file in Grails to fix this, perhaps?

    Below is my configuration, it'd be great if someone could let me know if there is anything wrong with it, or even if it is possible to use this UI in Grails. I'm using the 1.2.2 snapshot version of spring batch admin manager since I was already using spring integration 2.1.

    Thanks,
    Tony


    web.xml (generated by the Grails command for install-templates)

    Code:
    <servlet>
            <servlet-name>Batch Servlet</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <init-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>classpath*:/org/springframework/batch/admin/web/resources/servlet-config.xml,classpath*:/org/springframework/batch/admin/web/resources/webapp-config.xml</param-value>
            </init-param>
            <load-on-startup>1</load-on-startup>
    </servlet>
    
    <servlet-mapping>
    	<servlet-name>Batch Servlet</servlet-name>
    	<url-pattern>/batch/*</url-pattern>
    </servlet-mapping>
    applicationContext.xml

    Code:
    <bean id="resourceService" class="org.springframework.batch.admin.web.resources.DefaultResourceService">
    	   <property name="servletPath" value="/batch" />
    </bean>

  2. #2

    Default

    Quick update: If I navigate directly (type it in the URL bar) to myapp/batch/jobs/1 (i.e. if I give it an index) it will show a plain text page saying

    "There is no such job (1) "

    And give a few other Spring links, but the page has no formatting or styling whatsoever. Same is true if I navigate to myapp/jobs/executions/1

    This actually does show details of the job (so that is good news I suppose!), but again, there is no styling on the page, just plain text.

    Any ideas on how I can get the links working, and the styling working?

    Thanks,
    Tony

  3. #3

    Default

    So looking at the html source, it seems the links in the Batch Admin pages are all pointing at /myapp/<spring batch admin page> or /myapp/resources/styles/<various spring batch admin css files> whereas it should be pointing at /myapp/batch/<spring batch admin page> or /myapp/batch/resources/styles/<various spring batch admin css files>

    How do these links get generated? It looks like everywhere they use the "myapp" variable, I have to replace it with "myapp/batch" and I'll be good to go. Anyone know where this is read in from?

    Cheers,
    Tony

  4. #4

    Default

    Judging by the silence I'm going to take it that this can't work with Grails, and that the page's links are hard-coded or something. If any Spring people are viewing this thread, it'd be a nice integration/feature if you could get it working with Grails.

    Cheers,
    Tony

  5. #5
    Join Date
    Sep 2008
    Location
    Chicagoland, IL
    Posts
    351

    Default

    The URLs are generated prefixed with the "servletPath". That servlet path can be configured via the DefaultResourceService. By default, that prefix should be empty. You can override it per the override instructions http://static.springsource.org/sprin...g-started.html (Overriding Components from Spring Batch Admin). You should be able to configure your own DefaultResourceService and inject the context you want.
    Michael Minella
    Spring Batch Lead
    Author - Pro Spring Batch
    http://www.michaelminella.com
    Twitter: @MichaelMinella

  6. #6

    Default

    Thanks for the reply mminella, I'll give this a try and hopefully it'll sort out my issue.

    I haven't any files in the META-INF folder yet, they are all stored in my Grails conf/spring folder, so should I stick with the directions above and use the META-INF, or will I create a folder called conf/spring/override within grails-app?

    Thanks again for your help,
    Tony

  7. #7
    Join Date
    Sep 2008
    Location
    Chicagoland, IL
    Posts
    351

    Default

    In order for admin to pick up your override configuration, the file must be at that path.
    Michael Minella
    Spring Batch Lead
    Author - Pro Spring Batch
    http://www.michaelminella.com
    Twitter: @MichaelMinella

  8. #8

    Default

    Hi mminella,

    I did what you suggested and moved the declaration of the DefaultResourceService bean from my spring xml file in conf/spring to a file called override-context.xml in META-INF/spring/batch/override but it had no affect.

    The URLs in the source of the pages generated are still looking for resources at /myapp/whatever instead of /myapp/batch/whatever. Below is my entire override-context.xml file.

    Have you any idea why this file isn't being picked up?

    Many Thanks,
    Tony

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
       "http://www.springframework.org/dtd/spring-beans.dtd">
    
    <beans>
    	<bean id="resourceService" class="org.springframework.batch.admin.web.resources.DefaultResourceService">
    	    <property name="servletPath" value="/batch" />
    	</bean>
    </beans>

  9. #9

    Default

    So a work-around here is to make a META-INF/spring/batch/override/ folder structure underneath the conf section in your Grails project. If you put the override context in here it picks it up!

    All the job and execution pages are now visible correctly, which is great.

    The one outstanding piece is the links on the very top menu, the links labeled "Home", "Jobs", "Executions", and "Files" are still not working correctly.

    Looking at the page source, I can see they are pointing at:

    Code:
    <li><a href="/myapp/batch">Home</a></li>
    <li><a href="/myapp/batch/jobs">Jobs</a></li>
    <li><a href="/myapp/batch/jobs/executions">Executions</a></li>
    <li><a href="/myapp/batch/files">Files</a></li>
    Which I would have thought is correct, but clicking on, for instance the "Jobs" link gives me a 404:

    HTTP Status 404 - /myapp/WEB-INF/grails-app/views/jobs.jsp

    So it still looks like for some pages, Grails is tryingto take over and look for a jobs page in Views. Which is strange because I have my servlet mapping set to the following in my web.xml:

    Code:
    <servlet-mapping>
    	<servlet-name>Batch Servlet</servlet-name>
    	<url-pattern>/batch/*</url-pattern>
    </servlet-mapping>
    Any advice would be great. I'll keep updating if I find out more.

    Cheers,
    Tony

  10. #10
    Join Date
    Sep 2008
    Location
    Chicagoland, IL
    Posts
    351

    Default

    What is the servlet mapping for the grails servlet? It's been a while since I played with this type of thing but I'm wondering if it's more broadly mapped so the request is going there instead. Just brainstorming...
    Michael Minella
    Spring Batch Lead
    Author - Pro Spring Batch
    http://www.michaelminella.com
    Twitter: @MichaelMinella

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •