2016-07-13 6 views
1

私は、Ideellによって作成されたデフォルトのHelloWorldサンプルを使用してIntelli jideaでRestful Web Serviceプロジェクトを作成しました。私はそれを実行しようとすると、私はこのエラーIntellij Rest Serviceプロジェクト - java.lang.ArrayIndexOutOfBoundsException

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 256 
at org.objectweb.asm.ClassReader.readClass(Unknown Source) 
at org.objectweb.asm.ClassReader.accept(Unknown Source) 
at org.objectweb.asm.ClassReader.accept(Unknown Source) 
at com.sun.jersey.spi.scanning.AnnotationScannerListener.onProcess(AnnotationScannerListener.java:133) 
at com.sun.jersey.core.spi.scanning.JarFileScanner.scan(JarFileScanner.java:97) 
at com.sun.jersey.core.spi.scanning.JarFileScanner$1.f(JarFileScanner.java:74) 
at com.sun.jersey.core.util.Closing.f(Closing.java:71) 
at com.sun.jersey.core.spi.scanning.JarFileScanner.scan(JarFileScanner.java:71) 
at com.sun.jersey.core.spi.scanning.FilesScanner.scan(FilesScanner.java:83) 
at com.sun.jersey.core.spi.scanning.FilesScanner.scan(FilesScanner.java:74) 
at com.sun.jersey.api.core.ScanningResourceConfig.init(ScanningResourceConfig.java:80) 
at com.sun.jersey.api.core.ClasspathResourceConfig.init(ClasspathResourceConfig.java:119) 
at com.sun.jersey.api.core.ClasspathResourceConfig.<init>(ClasspathResourceConfig.java:101) 
at com.sun.jersey.api.container.ContainerFactory.createContainer(ContainerFactory.java:263) 
at com.sun.jersey.api.container.ContainerFactory.createContainer(ContainerFactory.java:246) 
at com.sun.jersey.api.container.httpserver.HttpServerFactory.create(HttpServerFactory.java:117) 
at com.sun.jersey.api.container.httpserver.HttpServerFactory.create(HttpServerFactory.java:92) 
at example.HelloWorld.main(HelloWorld.java:26) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:498) 
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) 
私はすでにバージョン2.2、1.2試さ

とジャージーライブラリの1.0を得た

package example; 
import com.sun.net.httpserver.HttpServer; 
import com.sun.jersey.api.container.httpserver.HttpServerFactory; 
import java.io.IOException; 

import javax.ws.rs.GET; 
import javax.ws.rs.Produces; 
import javax.ws.rs.Path; 

/** 
    * Created by UNAL on 12.07.2016. 
    */ 
// The Java class will be hosted at the URI path "/helloworld" 
@Path("/helloworld") 
public class HelloWorld { 
    // The Java method will process HTTP GET requests 
    @GET 
    // The Java method will produce content identified by the MIME Media type "text/plain" 
    @Produces("text/plain") 
    public String getClichedMessage() { 
     // Return some cliched textual content 
     return "Hello World"; 
    } 

    public static void main(String[] args) throws IOException { 
     HttpServer server = HttpServerFactory.create("http://localhost:9998/"); 
     server.start(); 

     System.out.println("Server running"); 
     System.out.println("Visit: http://localhost:9998/helloworld"); 
     System.out.println("Hit return to stop..."); 
     System.in.read(); 
     System.out.println("Stopping server"); 
     server.stop(0); 
     System.out.println("Server stopped"); 
    } 
} 

。 Jdk 1.8.0_91

+0

新しいジャージライブラリを使用して、新しいコードを投稿してください。これは本当に古いものです。私はそれがjideaとするsthを持っていると思ういけない。 – Apostolos

+0

jerseyの新しいバージョンにはHttpServerFactoryクラスが含まれていません。最新のJerseyでコードを生成するにはどうすればよいですか? – amlelanu

答えて

2

これはJava 8で問題と思われます。同じ例外があり、私がJDK 7を使用するためにJavaバージョンを変更したとき、それは不平を言いました。

+0

私はIntellij Ideaの最新バージョンをインストールしました。結果は同じです。私はあなたが言ったようにJDK 7を試してみます。 – amlelanu

+1

はあなたと同じことをしてくれました。 JDK 8と同じエラー、JDK 7のエラーが発生しました。 – Apostolos

+0

@unalelmaは動作しましたか? – Apostolos

0

私はジャージの最新バージョン(1.19.4)を試してみました、それはJDK 8 Mavenの依存関係で動作します:

<dependency> 
    <groupId>com.sun.jersey</groupId> 
    <artifactId>jersey-server</artifactId> 
    <version>1.19.4</version> 
</dependency> 
関連する問題