com.sap.cloud.sdk.frameworks.hystrix.ScpNeoHystrixBootstrapListenerjava.lang.IllegalStateException [英] com.sap.cloud.sdk.frameworks.hystrix.ScpNeoHystrixBootstrapListenerjava.lang.IllegalStateException

查看:162
本文介绍了com.sap.cloud.sdk.frameworks.hystrix.ScpNeoHystrixBootstrapListenerjava.lang.IllegalStateException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果在servlet中使用ODataQueryBuilder,则可以毫无问题地调用servlet.

If I use ODataQueryBuilder in a servlet, I can call the servlet without any problem.

如果将代码合并到方法中并在ServletContextListener中调用此方法,则会首先出现以下错误.

If I incorporated the code in a method and call this method within a ServletContextListener, I got first the following error.

2018 02 27 13:17:09#+00#ERROR#org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/]##anonymous#fs-watcher#na#afc186d33#firstapp#web##na#na#na#na#Exception sending context initialized event to listener instance of class com.sap.cloud.sdk.frameworks.hystrix.ScpNeoHystrixBootstrapListenerjava.lang.IllegalStateException: Another strategy was already registered.
at com.netflix.hystrix.strategy.HystrixPlugins.registerConcurrencyStrategy(HystrixPlugins.java:190)
at com.sap.cloud.sdk.frameworks.hystrix.ScpNeoHystrixBootstrapListener.bootstrap(ScpNeoHystrixBootstrapListener.java:43)
at com.sap.cloud.sdk.frameworks.hystrix.ScpNeoHystrixBootstrapListener.contextInitialized(ScpNeoHystrixBootstrapListener.java:74)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5110)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5633)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1015)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:991)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at org.eclipse.gemini.web.tomcat.internal.TomcatServletContainer.startWebApplication(TomcatServletContainer.java:125)
at org.eclipse.gemini.web.internal.StandardWebApplication.start(StandardWebApplication.java:109)
at org.eclipse.gemini.web.extender.WebContainerBundleCustomizer.addingBundle(WebContainerBundleCustomizer.java:49)
at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:467)
at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:1)
at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)
at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229)
at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:443)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:847)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
at org.eclipse.osgi.framework.internal.core.Framework.publishBundleEventPrivileged(Framework.java:1568)
at org.eclipse.osgi.framework.internal.core.Framework.publishBundleEvent(Framework.java:1504)
at org.eclipse.osgi.framework.internal.core.Framework.publishBundleEvent(Framework.java:1499)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:391)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:300)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:292)
at org.eclipse.virgo.web.war.deployer.WARDeployer.start(WARDeployer.java:780)
at org.eclipse.virgo.nano.deployer.internal.StandardApplicationDeployer.startDeployables(StandardApplicationDeployer.java:325)
at org.eclipse.virgo.nano.deployer.internal.StandardApplicationDeployer.bulkDeploy(StandardApplicationDeployer.java:116)
at org.eclipse.virgo.nano.deployer.hot.HotDeploymentFileSystemListener.bulkDeployIfNotDeployed(HotDeployerFileSystemListener.java:143)
at org.eclipse.virgo.nano.deployer.hot.HotDeploymentFileSystemListener.onInitialEvent(HotDeployerFileSystemListener.java:105)
at org.eclipse.virgo.util.io.FileSystemChecker.notifyListenersOnInitialEvent(FileSystemChecker.java:207)
at org.eclipse.virgo.util.io.FileSystemChecker.handleInitialFiles(FileSystemChecker.java:177)
at org.eclipse.virgo.util.io.FileSystemChecker.check(FileSystemChecker.java:261)
at org.eclipse.virgo.nano.deployer.hot.WatchTask.run(WatchTask.java:49)
at java.lang.Thread.run(Thread.java:807)

其次:

  • 一个或多个侦听器无法启动.详细信息请参见 适当的容器日志文件
  • 由于先前的错误,上下文[]启动失败
  • One or more listeners failed to start. Full details will be found in the appropriate container log file
  • Context [] startup failed due to previous errors

这将破坏我的Servlet Context Listener,然后无法在NEO中启动Web应用程序.

This will destroy my Servlet Context Listener and then failed to start web application in NEO.

这很奇怪,因为该方法调用得很好,并且在日志中我可以看到该方法的调用没有错误.

It is strange because the method is called well and in the log I can see that the method is called without an error.

如果我未在代码中调用该方法,则应用程序启动良好.

If I don't call the method in code, the application is starting up well.

请让我知道如何解决此问题,因为我需要调用S/4 Hana系统.

Please let me know, how I can solve this issue, because I need to call the S/4 Hana system.

推荐答案

更新:

SAP S/4HANA Cloud SDK的2.0.0版更改了RequestContextListener的初始化方式.现在可以使用以下代码,而无需付出额外的努力:

Version 2.0.0 of the SAP S/4HANA Cloud SDK changed the way how RequestContextListeners are initialized. It is now be possible to use the following code without additional effort:

new RequestContextExecutor().execute(...);

原始答案:

我想您想在不是由用户请求触发的某些后台任务中运行逻辑.

I guess that you want to run logic in some background task that is not triggered by a user request.

您能否尝试将调用S/4HANA系统的逻辑包装在Callable中,并将其传递给

Can you try to wrap the logic calling the S/4HANA system in a Callable which is passed to the execute method of a RequestContextExecutor?

例如:

List<SomeData> result = new RequestContextExecutor()
    .execute(new Callable<List<SomeData>>() {
        @Override
        public List<SomeData> call() {
            return new GetSomeDataCommand().execute();
        }
    });

请注意,这将要求技术用户在目标配置中具有基本凭据;在这种情况下,主体传播不可用.

Note that this will require a technical user with Basic credentials in the destination configuration; principal propagation is not available in this case.

还请注意,如果要在应用程序启动期间运行在ServletContextListener中调用外部系统的后台任务,则必须

Also note that if you want to run the background task calling the external system in a ServletContextListener during application startup, you have to

  • 要么显式注册相关的RequestContextListener类,它们也是ServletContextListener的子类(包括(如果使用SAP Cloud Platform Neo环境,则初始化ScpNeoHystrixBootstrapListener))
  • 或在web.xml文件中显式指定ServletContextListener类的顺序.
  • either explicitly register the relevant RequestContextListener classes which are also subclasses of ServletContextListener (including, if you are using the SAP Cloud Platform Neo environment, initializing the ScpNeoHystrixBootstrapListener),
  • or specify the order of the ServletContextListener classes explicitly in the web.xml file.

您可以按照以下方式明确注册这些侦听器:

You can register these listeners explictly as follows:

// ensure that the correct HystrixConcurrencyStrategy is used
new ScpNeoHystrixBootstrapListener().bootstrap();

// explicitly register RequestContextListeners
new RequestContextExecutor().withListeners(
    new DestinationsRequestContextListener(),
    new ScpNeoDestinationsRequestContextListener(),
    new TenantRequestContextListener(),
    new UserRequestContextListener()
).execute( /* callable */ );

这篇关于com.sap.cloud.sdk.frameworks.hystrix.ScpNeoHystrixBootstrapListenerjava.lang.IllegalStateException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