jersey with jetty - runnable jar

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

jersey with jetty - runnable jar

avner.eizner

I'm using embedded Jetty with Jersey to form a REST API.

When I export from Eclipse using the Runnable JAR wizard,
if I select "[Package required libraries into generated JAR",
when I run the JAR, I get the error:

"The ResourceConfig instance does not contain any root resource classes"


If I select "Extract required libraries into generated JAR", I get the error:
"Internal Server Error"

Anyone got any fixes or workarounds?
Reply | Threaded
Open this post in threaded view
|

Re: jersey with jetty - runnable jar

Pavel Bucek-2
Hello,

"Extract required libraries into generated JAR" should work, but you
have to make sure that /META-INF/services/* files are merged correctly.
You could be able to workaround that by depending (extracting) only
jersey-bundle, which should have all services already merged..

Regards,
Pavel


On 9/2/11 2:10 PM, avner.eizner wrote:

> I'm using embedded Jetty with Jersey to form a REST API.
>
> When I export from Eclipse using the Runnable JAR wizard,
> if I select "[Package required libraries into generated JAR",
> when I run the JAR, I get the error:
>
> "The ResourceConfig instance does not contain any root resource classes"
>
>
> If I select "Extract required libraries into generated JAR", I get the
> error:
> "Internal Server Error"
>
> Anyone got any fixes or workarounds?
>
> --
> View this message in context: http://jersey.576304.n2.nabble.com/jersey-with-jetty-runnable-jar-tp6753636p6753636.html
> Sent from the Jersey mailing list archive at Nabble.com.
>

Reply | Threaded
Open this post in threaded view
|

Re: jersey with jetty - runnable jar

avner.eizner
Thanks for the answer,
but even when I do Extract it does not work for me.
I get the following output:



C:\test\server>java -jar server.jar
2011-09-03 21:06:41.775:INFO::Logging to STDERR via org.mortbay.log.StdErrLog
2011-09-03 21:06:41.818:INFO::jetty-6.1.x
2011-09-03 21:06:41.876:INFO::Started SocketConnector@0.0.0.0:8080
±⌠Φ 03, 2011 9:06:44 PM com.sun.jersey.api.core.PackagesResourceConfig init
INFO: Scanning for root resource and provider classes in the packages:
  restServlets
±⌠Φ 03, 2011 9:06:45 PM com.sun.jersey.api.core.ScanningResourceConfig logClasse
s
INFO: Root resource classes found:
  class restServlets.Test
±⌠Φ 03, 2011 9:06:45 PM com.sun.jersey.api.core.ScanningResourceConfig init
INFO: No provider classes found.
±⌠Φ 03, 2011 9:06:45 PM com.sun.jersey.server.impl.application.WebApplicationImp
l _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.8 06/24/2011 12:17 PM'
±⌠Φ 03, 2011 9:06:45 PM com.sun.jersey.spi.container.ContainerResponse write
SEVERE: A message body writer for Java class java.lang.String, and Java type class java.lang.String, and MIME media type text/plain was not found
±⌠Φ 03, 2011 9:06:45 PM com.sun.jersey.spi.container.ContainerResponse write
SEVERE: The registered message body writers compatible with the MIME media type are:
*/* ->
  com.sun.jersey.server.impl.template.ViewableMessageBodyWriter

±⌠Φ 03, 2011 9:06:45 PM com.sun.jersey.spi.container.ContainerResponse logException
SEVERE: Mapped exception to response: 500 (Internal Server Error)
javax.ws.rs.WebApplicationException: com.sun.jersey.api.MessageException: A message body writer for Java class java.lang.String, and Java type class java.lang.String, and MIME media type text/plain was not found
        at com.sun.jersey.spi.container.ContainerResponse.write(ContainerRespons
e.java:285)
        at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1437)
        at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)
        at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339)
        at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
        at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
        at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:699)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
        at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:401)
        at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
        at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
        at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
        at org.mortbay.jetty.Server.handle(Server.java:326)
        at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
        at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:928)
        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
        at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
        at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: com.sun.jersey.api.MessageException: A message body writer for Java class java.lang.String, and Java type class java.lang.String, and MIME media type text/plain was not found
        ... 21 more
