Results 1 to 5 of 5

Thread: Factory method constructor args when using batch namespace

  1. #1
    Join Date
    Feb 2010
    Posts
    3

    Default Factory method constructor args when using batch namespace

    I'm having some difficulty configuring a bean to use a static factory method with arguments when using the Batch namespace.

    Here's my bean config:

    Code:
    	<beans:bean id="fileResource" class="com.foo.fileResourceFactory" 
    			factory-method="createOutputFile">  
    		<beans:constructor-arg type="java.util.Date" value="#{jobParameters[END_DATE]}" />
    		<beans:constructor-arg value="target/output/" />
    	</beans:bean>
    When I'm attempting to run this, I receive a BeanCreationException, with the description "No matching factory method found: createOutputFile".

    I quickly tried this by removing the parameters from the method signature and the bean definition and it worked fine, so the problem would seem to be in how I'm providing and/or declaring parameters in my configuration.

    Anyone able to point me in the right direction?

    Thanks.
    Last edited by Ickster; Feb 2nd, 2010 at 09:41 PM. Reason: adding dummy package name to the factory class

  2. #2
    Join Date
    Jun 2005
    Posts
    4,230

    Default

    It works for me. Is the factory method public static?

  3. #3
    Join Date
    Feb 2010
    Posts
    3

    Default

    Yup.
    Code:
    public static FileSystemResource createOutputFile(Date fileDate, String path) {
    . . . 
    }
    Like I mentioned above, at one point I removed the parameters from the method signature and the bean definition and then it worked just fine. I must be missing something, but for the life of me I can't figure out what it is.

  4. #4
    Join Date
    Jun 2005
    Posts
    4,230

    Default

    Still works for me. Is that method overloaded? Is that really a java.util.Date?

  5. #5
    Join Date
    Feb 2010
    Posts
    3

    Default

    Dave -

    Turns out that I just needed to clean the project in Eclipse to remove an old reference. My factory class originally implemented an interface before I changed the factory method to static. When I did that refactoring, the method signature was removed from the interface, so I removed the interface reference from the class, but apparently Eclipse did not. Such is life.

    Thanks for your responses!

Posting Permissions

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