6

簡単なテスト アプリケーションを作成しました。

import java.util.logging.Logger;

import org.apache.catalina.Context;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.startup.Tomcat;

public class Main {
  private final static Logger LOGGER = Logger.getLogger(Main.class.getName());
  private final static String mWorkingDir = System.getProperty("java.io.tmpdir");
  private static Tomcat tomcat = null;

  public static void main(String[] args) {

    tomcat = new Tomcat();
    tomcat.setPort(8080);
    tomcat.setBaseDir(mWorkingDir);
    tomcat.getHost().setAppBase(mWorkingDir);
    tomcat.getHost().setAutoDeploy(true);
    tomcat.getHost().setDeployOnStartup(true);

    try {
      tomcat.start();
    } catch (LifecycleException e) {
      LOGGER.severe("Tomcat could not be started.");
      e.printStackTrace();
    }
    LOGGER.info("Tomcat started on " + tomcat.getHost());

    // Alternatively, you can specify a WAR file as last parameter in the following call e.g. "C:\\Users\\admin\\Desktop\\app.war"    
    Context appContext = Main.getTomcat().addWebapp(Main.getTomcat().getHost(), "/app", System.getProperty("user.dir")+"\\Whys.war");
    LOGGER.info("Deployed " + appContext.getBaseName() + " as " + appContext.getBaseName());

    tomcat.getServer().await();
  }

  public static Tomcat getTomcat(){
      return tomcat;
  }
}

これをEclipseから開始すると、すべて正常に動作しますが、これを実行可能なjarにエクスポートして実行すると、次のエラーが発生します:

HTTP ステータス 500 - com.vaadin.server.ServiceException: java.lang.IllegalStateException: プッシュが利用できません。詳細については、以前のログ メッセージを参照してください。

コールスタック全体は次のとおりです。

GRAVE: Failed to initialize Atmosphere Framework
java.lang.IllegalArgumentException: Unable to createclass org.atmosphere.container.JSR356AsyncSupport
        at org.atmosphere.cpr.DefaultAsyncSupportResolver.newCometSupport(DefaultAsyncSupportResolver.java:229)
        at org.atmosphere.cpr.DefaultAsyncSupportResolver.resolveWebSocket(DefaultAsyncSupportResolver.java:288)
        at org.atmosphere.cpr.DefaultAsyncSupportResolver.resolve(DefaultAsyncSupportResolver.java:274)
        at org.atmosphere.cpr.AtmosphereFramework.autoDetectContainer(AtmosphereFramework.java:1591)
        at org.atmosphere.cpr.AtmosphereFramework.init(AtmosphereFramework.java:717)
        at org.atmosphere.cpr.AtmosphereFramework.init(AtmosphereFramework.java:614)
        at com.vaadin.server.communication.PushRequestHandler.<init>(PushRequestHandler.java:121)
        at com.vaadin.server.VaadinServletService.createRequestHandlers(VaadinServletService.java:82)
        at com.vaadin.server.VaadinService.init(VaadinService.java:186)
        at com.vaadin.server.VaadinServlet.createServletService(VaadinServlet.java:258)
        at com.vaadin.server.VaadinServlet.init(VaadinServlet.java:164)
        at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1231)
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1144)
        at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:817)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:135)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1527)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1484)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at org.atmosphere.cpr.DefaultAsyncSupportResolver.newCometSupport(DefaultAsyncSupportResolver.java:225)
        ... 28 more
Caused by: java.lang.IllegalStateException: ServerContainer is null
        at org.atmosphere.container.JSR356AsyncSupport.<init>(JSR356AsyncSupport.java:43)
        ... 33 more

ao¹t 12, 2015 8:32:04 PM com.vaadin.server.VaadinServletService createRequestHandlers
AVERTISSEMENT: Error initializing Atmosphere. Push will not work.
com.vaadin.server.ServiceException: Atmosphere init failed
        at com.vaadin.server.communication.PushRequestHandler.<init>(PushRequestHandler.java:129)
        at com.vaadin.server.VaadinServletService.createRequestHandlers(VaadinServletService.java:82)
        at com.vaadin.server.VaadinService.init(VaadinService.java:186)
        at com.vaadin.server.VaadinServlet.createServletService(VaadinServlet.java:258)
        at com.vaadin.server.VaadinServlet.init(VaadinServlet.java:164)
        at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1231)
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1144)
        at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:817)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:135)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1527)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1484)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Unknown Source)
Caused by: javax.servlet.ServletException: java.lang.IllegalArgumentException: Unable to createclass org.atmosphere.container.JSR356AsyncSupport
        at org.atmosphere.cpr.AtmosphereFramework.init(AtmosphereFramework.java:741)
        at org.atmosphere.cpr.AtmosphereFramework.init(AtmosphereFramework.java:614)
        at com.vaadin.server.communication.PushRequestHandler.<init>(PushRequestHandler.java:121)
        ... 22 more
Caused by: java.lang.IllegalArgumentException: Unable to createclass org.atmosphere.container.JSR356AsyncSupport
        at org.atmosphere.cpr.DefaultAsyncSupportResolver.newCometSupport(DefaultAsyncSupportResolver.java:229)
        at org.atmosphere.cpr.DefaultAsyncSupportResolver.resolveWebSocket(DefaultAsyncSupportResolver.java:288)
        at org.atmosphere.cpr.DefaultAsyncSupportResolver.resolve(DefaultAsyncSupportResolver.java:274)
        at org.atmosphere.cpr.AtmosphereFramework.autoDetectContainer(AtmosphereFramework.java:1591)
        at org.atmosphere.cpr.AtmosphereFramework.init(AtmosphereFramework.java:717)
        ... 24 more
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at org.atmosphere.cpr.DefaultAsyncSupportResolver.newCometSupport(DefaultAsyncSupportResolver.java:225)
        ... 28 more
Caused by: java.lang.IllegalStateException: ServerContainer is null
        at org.atmosphere.container.JSR356AsyncSupport.<init>(JSR356AsyncSupport.java:43)
        ... 33 more

ao¹t 12, 2015 8:33:08 PM com.vaadin.server.VaadinServletService ensurePushAvailable
AVERTISSEMENT:
=================================================================
Atmosphere could not be loaded. When using push with Vaadin, the
Atmosphere framework must be present on the classpath.
If using a dependency management system, please add a dependency
to vaadin-push.
If managing dependencies manually, please make sure Atmosphere
2.1.2.vaadin6 is included on the classpath.
Will fall back to using PushMode.DISABLED.
=================================================================

javax.websocket-api-1.1.jar をライブラリに追加しようとしましたが、何も変更されず、同じエラーが発生しました。

どこに問題があるのか​​ わかりません。おそらく何かを追加する必要がありますが、現時点では何がわかりません。

編集:

私は Maven/Gradle を使用しません。Tomcat8 の Web サイトに必要なものをすべてダウンロードした埋め込み用の tomcat8 と、埋め込みなしの Tomcat8 で正常に動作するプロジェクトの 1 つを使用したテスト アプリケーション ウォー用です。

4

1 に答える 1

1

この問題は、クラスパスに含まれる Jetty ライブラリが原因であると思います。それらは他のJava jar内にある可能性があります-そのため、アプリケーションのすべての依存関係を何らかのツールで分析する必要があります(統合されたIDEであっても)。

私の疑惑はVaadin Configuration tutorialにも基づいています。特にTomcat 8セクションを見てください。

編集: Vaadin Push を有効にする場合は、公式wikiも参照してください。プロジェクトで行う必要があるすべての変更 (依存関係、UI 注釈、web.xml) が記述されています。

于 2015-08-15T15:01:37.827 に答える