Reply | Threaded
Open this post in threaded view
|

Re: jersey with jetty - runnable jar

Pavel Bucek-2
yeah, that kind of proves I'm right about the cause.

Can you please make sure that META-INF/servces/* is correctly unpacked
into your jar and file named

META-INF/services/javax.ws.rs.ext.MessageBodyWriter

contains:

com.sun.jersey.core.impl.provider.entity.StringProvider
com.sun.jersey.core.impl.provider.entity.ByteArrayProvider
com.sun.jersey.core.impl.provider.entity.FileProvider
com.sun.jersey.core.impl.provider.entity.InputStreamProvider
com.sun.jersey.core.impl.provider.entity.DataSourceProvider
com.sun.jersey.core.impl.provider.entity.RenderedImageProvider
com.sun.jersey.core.impl.provider.entity.MimeMultipartProvider
com.sun.jersey.core.impl.provider.entity.FormProvider
com.sun.jersey.core.impl.provider.entity.FormMultivaluedMapProvider
com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$App
com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$Text
com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$General
com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$App
com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$Text
com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$General
com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$App
com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$Text
com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$General
com.sun.jersey.core.impl.provider.entity.ReaderProvider
com.sun.jersey.core.impl.provider.entity.DocumentProvider
com.sun.jersey.core.impl.provider.entity.StreamingOutputProvider
com.sun.jersey.core.impl.provider.entity.SourceProvider$SourceWriter
com.sun.jersey.server.impl.template.ViewableMessageBodyWriter
com.sun.jersey.atom.rome.impl.provider.entity.AtomFeedProvider
com.sun.jersey.atom.rome.impl.provider.entity.AtomEntryProvider
com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider$App
com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider$General
com.sun.jersey.json.impl.provider.entity.JSONJAXBElementProvider$App
com.sun.jersey.json.impl.provider.entity.JSONJAXBElementProvider$General
com.sun.jersey.json.impl.provider.entity.JSONListElementProvider$App
com.sun.jersey.json.impl.provider.entity.JSONListElementProvider$General
com.sun.jersey.json.impl.provider.entity.JSONArrayProvider$App
com.sun.jersey.json.impl.provider.entity.JSONArrayProvider$General
com.sun.jersey.json.impl.provider.entity.JSONObjectProvider$App
com.sun.jersey.json.impl.provider.entity.JSONObjectProvider$General
com.sun.jersey.json.impl.provider.entity.JSONWithPaddingProvider
com.sun.jersey.json.impl.provider.entity.JacksonProviderProxy
com.sun.jersey.fastinfoset.impl.provider.entity.FastInfosetRootElementProvider
com.sun.jersey.fastinfoset.impl.provider.entity.FastInfosetJAXBElementProvider
com.sun.jersey.fastinfoset.impl.provider.entity.FastInfosetListElementProvider


Pavel

On 9/3/11 8:15 PM, avner.eizner wrote:

> Thanks for the answer,
> but even when I do Extract it does not work for me.
> I get the following output:
>
>
>
> C:\test\server>java -jar server.jar
> 2011-09-03 21:06:41.775:INFO::Logging to STDERR via
> org.mortbay.log.StdErrLog
> 2011-09-03 21:06:41.818:INFO::jetty-6.1.x
> 2011-09-03 21:06:41.876:INFO::Started SocketConnector@0.0.0.0:8080
> ±⌠Φ 03, 2011 9:06:44 PM com.sun.jersey.api.core.PackagesResourceConfig init
> INFO: Scanning for root resource and provider classes in the packages:
>    restServlets
> ±⌠Φ 03, 2011 9:06:45 PM com.sun.jersey.api.core.ScanningResourceConfig
> logClasse
> s
> INFO: Root resource classes found:
>    class restServlets.Test
> ±⌠Φ 03, 2011 9:06:45 PM com.sun.jersey.api.core.ScanningResourceConfig init
> INFO: No provider classes found.
> ±⌠Φ 03, 2011 9:06:45 PM
> com.sun.jersey.server.impl.application.WebApplicationImp
> l _initiate
> INFO: Initiating Jersey application, version 'Jersey: 1.8 06/24/2011 12:17
> PM'
> ±⌠Φ 03, 2011 9:06:45 PM com.sun.jersey.spi.container.ContainerResponse write
> SEVERE: A message body writer for Java class java.lang.String, and Java type
> class java.lang.String, and MIME media type text/plain was not found
> ±⌠Φ 03, 2011 9:06:45 PM com.sun.jersey.spi.container.ContainerResponse write
> SEVERE: The registered message body writers compatible with the MIME media
> type are:
> */* ->
>    com.sun.jersey.server.impl.template.ViewableMessageBodyWriter
>
> ±⌠Φ 03, 2011 9:06:45 PM com.sun.jersey.spi.container.ContainerResponse
> logException
> SEVERE: Mapped exception to response: 500 (Internal Server Error)
> javax.ws.rs.WebApplicationException: com.sun.jersey.api.MessageException: A
> message body writer for Java class java.lang.String, and Java type class
> java.lang.String, and MIME media type text/plain was not found
>          at
> com.sun.jersey.spi.container.ContainerResponse.write(ContainerRespons
> e.java:285)
>          at
> com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1437)
>          at
> com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)
>          at
> com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339)
>          at
> com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
>          at
> com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
>          at
> com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:699)
>          at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
>          at
> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
>          at
> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:401)
>          at
> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
>          at
> org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
>          at
> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
>          at org.mortbay.jetty.Server.handle(Server.java:326)
>          at
> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
>          at
> org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:928)
>          at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
>          at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
>          at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
>          at
> org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
>          at
> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
> Caused by: com.sun.jersey.api.MessageException: A message body writer for
> Java class java.lang.String, and Java type class java.lang.String, and MIME
> media type text/plain was not found
>          ... 21 more
>
>
> --
> View this message in context: http://jersey.576304.n2.nabble.com/jersey-with-jetty-runnable-jar-tp6753636p6757080.html
> Sent from the Jersey mailing list archive at Nabble.com.
>

