[Solved] WebServer startup fails with ArrayIndexOutOfBounds-Exception

Hallo everyone!

I just created a new Web Service-project from scratch and marked the RESTful Web Services setting.
All jars have been automatically downloaded and the example HelloWorld.java file is opened.
When I try to execute it, I get the following ArrayIndexOutOfBounds-Exception.

18.11.2011 16:38:47 com.sun.jersey.api.core.ClasspathResourceConfig init

INFO: Scanning for root resource and provider classes in the paths:
  /usr/lib64/jvm/java-1.6.0-sun-1.6.0/jre/lib/alt-rt.jar
  /usr/lib64/jvm/java-1.6.0-sun-1.6.0/jre/lib/resources.jar
  /usr/lib64/jvm/java-1.6.0-sun-1.6.0/jre/lib/deploy.jar
  /usr/lib64/jvm/java-1.6.0-sun-1.6.0/jre/lib/charsets.jar
  /usr/lib64/jvm/java-1.6.0-sun-1.6.0/jre/lib/plugin.jar
  /usr/lib64/jvm/java-1.6.0-sun-1.6.0/jre/lib/javaws.jar
  /usr/lib64/jvm/java-1.6.0-sun-1.6.0/jre/lib/rt.jar
  /usr/lib64/jvm/java-1.6.0-sun-1.6.0/jre/lib/jce.jar
  /usr/lib64/jvm/java-1.6.0-sun-1.6.0/jre/lib/management-agent.jar
  /usr/lib64/jvm/java-1.6.0-sun-1.6.0/jre/lib/jsse.jar
  /usr/lib64/jvm/java-1.6.0-sun-1.6.0/jre/lib/ext/sunpkcs11.jar
  /usr/lib64/jvm/java-1.6.0-sun-1.6.0/jre/lib/ext/localedata.jar
  /usr/lib64/jvm/java-1.6.0-sun-1.6.0/jre/lib/ext/sunjce_provider.jar
  /usr/lib64/jvm/java-1.6.0-sun-1.6.0/jre/lib/ext/dnsns.jar
  /home
  /home/bjacobs/Dokumente/Java Entwicklung/WSTest/out/production/WSTest
  /home/bjacobs/Dokumente/Java Entwicklung/WSTest/lib/activation-1.1.jar
  /home/bjacobs/Dokumente/Java Entwicklung/WSTest/lib/asm-3.1.jar
  /home/bjacobs/Dokumente/Java Entwicklung/WSTest/lib/FastInfoset-1.2.2.jar
  /home/bjacobs/Dokumente/Java Entwicklung/WSTest/lib/grizzly-servlet-webserver-1.9.18-i.jar
  /home/bjacobs/Dokumente/Java Entwicklung/WSTest/lib/http-20070405.jar
  /home/bjacobs/Dokumente/Java Entwicklung/WSTest/lib/jaxb-api-2.1.jar
  /home/bjacobs/Dokumente/Java Entwicklung/WSTest/lib/jaxb-impl-2.1.10.jar
  /home/bjacobs/Dokumente/Java Entwicklung/WSTest/lib/localizer.jar
  /home/bjacobs/Dokumente/Java Entwicklung/WSTest/lib/jaxb-xjc.jar
  /home/bjacobs/Dokumente/Java Entwicklung/WSTest/lib/jackson-core-asl-1.1.1.jar
  /home/bjacobs/Dokumente/Java Entwicklung/WSTest/lib/jdom-1.0.jar
  /home/bjacobs/Dokumente/Java Entwicklung/WSTest/lib/jersey-bundle-1.3.jar
  /home/bjacobs/Dokumente/Java Entwicklung/WSTest/lib/jersey-multipart-1.3.jar
  /home/bjacobs/Dokumente/Java Entwicklung/WSTest/lib/jettison-1.1.jar
  /home/bjacobs/Dokumente/Java Entwicklung/WSTest/lib/jsr311-api-1.1.1.jar
  /home/bjacobs/Dokumente/Java Entwicklung/WSTest/lib/mail-1.4.jar
  /home/bjacobs/Dokumente/Java Entwicklung/WSTest/lib/rome-0.9.jar
  /home/bjacobs/Dokumente/Java Entwicklung/WSTest/lib/stax-api-1.0-2.jar
  /home/bjacobs/Dokumente/Java Entwicklung/WSTest/lib/wadl-core.jar
  /home/bjacobs/Dokumente/Java Entwicklung/WSTest/lib/wadl-cmdline.jar
  /home/bjacobs/Dokumente/Java Entwicklung/WSTest/lib/wadl2java.jar
  /opt/idea-IU-107.105/lib/idea_rt.jar
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
    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:130)
    at com.sun.jersey.core.spi.scanning.FilesScanner$1.f(FilesScanner.java:104)
    at com.sun.jersey.core.util.Closing.f(Closing.java:68)
    at com.sun.jersey.core.spi.scanning.FilesScanner.scanDir(FilesScanner.java:101)
    at com.sun.jersey.core.spi.scanning.FilesScanner.scanDir(FilesScanner.java:92)
    at com.sun.jersey.core.spi.scanning.FilesScanner.scanDir(FilesScanner.java:92)
    at com.sun.jersey.core.spi.scanning.FilesScanner.scanDir(FilesScanner.java:92)
    at com.sun.jersey.core.spi.scanning.FilesScanner.scanDir(FilesScanner.java:92)
    at com.sun.jersey.core.spi.scanning.FilesScanner.scanDir(FilesScanner.java:92)
    at com.sun.jersey.core.spi.scanning.FilesScanner.scanDir(FilesScanner.java:92)
    at com.sun.jersey.core.spi.scanning.FilesScanner.scan(FilesScanner.java:77)
    at com.sun.jersey.core.spi.scanning.FilesScanner.scan(FilesScanner.java:71)
    at com.sun.jersey.api.core.ScanningResourceConfig.init(ScanningResourceConfig.java:69)
    at com.sun.jersey.api.core.ClasspathResourceConfig.init(ClasspathResourceConfig.java:128)
    at com.sun.jersey.api.core.ClasspathResourceConfig.<init>(ClasspathResourceConfig.java:102)
    at com.sun.jersey.api.container.ContainerFactory.createContainer(ContainerFactory.java:250)
    at com.sun.jersey.api.container.ContainerFactory.createContainer(ContainerFactory.java:233)
    at com.sun.jersey.api.container.httpserver.HttpServerFactory.create(HttpServerFactory.java:114)
    at com.sun.jersey.api.container.httpserver.HttpServerFactory.create(HttpServerFactory.java:89)
    at example.HelloWorld.main(HelloWorld.java:29)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)


Process finished with exit code 1

The line of code where the Exception happens:
HttpServer server = HttpServerFactory.create("http://localhost:9998/");

I didn't change anything on the code. So any suggestions, what might be the problem here? Changing the port didn't help...

Thank you!
Björn

1 comment

Ok, I solved the problem myself after hours of confusion. :)

I found a similar error description on this IBM site. ( http://www-01.ibm.com/support/docview.wss?uid=swg1PK81656 )

The reason for this error was explained as: "An 'AnnotationException' may occur when a corrupt Java class is scanned for annotations"
This led me to checking which paths were scanned for classes. In my case somehow under "Platform settings / SDKs" I had an entry "/home" which also got scanned for classes. This is where this error occured. After removing this entry, everything works fine. :^O

Greetings,
Björn

0

Please sign in to leave a comment.