Announcement Announcement Module
Collapse
No announcement yet.
Factory method constructor args when using batch namespace Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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, 10:41 PM. Reason: adding dummy package name to the factory class

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

    Comment


    • #3
      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.

      Comment


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

        Comment


        • #5
          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!

          Comment

          Working...
          X