Announcement

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

    Spring serverConstructor error

    v8.3p_2012-11-22/PowerEdition Deployment (built 2012-11-22)

    There's an error loading datasource configuration from ds.xml files when two datasources are related to each other.

    users.ds.xml
    Code:
    <DataSource ID="users" [b]serverConstructor="spring:EtgHibernateDataSource"[/b]
                serverType="hibernate" beanClassName="ru.eurotechnologygroup.etgcrm.server.model.User"
                schemaBean="ru.eurotechnologygroup.etgcrm.server.model.User" allowAdvancedCriteria="true">
        <operationBindings>
            <operationBinding operationType="fetch" operationId="listFetch"
                              outputs="id,lastName,firstName,secondName,departmentName,department,phone,email,login,maskip,datebirth,blocked"/>
        </operationBindings>
        <fields>
            <field name="id" title="Идентификатор" detail="true" hidden="false"/>
            <field name="lastName" title="Фамилия" length="30" required="true"/>
            <field name="firstName" title="Имя" length="30"/>
            <field name="secondName" title="Отчество"  length="30"/>
            [b]<field name="departmentName" title="Подразделение" includeFrom="departments.name" canSave="false"/>
            <field name="department" title="Подразделение" foreignKey="departments.id" displayField="departmentName"
                   hidden="true" editorType="IPickTreeItem" required="true" advancedFilterField="true"/>[/b]
            <field name="phone" title="Телефон" length="50"/>
            <field name="email" title="EMail" length="50"/>
            <field name="login" title="Логин" length="20" required="true"/>
            <field name="password" title="Пароль" hidden="true" length="20" required="true" viewRequiresRole="R_ADM"/>
            <field name="maskip" title="IP-маска" length="100"/>
            <field name="datebirth" title="Дата рождения" dateFormatter="toEuropeanShortDate"/>
            <field name="roles" title="Роли" detail="true" customEditorType="RolesPicker" advancedFilterField="true"/>
            <field name="blocked" title="Заблокирован"/>
        </fields>
    </DataSource>
    departments.ds.xml
    Code:
    <DataSource ID="departments" [b]serverConstructor="spring:EtgHibernateDataSource"[/b]
                serverType="hibernate" beanClassName="ru.eurotechnologygroup.etgcrm.server.model.Department"
                schemaBean="ru.eurotechnologygroup.etgcrm.server.model.Department">
        <fields>
            <field name="id" title="№" detail="true" hidden="false"/>
            <field name="name" title="Название" required="true" length="100"/>
            <field name="parent" foreignKey="departments.id"/>
            <field name="children" ignore="true"/>
        </fields>
    </DataSource>
    Custom datasource declaration
    Code:
    @Service("EtgHibernateDataSource")
    public class EtgHibernateDataSource extends HibernateDataSource
    {
    ...
    }

    The error:
    Code:
    === 2012-11-25 20:59:30,420 [l0-3] DEBUG XML - Parsed XML from C:\Users\Val\.IntelliJIdea11\system\gwt\etgcrm.etgcrm77d24fbc\etgcrm.aaba320c\run\www\etgcrm\sc\system\schema\builtinTypes.xml: 3ms
    === 2012-11-25 20:59:30,466 [l0-3] DEBUG XML - Parsed XML from C:\Users\Val\.IntelliJIdea11\system\gwt\etgcrm.etgcrm77d24fbc\etgcrm.aaba320c\run\www\ds\users.ds.xml: 1ms
    === 2012-11-25 20:59:30,469 [l0-3] DEBUG XML - Parsed XML from C:\Users\Val\.IntelliJIdea11\system\gwt\etgcrm.etgcrm77d24fbc\etgcrm.aaba320c\run\www\etgcrm\sc\system\schema\DataSource.ds.xml: 2ms
    === 2012-11-25 20:59:30,503 [l0-3] DEBUG XML - Parsed XML from C:\Users\Val\.IntelliJIdea11\system\gwt\etgcrm.etgcrm77d24fbc\etgcrm.aaba320c\run\www\etgcrm\sc\system\schema\OperationBinding.ds.xml: 2ms
    === 2012-11-25 20:59:30,515 [l0-3] DEBUG XML - Parsed XML from C:\Users\Val\.IntelliJIdea11\system\gwt\etgcrm.etgcrm77d24fbc\etgcrm.aaba320c\run\www\etgcrm\sc\system\schema\DataSourceField.ds.xml: 3ms
    === 2012-11-25 20:59:30,695 [l0-3] DEBUG HibernateDataSource - Looking up session factory with lookup style 'spring'
    === 2012-11-25 20:59:30,696 [l0-3] INFO  ServerObject - DMI on Spring bean: &sessionFactory
    === 2012-11-25 20:59:30,718 [l0-3] DEBUG XML - Parsed XML from C:\Users\Val\.IntelliJIdea11\system\gwt\etgcrm.etgcrm77d24fbc\etgcrm.aaba320c\run\www\ds\departments.ds.xml: 2ms
    === 2012-11-25 20:59:30,730 [l0-3] ERROR DataSourceLoader - Exception while attempting to load a DataSource
    java.lang.NullPointerException
    	at com.isomorphic.datasource.BasicDataSource.init(BasicDataSource.java:462)
    	at com.isomorphic.hibernate.HibernateDataSource.init(HibernateDataSource.java:316)
    	at com.isomorphic.datasource.DataSource.initialize(DataSource.java:400)
    	at com.isomorphic.datasource.BasicDataSource.fromConfig(BasicDataSource.java:163)
    	at com.isomorphic.datasource.DataSource.fromConfig(DataSource.java:385)
    	at com.isomorphic.datasource.FileSystemDSRepo.loadDS(FileSystemDSRepo.java:110)
    	at com.isomorphic.datasource.DataSource.forName(DataSource.java:204)
    	at com.isomorphic.datasource.DataSource.forName(DataSource.java:195)
    	at com.isomorphic.datasource.DataSource.forName(DataSource.java:184)
    	at com.isomorphic.datasource.PoolableDataSourceFactory.makeUnpooledObject(PoolableDataSourceFactory.java:119)
    	at com.isomorphic.datasource.PoolableDataSourceFactory.makeObject(PoolableDataSourceFactory.java:127)
    	at com.isomorphic.pool.PoolManager.borrowObject(PoolManager.java:94)
    	at com.isomorphic.datasource.DataSourceManager.getDataSource(DataSourceManager.java:89)
    	at com.isomorphic.datasource.DataSourceManager.getDataSource(DataSourceManager.java:83)
    	at com.isomorphic.servlet.DataSourceLoader.processRequest(DataSourceLoader.java:126)
    	at com.isomorphic.servlet.DataSourceLoader.doGet(DataSourceLoader.java:94)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    	at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
    	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1097)
    	at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:259)
    	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1088)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
    	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
    	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    	at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    	at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    	at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    	at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    	at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    	at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
    	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
    	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
    	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
    	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1088)
    	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
    	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
    	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
    	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
    	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    	at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
    	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    	at org.mortbay.jetty.Server.handle(Server.java:324)
    	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
    	at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:829)
    	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:513)
    	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
    	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
    	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
    	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
    === 2012-11-25 20:59:30,732 [l0-3] ERROR DataSourceLoader - Top-level servlet error: 
    javax.servlet.ServletException: java.lang.NullPointerException
    	at com.isomorphic.datasource.BasicDataSource.init(BasicDataSource.java:462)
    	at com.isomorphic.hibernate.HibernateDataSource.init(HibernateDataSource.java:316)
    	at com.isomorphic.datasource.DataSource.initialize(DataSource.java:400)
    	at com.isomorphic.datasource.BasicDataSource.fromConfig(BasicDataSource.java:163)
    	at com.isomorphic.datasource.DataSource.fromConfig(DataSource.java:385)
    	at com.isomorphic.datasource.FileSystemDSRepo.loadDS(FileSystemDSRepo.java:110)
    	at com.isomorphic.datasource.DataSource.forName(DataSource.java:204)
    	at com.isomorphic.datasource.DataSource.forName(DataSource.java:195)
    	at com.isomorphic.datasource.DataSource.forName(DataSource.java:184)
    	at com.isomorphic.datasource.PoolableDataSourceFactory.makeUnpooledObject(PoolableDataSourceFactory.java:119)
    	at com.isomorphic.datasource.PoolableDataSourceFactory.makeObject(PoolableDataSourceFactory.java:127)
    	at com.isomorphic.pool.PoolManager.borrowObject(PoolManager.java:94)
    	at com.isomorphic.datasource.DataSourceManager.getDataSource(DataSourceManager.java:89)
    	at com.isomorphic.datasource.DataSourceManager.getDataSource(DataSourceManager.java:83)
    	at com.isomorphic.servlet.DataSourceLoader.processRequest(DataSourceLoader.java:126)
    	at com.isomorphic.servlet.DataSourceLoader.doGet(DataSourceLoader.java:94)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    	at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
    	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1097)
    	at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:259)
    	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1088)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
    	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
    	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    	at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    	at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    	at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    	at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    	at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    	at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
    	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
    	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
    	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
    	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1088)
    	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
    	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
    	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
    	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
    	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    	at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
    	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    	at org.mortbay.jetty.Server.handle(Server.java:324)
    	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
    	at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:829)
    	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:513)
    	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
    	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
    	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
    	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
    
    	at com.isomorphic.servlet.DataSourceLoader.processRequest(DataSourceLoader.java:185)
    	at com.isomorphic.servlet.DataSourceLoader.doGet(DataSourceLoader.java:94)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    	at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
    	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1097)
    	at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:259)
    	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1088)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
    	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
    	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    	at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    	at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    	at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    	at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    	at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    	at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
    	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
    	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
    	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
    	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1088)
    	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
    	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
    	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
    	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
    	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    	at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
    	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    	at org.mortbay.jetty.Server.handle(Server.java:324)
    	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
    	at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:829)
    	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:513)
    	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
    	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
    	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
    	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
    The error only appears when both datasources use serverConstructor="spring:...". There's no error after removing "spring:" from one of them.

    Also, all other datasources are working fine if they are not related.

    TY.

    #2
    Data source implementation cannot be used as singleton and it is not thread-safe.

    You did not show your spring config here, but I guess you configured your bean without "scope" attribute, which defaults to "singleton". You could change scope to "prototype" (independent instance resulting from each call to getBean):
    Code:
    <bean id="EtgHibernateDataSource" ... scope="prototype" />

    Comment


      #3
      Thx for your help. You're absolutely right, DataSource must not be a singleton.

      Adding @Scope("prototype") resolved the problem.

      Comment

      Working...
      X