Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Spring intergration of DataSource

    Hi,

    I'd like to configure some custom datasources through Spring (in this particular case, the datasources provide file names, and the directory should be configurable)

    When I initiate the datasource as a Spring bean, I get the following error:
    Code:
    Exception when loading from D:/eclipse-3.3/workspacesmartgwt/builtinds/war/builtinds/sc/system/schema/builtinTypes.xml:
    java.lang.NullPointerException
    	at com.isomorphic.datasource.BasicDataSource.toRecord(BasicDataSource.java:857)
    	at com.isomorphic.datasource.BasicDataSource.toRecords(BasicDataSource.java:822)
    	at com.isomorphic.datasource.DataSource.recordsFromXML(DataSource.java:953)
    	at com.isomorphic.xml.XML.toDSRecords(XML.java:298)
    	at com.isomorphic.xml.XML.toDSRecords(XML.java:262)
    	at com.isomorphic.xml.XML.toDSRecords(XML.java:265)
    	at com.isomorphic.datasource.DataSource.<clinit>(DataSource.java:544)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:85)
    My custom datasource extends the SQLDataSource (although the error also occurs when extending BasicDataSource)

    My datasource xml definition is as follows:
    Code:
    <DataSource ID="ficheros" 
    	 serverConstructor="spring:fileDataSource">
    
    </DataSource>
    Spring definition:
    Code:
    	<bean id="fileDataSource"
    		class="es.valbosoft.smartgwt.datasource.FileDataSource">
    	</bean>
    It seems like this datasource class can't be instantiated by Spring, could it be that it only works when called directly from the datasource xml file?

    I'm using smartgwt 2.5 nightly build 18-7-2011
    Chrome

    Thanks in advance,
    Bo

    #2
    lazy-init seems to do the trick:
    Code:
    <bean id="fileDataSource"
    		class="es.valbosoft.smartgwt.datasource.FileDataSource" lazy-init="true">
    	</bean>
    thanks

    Comment

    Working...
    X