Announcement

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

    PreCache datasource loading uses custom added dynamic ds generators

    Hi

    We recently upgraded to SmartGWT 12.1 and are having some exceptions during server startup but do not prevent the server from starting, so I have some questions whether this could be an issue or not.
    This happens when pre-caching https://www.smartclient.com/smartgwt.../PreCache.html
    Exception:
    Code:
    2021-03-08 12:44:16,182 [.0.1] ERROR DataSourceConverter - Could not generate datasource Rule
    java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.
        at org.springframework.web.context.request.RequestContextHolder.currentRequestAttributes(RequestContextHolder.java:131) ~[spring-web-5.2.6.RELEASE.jar:5.2.6.RELEASE]
        at com.genohm.slims.server.datasource.generator.AgnosticRequestGetter.getRequest(AgnosticRequestGetter.java:13) ~[classes/:?]
        at com.genohm.slims.server.datasource.generator.DataSourceConverter.getDataSource(DataSourceConverter.java:66) ~[classes/:?]
        at com.genohm.slims.server.datasource.generator.DataSourceConverter.getDataSource(DataSourceConverter.java:54) ~[classes/:?]
        at com.isomorphic.datasource.DataSource.getDynamicDataSource(DataSource.java:911) ~[isomorphic_core_rpc.jar:?]
        at com.isomorphic.datasource.DataSource.forName(DataSource.java:512) ~[isomorphic_core_rpc.jar:?]
        at com.isomorphic.datasource.PoolableDataSourceFactory.makeUnpooledObject(PoolableDataSourceFactory.java:125) ~[isomorphic_core_rpc.jar:?]
        at com.isomorphic.pool.PoolManager.borrowUnpooledObject(PoolManager.java:130) ~[isomorphic_core_rpc.jar:?]
        at com.isomorphic.datasource.DataSourceManager.getDataSource(DataSourceManager.java:193) ~[isomorphic_core_rpc.jar:?]
        at com.isomorphic.datasource.DataSourceManager.getDataSource(DataSourceManager.java:121) ~[isomorphic_core_rpc.jar:?]
        at com.isomorphic.taglib.LoadSystemSchemaTag.outputDSForName(LoadSystemSchemaTag.java:144) ~[isomorphic_core_rpc.jar:?]
        at com.isomorphic.taglib.LoadSystemSchemaTag.outputDSForName(LoadSystemSchemaTag.java:151) ~[isomorphic_core_rpc.jar:?]
        at com.isomorphic.taglib.LoadSystemSchemaTag.outputSystemSchema(LoadSystemSchemaTag.java:129) ~[isomorphic_core_rpc.jar:?]
        at com.isomorphic.servlet.PreCache.preLoadDataSources(PreCache.java:105) ~[isomorphic_core_rpc.jar:?]
        at com.isomorphic.servlet.PreCache.init(PreCache.java:91) ~[isomorphic_core_rpc.jar:?]
        at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1230) ~[catalina.jar:7.0.92]
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1174) ~[catalina.jar:7.0.92]
        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1066) ~[catalina.jar:7.0.92]
        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5409) ~[catalina.jar:7.0.92]
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5707) ~[catalina.jar:7.0.92]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) ~[catalina.jar:7.0.92]
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1018) ~[catalina.jar:7.0.92]
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:994) ~[catalina.jar:7.0.92]
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652) ~[catalina.jar:7.0.92]
        at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1900) ~[catalina.jar:7.0.92]
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
        at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
        at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301) ~[tomcat-coyote.jar:7.0.92]
        at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:809) ~[?:?]
        at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) ~[?:?]
        at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:619) ~[catalina.jar:7.0.92]
        at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:566) ~[catalina.jar:7.0.92]
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
        at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
        at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301) ~[tomcat-coyote.jar:7.0.92]
        at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:809) ~[?:?]
        at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) ~[?:?]
        at com.sun.jmx.remote.security.MBeanServerAccessController.invoke(MBeanServerAccessController.java:468) ~[?:?]
        at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1466) ~[?:?]
        at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1307) ~[?:?]
        at java.security.AccessController.doPrivileged(Native Method) ~[?:?]
        at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1406) ~[?:?]
        at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:827) ~[?:?]
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
        at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
        at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359) ~[?:?]
        at sun.rmi.transport.Transport$1.run(Transport.java:200) ~[?:?]
        at sun.rmi.transport.Transport$1.run(Transport.java:197) ~[?:?]
        at java.security.AccessController.doPrivileged(Native Method) ~[?:?]
        at sun.rmi.transport.Transport.serviceCall(Transport.java:196) ~[?:?]
        at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562) ~[?:?]
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796) ~[?:?]
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677) ~[?:?]
        at java.security.AccessController.doPrivileged(Native Method) ~[?:?]
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676) [?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
        at java.lang.Thread.run(Thread.java:834) [?:?]
    After some investigation I noticed the difference between the previous versions and 12.1 is that a lot more framework datasources get loaded in.
    On 12.1 LoadSystemSchemaTag#getFrameworkDataSources is used and seems to load in every ds.xml in smartgwtee.jar!/com/smartclient/public/sc/system/schema and on previous versions it is
    Code:
        public void preLoadDataSources() throws Exception {
            String[] dsNames = new String[]{"DataSource", "DataSourceField", "Validator", "ValueMap", "InstantDataApp", "IDAPage", "IDAUserType", "IDAOperation", "IDAComponent", "ComponentButton", "Canvas", "Img", "Button", "ListViewer", "ListViewerField", "DynamicForm", "FormItem", "DetailViewer", "DetailViewerField", "isomorphicXML"};
    
            for(int i = 0; i < dsNames.length; ++i) {
                String dsName = dsNames[i];
                this.log.debug("Preloading DataSource: " + dsName);
                DataSource ds = DataSourceManager.getDataSource(dsName, (DSRequest)null);
                DataSourceManager.freeDataSource(ds);
            }
    
        }
    It so happens we have some datasources with the same ID as some framework datasources (Rule, Project, Field) and we register a dynamic datasource generator for each of these.
    Code:
    DataSource.addDynamicDSGenerator(converter, Pattern.compile("\\A" + entry.getKey() + "\\z"));
    We've never had issues before with some of our datasources using the same ID as some framework datasources so I guess that it shouldn't be an issue now?
    As for the exceptions on startup I'd just like to confirm that we can ignore these since pre-caching is optional anyway?

    Kind Regards,
    Jeno

    #2
    This looks like an order of initialization problem. At the moment the PreCache servlet is running, Spring has not initialized, so it blows up.

    You may need to reorder initialization so that PreCache runs later (see https://www.smartclient.com/smartgwt...erverInit.html), or, as you say, you can skip PreCache - it's optional.

    Comment

    Working...
    X