Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/355.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 找到类org.eclipse.jetty.websocket.api.UpgradeRequest,但需要接口_Java_Jetty - Fatal编程技术网

Java 找到类org.eclipse.jetty.websocket.api.UpgradeRequest,但需要接口

Java 找到类org.eclipse.jetty.websocket.api.UpgradeRequest,但需要接口,java,jetty,Java,Jetty,我是Java开发新手,在尝试通过getParameterMap()方法获取querystring变量时遇到了这个错误: Found class org.eclipse.jetty.websocket.api.UpgradeRequest, but interface was expected 我使用的代码如下: public class TranscribeSocket extends WebSocketAdapter implements ApiStreamObserver<Strea

我是Java开发新手,在尝试通过getParameterMap()方法获取querystring变量时遇到了这个错误:

Found class org.eclipse.jetty.websocket.api.UpgradeRequest, but interface was expected
我使用的代码如下:

public class TranscribeSocket extends WebSocketAdapter implements ApiStreamObserver<StreamingRecognizeResponse> {

private String speechLanguage = "en-US";

@Override
public void onWebSocketConnect(Session sess) {
    UpgradeRequest request = sess.getUpgradeRequest();
    Map<String, List<String>> params = request.getParameterMap();

    List<String> language = params.get("lang");
    if (language != null && language.size() > 0) {
        String lang = language.get(0);
        switch (lang) {
            case "en":
                speechLanguage = "en-US";
                break;
            case "fr":
                speechLanguage = "fr-FR";
                break;
            default:
                speechLanguage = "en-US";
        }
    }
}

事实上,这段代码取自GoogleSpeech-to-text示例,它提供了流式语音的转录。我需要将语音语言传递给gcloud,前端是用PHP构建的,因此我看到的唯一方法是通过查询字符串将适当的值传递给websocket。

好的问题在将jar-s升级到最新版本(不仅仅是wedsocket-jar)后得到了解决。多亏了

,我认为您可能会有相互冲突的websocket罐版本。你能用你正在使用的依赖关系树更新你的问题吗?
[INFO] be.smartconcept.speech:speaking-with-a-page:war:1.0-SNAPSHOT
[INFO] +- javax.servlet:javax.servlet-api:jar:3.1.0:provided
[INFO] +- org.eclipse.jetty.websocket:websocket-servlet:jar:9.4.1.v20170120:compile
[INFO] |  \- org.eclipse.jetty.websocket:websocket-api:jar:9.4.1.v20170120:compile
[INFO] +- com.google.cloud:google-cloud-speech:jar:0.49.0-alpha:compile
[INFO] |  +- com.google.cloud:google-cloud-core:jar:1.31.0:compile
[INFO] |  |  +- com.google.guava:guava:jar:20.0:compile
[INFO] |  |  +- joda-time:joda-time:jar:2.9.2:compile
[INFO] |  |  +- com.google.http-client:google-http-client:jar:1.23.0:compile
[INFO] |  |  |  \- org.apache.httpcomponents:httpclient:jar:4.0.1:compile
[INFO] |  |  |     +- org.apache.httpcomponents:httpcore:jar:4.0.1:compile
[INFO] |  |  |     +- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] |  |  |     \- commons-codec:commons-codec:jar:1.3:compile
[INFO] |  |  +- com.google.code.findbugs:jsr305:jar:3.0.1:compile
[INFO] |  |  +- com.google.api:api-common:jar:1.5.0:compile
[INFO] |  |  +- com.google.api:gax:jar:1.25.0:compile
[INFO] |  |  |  \- org.threeten:threetenbp:jar:1.3.3:compile
[INFO] |  |  +- com.google.protobuf:protobuf-java-util:jar:3.5.1:compile
[INFO] |  |  +- com.google.api.grpc:proto-google-common-protos:jar:1.11.0:compile
[INFO] |  |  \- com.google.api.grpc:proto-google-iam-v1:jar:0.12.0:compile
[INFO] |  +- com.google.cloud:google-cloud-core-grpc:jar:1.31.0:compile
[INFO] |  |  +- com.google.auth:google-auth-library-credentials:jar:0.9.1:compile
[INFO] |  |  +- com.google.protobuf:protobuf-java:jar:3.5.1:compile
[INFO] |  |  +- io.grpc:grpc-protobuf:jar:1.10.1:compile
[INFO] |  |  |  \- io.grpc:grpc-protobuf-lite:jar:1.10.1:compile
[INFO] |  |  +- io.grpc:grpc-context:jar:1.10.1:compile
[INFO] |  |  \- com.google.api:gax-grpc:jar:1.25.0:compile
[INFO] |  +- com.google.api.grpc:proto-google-cloud-speech-v1beta1:jar:0.14.0:compile
[INFO] |  +- com.google.api.grpc:proto-google-cloud-speech-v1p1beta1:jar:0.14.0:compile
[INFO] |  +- com.google.api.grpc:proto-google-cloud-speech-v1:jar:0.14.0:compile
[INFO] |  +- io.grpc:grpc-netty-shaded:jar:1.10.1:compile
[INFO] |  |  \- io.grpc:grpc-core:jar:1.10.1:compile (version selected from constraint [1.10.1,1.10.1])
[INFO] |  |     +- com.google.errorprone:error_prone_annotations:jar:2.1.2:compile
[INFO] |  |     \- io.opencensus:opencensus-contrib-grpc-metrics:jar:0.11.0:compile
[INFO] |  +- io.grpc:grpc-stub:jar:1.10.1:compile
[INFO] |  \- io.grpc:grpc-auth:jar:1.10.1:compile
[INFO] +- com.google.cloud:google-cloud-storage:jar:1.37.1:compile
[INFO] |  +- com.google.cloud:google-cloud-core-http:jar:1.37.1:compile
[INFO] |  |  +- com.google.auth:google-auth-library-oauth2-http:jar:0.9.1:compile
[INFO] |  |  +- com.google.oauth-client:google-oauth-client:jar:1.23.0:compile
[INFO] |  |  +- com.google.api-client:google-api-client:jar:1.23.0:compile
[INFO] |  |  +- com.google.http-client:google-http-client-appengine:jar:1.23.0:compile
[INFO] |  |  +- com.google.http-client:google-http-client-jackson:jar:1.23.0:compile
[INFO] |  |  |  \- org.codehaus.jackson:jackson-core-asl:jar:1.9.11:compile
[INFO] |  |  +- com.google.http-client:google-http-client-jackson2:jar:1.23.0:compile
[INFO] |  |  |  \- com.fasterxml.jackson.core:jackson-core:jar:2.1.3:compile
[INFO] |  |  +- com.google.api:gax-httpjson:jar:0.46.0:compile
[INFO] |  |  +- io.opencensus:opencensus-api:jar:0.12.3:compile
[INFO] |  |  \- io.opencensus:opencensus-contrib-http-util:jar:0.12.3:compile
[INFO] |  \- com.google.apis:google-api-services-storage:jar:v1-rev131-1.23.0:compile
[INFO] \- com.google.code.gson:gson:jar:2.8.0:compile