0

I have written a sample HTTPServer using Jersey. It works fine when I start it via eclipse. I have tested using Postman.

I built a runnable jar and tried to start it, I am getting below error and server is not starting up. Please let me know what am missing here.

       SEVERE: The provider class, class com.sun.jersey.server.impl.model.parameter.mul
tivalued.JAXBStringReaderProviders$RootElementProvider, could not be instantiate
d. Processing will continue but the class will not be utilized
java.lang.IllegalArgumentException: argument type mismatch
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Sou
rce)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at com.sun.jersey.core.spi.component.ComponentConstructor._getInstance(C
omponentConstructor.java:210)
        at com.sun.jersey.core.spi.component.ComponentConstructor.getInstance(Co
mponentConstructor.java:180)
        at com.sun.jersey.core.spi.component.ProviderFactory.__getComponentProvi
der(ProviderFactory.java:166)
        at com.sun.jersey.core.spi.component.ProviderFactory.getComponentProvide
r(ProviderFactory.java:137)
        at com.sun.jersey.core.spi.component.ProviderServices.getComponent(Provi
derServices.java:283)
        at com.sun.jersey.core.spi.component.ProviderServices.getProvidersAndSer
vices(ProviderServices.java:176)
        at com.sun.jersey.server.impl.model.parameter.multivalued.StringReaderFa
ctory.init(StringReaderFactory.java:60)
        at com.sun.jersey.server.impl.application.WebApplicationImpl._initiate(W
ebApplicationImpl.java:1341)
        at com.sun.jersey.server.impl.application.WebApplicationImpl.access$700(
WebApplicationImpl.java:180)
        at com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApp
licationImpl.java:799)
        at com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApp
licationImpl.java:795)
        at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:193)
        at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(We
bApplicationImpl.java:795)
        at com.sun.jersey.api.container.ContainerFactory.createContainer(Contain
erFactory.java:172)
        at com.sun.jersey.api.container.ContainerFactory.createContainer(Contain
erFactory.java:134)
        at com.sun.jersey.api.container.httpserver.HttpServerFactory.create(Http
ServerFactory.java:172)


May 01, 2016 12:42:04 AM com.sun.jersey.spi.inject.Errors processErrorMessages
SEVERE: The following errors and warnings have been detected with resource and/o
r provider classes:
  SEVERE: Missing dependency for constructor public com.sun.jersey.server.impl.m
odel.parameter.multivalued.JAXBStringReaderProviders$RootElementProvider(com.sun
.jersey.spi.inject.Injectable,javax.ws.rs.ext.Providers) at parameter index 0
Exception in thread "main" com.sun.jersey.spi.inject.Errors$ErrorMessagesExcepti
on
        at com.sun.jersey.spi.inject.Errors.processErrorMessages(Errors.java:170
)
        at com.sun.jersey.spi.inject.Errors.postProcess(Errors.java:136)
        at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:199)
        at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(We
bApplicationImpl.java:795)
        at com.sun.jersey.api.container.ContainerFactory.createContainer(Contain
erFactory.java:172)
        at com.sun.jersey.api.container.ContainerFactory.createContainer(Contain
erFactory.java:134)
        at com.sun.jersey.api.container.httpserver.HttpServerFactory.create(Http
ServerFactory.java:172)

My Main method looks like this :

public static void main( String[] args ) throws Exception {
        if ( args.length != 2 ) {
            logger.fatal( "Please pass port and config file path. " );
            System.exit( 1 );
        }

        port = Integer.parseInt( args[0].trim() );
        startServer();
        logger.info( "Started server successfully on port --> " + port );
    }

    private static void startServer() throws Exception {
        URI uri = UriBuilder.fromUri( "http://localhost/" ).port( port ).build();
        ResourceConfig rc = new PackagesResourceConfig( "my.test.apihandlers" );
        HttpServer server = HttpServerFactory.create( uri, rc );

        server.start();
    }
LPD
  • 2,833
  • 2
  • 29
  • 48
  • I think there are more on this stacktrace that you are not showing. Stacktrace should be readed from bottom to top. You showed just the top level of it. Can you post the entire stacktrace please? – Jorge Campos Apr 30 '16 at 19:20
  • @JorgeCampos, Thanks for your reply. I have posted the entire trace. – LPD Apr 30 '16 at 19:24
  • Take a look here at this [other post](http://stackoverflow.com/questions/21181605/jersey-error-jaxbstringreaderprovidersrootelementprovider) it may help – Jorge Campos Apr 30 '16 at 19:32
  • Is this an uber jar? If so, check [this out](http://stackoverflow.com/q/36687312/2587435) – Paul Samsotha May 01 '16 at 00:08

0 Answers0