Summary:

Errors in the CRM metadata my lead to a StringIndexOutOfBoundsException when the CRMJ webapp attempts to load the metadata. Subsequent requests to use the metadata object in Java (e.g., using the Exchange integration, or viewing the SDATA schema URL) will result in a SageObjectNotInitializedException.

Symptoms:

The following is logged to \CRM\tomcat\logs\stdout.log on startup:

Exception in thread "Thread-13" java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(Unknown Source)
at org.hibernate.type.descriptor.java.CharacterTypeDescriptor.wrap(CharacterTypeDescriptor.java:80)
at org.hibernate.type.descriptor.java.CharacterTypeDescriptor.wrap(CharacterTypeDescriptor.java:34)
at org.hibernate.type.descriptor.sql.VarcharTypeDescriptor$2.doExtract(VarcharTypeDescriptor.java:61)
at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:64)
...
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:279)
at org.hibernate.loader.Loader.doList(Loader.java:2533)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
at org.hibernate.loader.Loader.list(Loader.java:2271)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:119)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1716)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:347)
at com.sage.scrm.model.BasicHelper.getListFromCriteria(BasicHelper.java:124)
at com.sage.scrm.model.BasicHelper.getListFromCriteria(BasicHelper.java:91)
at com.sage.scrm.model.BasicHelper.getListOfModifiedObjects(BasicHelper.java:205)
at com.sage.scrm.model.metadata.MetaDataHelper.getCustomEntities(MetaDataHelper.java:104)
at com.sage.scrm.model.metadata.MetaDataHelper$$FastClassByCGLIB$$88d7b8c9.invoke()
...
at com.sage.scrm.model.metadata.MetaDataHelper$$EnhancerByCGLIB$$c0fba81d.getCustomEntities()
at com.sage.scrm.model.metadata.MetaDataStore$1.run(MetaDataStore.java:225)
at java.lang.Thread.run(Unknown Source)

Error in \CRM\Logs\Exchange Integration\Exchangeexchangesyncengine.log on request for status:

message: objectNotInitialized
stackTrace: com.sage.scrm.model.error.SageObjectNotInitializedException: objectNotInitialized
at com.sage.scrm.model.metadata.MetaDataStore.checkInitialization(MetaDataStore.java:872)
at com.sage.scrm.model.metadata.MetaDataStore.isEntityAccessible(MetaDataStore.java:902)
at com.sage.scrm.model.metadata.MetaDataStore.isEntityAccessible(MetaDataStore.java:949)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:196)
at $Proxy38.isEntityAccessible(Unknown Source)
at com.sage.scrm.model.db.security.SecurityInformation.getUserSecurityForTable(SecurityInformation.java:148)
at com.sage.scrm.model.db.security.SecurityInformation.getUserSecurity(SecurityInformation.java:85)
at com.sage.scrm.model.db.AbstractBaseQuery.setSecurityString(AbstractBaseQuery.java:467)
at com.sage.scrm.model.db.ReadQuery.setQueryString(ReadQuery.java:538)
at com.sage.scrm.model.db.ReadQuery.buildQuery(ReadQuery.java:435)
at com.sage.scrm.model.db.ReadQuery.execute(ReadQuery.java:343)
at com.sage.scrm.model.db.ReadQuery.execute(ReadQuery.java:295)
at com.sage.scrm.model.db.ReadQuery.execute(ReadQuery.java:238)
at com.sage.scrm.model.db.ReadQuery.execute(ReadQuery.java:250)
at com.sage.scrm.model.sync.db.AbstractSyncIntegrationDB.getConfigurations(AbstractSyncIntegrationDB.java:259)
at com.sage.scrm.model.sync.db.AbstractSyncIntegrationDB.getConfigurations(AbstractSyncIntegrationDB.java:243)
at com.sage.scrm.model.sync.db.SyncIntegrationDBExchange.getSyncIntegration(SyncIntegrationDBExchange.java:152)
at com.sage.scrm.model.sync.db.SyncIntegrationDBExchange$$FastClassByCGLIB$$2ad728a.invoke()
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:617)
at com.sage.scrm.model.sync.db.SyncIntegrationDBExchange$$EnhancerByCGLIB$$a1c59be9.getSyncIntegration()
at com.sage.scrm.model.store.ExchangeSyncEngineConfigurationServiceStore.getData(ExchangeSynchainsawcEngineConfigurationServiceStore.java:48)
at com.sage.scrm.controller.SyncEngineConfigurationServiceController.requestAction(SyncEngineConfigurationServiceController.java:81)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.web.servlet.mvc.multiaction.MultiActionController.invokeNamedMethod(MultiActionController.java:471)
at org.springframework.web.servlet.mvc.multiaction.MultiActionController.handleRequestInternal(MultiActionController.java:408)
at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.sage.scrm.controller.util.AbstractSessionRequestFilter.doFilter(AbstractSessionRequestFilter.java:127)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.sage.scrm.scrmcommons.controller.util.EncodingRequestFilter.doFilter(EncodingRequestFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)

Work around / Resolution:

The issue is caused by an attempt to reference the first character in a zero-length screen when reading field properties. Running the following on the DB and then doing an IIS reset will resolve the issue:

update custom_edits set colp_lookupfamily = null where rtrim(colp_lookupfamily) = ''
update custom_edits set colp_required = null where rtrim(colp_required) = ''
update custom_edits set colp_system = null where rtrim(colp_system) = ''
update custom_edits set colp_lookupwidth = null where rtrim(colp_lookupwidth) = ''
update custom_edits set colp_searchsql = null where rtrim(colp_searchsql) = ''
drop view vsentinel