Reply | Threaded
Open this post in threaded view
|

Re: jersey with jetty - runnable jar

avner.eizner
Hurrah! It works!

But now I have the problem in MessageBodyReader..
the output:

SEVERE: A message body reader for Java class java.lang.String, and Java type class java.lang.String, and MIME media type text/plain was not found.
The registered message body readers compatible with the MIME media type are:
*/* ->
  com.sun.jersey.json.impl.provider.entity.JSONJAXBElementProvider$General
  com.sun.jersey.json.impl.provider.entity.JSONArrayProvider$General
  com.sun.jersey.json.impl.provider.entity.JSONObjectProvider$General
  com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider$General
  com.sun.jersey.json.impl.provider.entity.JSONListElementProvider$General
  com.sun.jersey.json.impl.provider.entity.JacksonProviderProxy

How do I handle this automatically?
Or how i can extract only jersey-bundle?
Is it possible to use with "Package", and fix it by use of jetty context setClassLoader ?
Reply | Threaded
Open this post in threaded view
|

Re: jersey with jetty - runnable jar

Pavel Bucek-2
Yeah. You need to do it for all META-INF/services/* files and the
easiest way to do it should be just take jersey-bundle.jar and unpack it
(or use some Eclipse feature which could automatically merge them - I
don't use Eclipse so I'm not very familiar with that).

jersey-bundle.jar is available at:
https://maven.java.net/content/repositories/releases/com/sun/jersey/jersey-bundle/1.9/jersey-bundle-1.9.jar

unpack it manually and explore META-INF/services dir (or just take it
from there). You should be able to do it "automatically" by depending on
jersey-bundle only (my guess is that you are depending on jersey-server
(and other transitive dependencies) and "unpack" process just rewrites
META-INF/services/*).

Pavel

On 9/5/11 11:21 AM, avner.eizner wrote:

> Hurrah! It works!
>
> But now I have the problem in MessageBodyReader..
> the output:
>
> SEVERE: A message body reader for Java class java.lang.String, and Java type
> class java.lang.String, and MIME media type text/plain was not found.
> The registered message body readers compatible with the MIME media type are:
> */* ->
>    com.sun.jersey.json.impl.provider.entity.JSONJAXBElementProvider$General
>    com.sun.jersey.json.impl.provider.entity.JSONArrayProvider$General
>    com.sun.jersey.json.impl.provider.entity.JSONObjectProvider$General
>    com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider$General
>    com.sun.jersey.json.impl.provider.entity.JSONListElementProvider$General
>    com.sun.jersey.json.impl.provider.entity.JacksonProviderProxy
>
> How do I handle this automatically?
> Or how i can extract only jersey-bundle?
> Is it possible to use with "Package", and fix it by use of jetty context
> setClassLoader ?
>
>
> --
> View this message in context: http://jersey.576304.n2.nabble.com/jersey-with-jetty-runnable-jar-tp6753636p6760278.html
> Sent from the Jersey mailing list archive at Nabble.com.
>

