0

I can create a runnable jar every time with Eclipse's Runnable Jar wizard. If I check the box for Eclipse to "Save as ANT script", then incorporate that code into build.xml and then have our GitLab CI process do a build & create a runnable jar, it runs, but it can't seem to find a class in that jar even though the .class file is in there.

I'm not sure where to start. The resulting jar files from the Eclipse build vs the standalone java/ant build are similar, but not exactly the same. A few things are out of order, but that's all I can put my finger on at the moment.

How can I start to hone in on this? My program is a Jersey web client. I'm using Genson and the error message I'm getting with the standalone jar build is

org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyWriter not found for media type=application/json

But I can list the jar files and both have these entries

        47 Sun Mar 27 22:23:48 CDT 2016 META-INF/services/javax.ws.rs.ext.MessageBodyWriter
  1220 Thu Aug 07 14:08:08 CDT 2014 javax/ws/rs/ext/MessageBodyWriter.class            

Right now I can get around it by doing a build in Eclipse and manually deploying the file, but of course this isn't acceptable.

EDIT: Thanks to a helpful friend, I was pointed to the contents of META-INF/services. I don't know what it means, but here are the contents of that from both jars.

GitLab jar (get MessageBodyWriter error message)
     0 Sun Mar 27 22:23:48 CDT 2016 META-INF/services/
    47 Sun Mar 27 22:23:48 CDT 2016 META-INF/services/javax.json.spi.JsonProvider
    47 Sun Mar 27 22:23:48 CDT 2016 META-INF/services/javax.ws.rs.ext.MessageBodyReader
    47 Sun Mar 27 22:23:48 CDT 2016 META-INF/services/javax.ws.rs.ext.MessageBodyWriter
    47 Sun Mar 27 22:23:48 CDT 2016 META-INF/services/javax.ws.rs.ext.Providers
    50 Sun Mar 27 22:23:48 CDT 2016 META-INF/services/org.glassfish.jersey.internal.spi.AutoDiscoverable
    61 Fri May 27 19:08:18 CDT 2016 META-INF/services/org.glassfish.hk2.extension.ServiceLocatorGenerator
    60 Thu Oct 27 14:32:12 CDT 2016 META-INF/services/org.glassfish.jersey.internal.spi.AutoDiscoverable
    67 Thu Oct 27 14:32:12 CDT 2016 META-INF/services/javax.servlet.ServletContainerInitializer
    67 Thu Oct 27 14:32:12 CDT 2016 META-INF/services/org.glassfish.jersey.servlet.spi.AsyncContextDelegateProvider
    63 Thu Oct 27 14:32:12 CDT 2016 META-INF/services/org.glassfish.jersey.servlet.spi.FilterUrlMappingsProvider
    56 Thu Oct 27 14:32:12 CDT 2016 META-INF/services/org.glassfish.jersey.internal.spi.ForcedAutoDiscoverable
    56 Thu Oct 27 14:32:12 CDT 2016 META-INF/services/javax.ws.rs.ext.RuntimeDelegate
    73 Thu Oct 27 14:32:12 CDT 2016 META-INF/services/org.glassfish.jersey.internal.spi.AutoDiscoverable
   137 Thu Oct 27 14:32:12 CDT 2016 META-INF/services/org.glassfish.jersey.internal.spi.ForcedAutoDiscoverable
   855 Sun Oct 02 11:14:44 CDT 2016 META-INF/services/javax.annotation.processing.Processor

Eclipse jar (works)
      0 Tue Dec 13 08:55:42 CST 2016 META-INF/services/
     47 Tue Dec 13 08:55:42 CST 2016 META-INF/services/javax.json.spi.JsonProvider
     47 Tue Dec 13 08:55:42 CST 2016 META-INF/services/javax.ws.rs.ext.MessageBodyReader
     47 Tue Dec 13 08:55:42 CST 2016 META-INF/services/javax.ws.rs.ext.MessageBodyWriter
     47 Tue Dec 13 08:55:42 CST 2016 META-INF/services/javax.ws.rs.ext.Providers
     50 Tue Dec 13 08:55:42 CST 2016 META-INF/services/org.glassfish.jersey.internal.spi.AutoDiscoverable
     61 Tue Dec 13 08:55:42 CST 2016 META-INF/services/org.glassfish.hk2.extension.ServiceLocatorGenerator
     67 Tue Dec 13 08:55:42 CST 2016 META-INF/services/javax.servlet.ServletContainerInitializer
     67 Tue Dec 13 08:55:42 CST 2016 META-INF/services/org.glassfish.jersey.servlet.spi.AsyncContextDelegateProvider
     63 Tue Dec 13 08:55:42 CST 2016 META-INF/services/org.glassfish.jersey.servlet.spi.FilterUrlMappingsProvider
     56 Tue Dec 13 08:55:42 CST 2016 META-INF/services/org.glassfish.jersey.internal.spi.ForcedAutoDiscoverable
     56 Tue Dec 13 08:55:42 CST 2016 META-INF/services/javax.ws.rs.ext.RuntimeDelegate
    855 Tue Dec 13 08:55:44 CST 2016 META-INF/services/javax.annotation.processing.Processor

EDIT3: The contents of each duplicate org.glassfish.jersey.internal.spi.AutoDiscoverable (3)

  1. com.owlike.genson.ext.jaxrs.JerseyAutoDiscoverable
  2. org.glassfish.jersey.logging.LoggingFeatureAutoDiscoverable
  3. org.glassfish.jersey.server.filter.internal.ServerFiltersAutoDiscoverable

org.glassfish.jersey.internal.spi.ForcedAutoDiscoverable (2)

  1. org.glassfish.jersey.jaxb.internal.JaxbAutoDiscoverable
  2. org.glassfish.jersey.logging.LoggingFeatureAutoDiscoverable

Versus the "good" jar file, built by Eclipse, which has no duplicates:

in org.glassfish.jersey.internal.spi.AutoDiscoverable com.owlike.genson.ext.jaxrs.JerseyAutoDiscoverable

I guess I'll plow through other META-INF things, so see what can be seen.

in org.glassfish.jersey.internal.spi.ForcedAutoDiscoverable org.glassfish.jersey.jaxb.internal.JaxbAutoDiscoverable

Kelly Beard
  • 684
  • 1
  • 8
  • 20
  • What's the content of the files under META-INF/services ? – eugen Dec 12 '16 at 22:57
  • @eugen, They are different. I've edited my post to reflect this. – Kelly Beard Dec 13 '16 at 14:58
  • It looks like there is some duplication or additional jar being included in the automated build? I'm checking that configuration. – Kelly Beard Dec 13 '16 at 15:05
  • what is the content of those files, here you list the files under services. My question is what's inside, especially the first 4 ones javax.ws.rs.ext.* and javax.json.spi.JsonProvider – eugen Dec 13 '16 at 20:16
  • I suspect that during your build the duplicate files are not being merged properly and the Genson extension is being lost, thus it can't be found at runtime. – eugen Dec 13 '16 at 20:17
  • @eugen Seems odd that Eclipse can do this correctly and ant cannot, when using a build file that Eclipse itself generated. I've added other stuff to the post, for all the good it will probably do. Seems I've stumped SO again. :-) – Kelly Beard Dec 14 '16 at 15:07
  • what about the content of other files MessageBodyXXX and Providers? – eugen Dec 15 '16 at 06:34

0 Answers0