Announcement Announcement Module
Collapse
No announcement yet.
iBatis 2 Support - Can't locate sqlmap config file Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • iBatis 2 Support - Can't locate sqlmap config file

    Greetings, all. I'm having a bear of a time with getting the framework to locate my sql-map.config.xml file.

    Dev tool: WSAD 5.1.2
    Runtime: WebSphere 5.1
    JDK (both): 1.4.2
    Spring Release: 1.1RC2

    ((From spring config))
    Code:
    	<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
    		<property name="configLocation"><value>WEB-INF/sql-map-config.xml</value></property>
    	</bean>
    The file is in the indicated directory, but during initialization it keeps throwing
    springApplicationContext.xml]: Initialization of bean failed; nested exception is java.io.FileNotFoundException: sql-map-config.xml (The system cannot find the file specified)

    To make it work, I've removed the "WEB-INF/" portion of the path and placed it in WSAD5.1's base directory, and everything started up and initialized as expected. The 'WEB-INF/' recommendation came from the javadoc for said class.

    Anyone else run into this, or have any pointers? I can't continue to place the file in the server's base....thanks for any assistance!

  • #2
    Just FYI, the trace I included was from a different attempt so the config and trace are out of sync...but the results were always the same, FileNotFoundException....

    Comment


    • #3
      Code:
       <bean id="sqlMap" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
             <property name="configLocation">
             		<value>/WEB-INF/sqlmapconfig.xml</value>
             	</property>
             	<property name="dataSource">
             		<ref local="myDataSource"/>
             	</property>
          </bean>

      This is mine and it is in dataAccessContext-local.xml context file.

      Comment


      • #4
        Is the SqlMapClientFactoryBean bean definition actually being used inside a WebApplicationContext variant? A path like '/WEB-INF/xxxx' is only going to work inside a web appcontext variant (the leading slash should actually be there, but Spring will add it for you). If you are using it instead inside something like a ClassPathXmlApplicationContext, or FileSystemXmlApplicationContext, you need to use a classpath location, or filesystem location, respectively...

        What happens is that the configLocation is actually of a type 'Resoure'. Now when you use this bean inside an application context, you get an automatic conversion from the String value you specify, to a real Resource type, via the ResourceEditor PropertyEditor the context automatically registers. But the context itself gets set up as the resource loader, and the web variants of the context interpret unqualified paths as relative to the web-app context root, while the other ones interpret unqualified paths as classpath names.

        I hope this is clear. You can btw always force a path to be interpreted as a classpath location, by using the form:
        classpath:xxx/yyy/zzzz/whatever
        and you can always force a path to be interpreted as an absolute file location by using the form:
        file:<some valid file URL path>

        Regards,

        Comment


        • #5
          Mr. Sampaleanu,

          Oh my, is my face red now...as soon as you pointed that out, it became clear, and your diagnosis was spot-on. Thanks for the assistance!

          Regards,

          Ron Eisele

          Comment


          • #6
            Actually, as I mentioned on a dev-list thread yesterday, we need to document a bit more clearly for Resource params that there is automatic conversion from Strings going on in the AppContext, and this can be treated differently...

            Comment

            Working...
            X