Reply | Threaded
Open this post in threaded view
|

Re: jersey with jetty - runnable jar

avner.eizner
Thanks, it is work!

2011/9/5 Pavel Bucek-2 [via Jersey] <[hidden email]>
Yeah. You need to do it for all META-INF/services/* files and the
easiest way to do it should be just take jersey-bundle.jar and unpack it
(or use some Eclipse feature which could automatically merge them - I
don't use Eclipse so I'm not very familiar with that).

jersey-bundle.jar is available at:
https://maven.java.net/content/repositories/releases/com/sun/jersey/jersey-bundle/1.9/jersey-bundle-1.9.jar

unpack it manually and explore META-INF/services dir (or just take it
from there). You should be able to do it "automatically" by depending on
jersey-bundle only (my guess is that you are depending on jersey-server
(and other transitive dependencies) and "unpack" process just rewrites
META-INF/services/*).

Pavel

On 9/5/11 11:21 AM, avner.eizner wrote:

> Hurrah! It works!
>
> But now I have the problem in MessageBodyReader..
> the output:
>
> SEVERE: A message body reader for Java class java.lang.String, and Java type
> class java.lang.String, and MIME media type text/plain was not found.
> The registered message body readers compatible with the MIME media type are:
> */* ->
>    com.sun.jersey.json.impl.provider.entity.JSONJAXBElementProvider$General
>    com.sun.jersey.json.impl.provider.entity.JSONArrayProvider$General
>    com.sun.jersey.json.impl.provider.entity.JSONObjectProvider$General
>    com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider$General
>    com.sun.jersey.json.impl.provider.entity.JSONListElementProvider$General
>    com.sun.jersey.json.impl.provider.entity.JacksonProviderProxy
>
> How do I handle this automatically?
> Or how i can extract only jersey-bundle?
> Is it possible to use with "Package", and fix it by use of jetty context
> setClassLoader ?
>
>
> --
> View this message in context: http://jersey.576304.n2.nabble.com/jersey-with-jetty-runnable-jar-tp6753636p6760278.html

> Sent from the Jersey mailing list archive at Nabble.com.
>




If you reply to this email, your message will be added to the discussion below:
http://jersey.576304.n2.nabble.com/jersey-with-jetty-runnable-jar-tp6753636p6761089.html
To unsubscribe from jersey with jetty - runnable jar, click here.


--
אבנר אייזנר
[hidden email]