how solve that exception in java creating bar chart? [duplicate] - java

Anyone can tell me where can I find the full version of JFreeChart? I downloaded the JCommon and JFreeChart as well (from the sourceforge page), but the JFreeChart contains only the jfreechart-demo.jar, so even if I correctly added the libraries in Eclipse, it doesn't work either...
Many Thanks!

When unpacked, the required JAR files are in the lib directory.
$ ls -ln lib
total 5800
-rw-r--r--# 1 501 20 45024 Jul 31 2014 hamcrest-core-1.3.jar
-rw-r--r--# 1 501 20 330246 Jul 31 2014 jcommon-1.0.23.jar
-rw-r--r--# 1 501 20 13796 Jul 31 2014 jfreechart-1.0.19-experimental.jar
-rw-r--r--# 1 501 20 79793 Jul 31 2014 jfreechart-1.0.19-swt.jar
-rw-r--r--# 1 501 20 1570157 Jul 31 2014 jfreechart-1.0.19.jar
-rw-r--r--# 1 501 20 50769 Jul 31 2014 jfreesvg-2.0.jar
-rw-r--r--# 1 501 20 245039 Jul 31 2014 junit-4.11.jar
-rw-r--r--# 1 501 20 445025 Jul 31 2014 orsoncharts-1.4-eval-nofx.jar
-rw-r--r--# 1 501 20 72444 Jul 31 2014 orsonpdf-1.6-eval.jar
-rw-r--r--# 1 501 20 80054 Jul 31 2014 servlet.jar
-rw-r--r--# 1 501 20 17492 Jul 31 2014 swtgraphics2d.jar
For example, the following command line runs TimeSeriesChartDemo1 on Unix; separate class path entries with a semicolon (;) on Windows.
$ java -cp .:lib/* org.jfree.chart.demo.TimeSeriesChartDemo1

Related

kafka connect to Google BigQuery throws error java.lang.NoClassDefFoundError: org/apache/kafka/common/config/ConfigDef$CaseInsensitiveValidString

I am trying to stream from a Kafka topic to Google BigQuery. My connect-standalone.properties file is as follows:
bootstrap.servers=rhes75:9092,rhes75:9093,rhes75:9094,rhes564:9092,rhes564:9093,rhes564:9094,rhes76:9092,rhes76:9093,rhes76:9094
key.converter=org.apache.kafka.connect.storage.StringConverter
##value.converter=org.apache.kafka.connect.storage.StringConverter
value.converter=org.apache.kafka.connect.json.JsonConverter
key.converter.schemas.enable=false
value.converter.schemas.enable=false
##internal.key.converter=org.apache.kafka.connect.json.JsonConverter
internal.value.converter=org.apache.kafka.connect.json.JsonConverter
internal.key.converter=org.apache.kafka.connect.storage.StringConverter
##internal.value.converter=org.apache.kafka.connect.storage.StringConverter
internal.key.converter.schemas.enable=false
internal.value.converter.schemas.enable=false
offset.storage.file.filename=/tmp/connect_bq.offsets
offset.flush.interval.ms=10000
#plugin.path=/d4T/hduser/bigquery-kafka-connect-sink/share/kafka/plugins
plugin.path=/d4T/hduser/bigquery-kafka-connect-sink/share/kafka/plugins/wepay-kafka-connect-bigquery-2.1.0
and my bigquery-sink.properties is as below
name=bigquery-sink
connector.type=bigquery-connector
connector.class=com.wepay.kafka.connect.bigquery.BigQuerySinkConnector
defaultDataset=test
project=axial-glow-224522
topics=md
autoCreateTables=false
gcsBucketName=tmp_storage_bucket
queueSize=-1
bigQueryRetry=0
bigQueryRetryWait=1000
bigQueryMessageTimePartitioning=false
bigQueryPartitionDecorator=true
timePartitioningType=DAY
keySource=FILE
keyfile=/home/hduser/xyz.json
sanitizeTopics=false
schemaRetriever=com.wepay.kafka.connect.bigquery.retrieve.IdentitySchemaRetriever
threadPoolSize=10
allBQFieldsNullable=false
avroDataCacheSize=100
batchLoadIntervalSec=120
convertDoubleSpecialValues=false
enableBatchLoad=false
upsertEnabled=false
deleteEnabled=false
mergeIntervalMs=60_000L
mergeRecordsThreshold=-1
autoCreateBucket=true
allowNewBigQueryFields=false
allowBigQueryRequiredFieldRelaxation=false
allowSchemaUnionization=false
kafkaDataFieldName=null
kafkaKeyFieldName=null
I run the code as below
#!/bin/ksh
unset CLASSPATH
export CLASSPATH=/d4T/hduser/bigquery-kafka-connect-sink/share/kafka/plugins/wepay-kafka-connect-bigquery-2.1.0/lib:$KAFKA_HOME/libs
export KAFKA_DEBUG=y
$KAFKA_HOME/bin/connect-standalone.sh \
/d4T/hduser/bigquery-kafka-connect-sink/etc/connect-standalone.properties \
/d4T/hduser/bigquery-kafka-connect-sink/etc/bigquery-sink.properties
It comes back with this error
[2021-03-13 18:17:38,499] INFO Started o.e.j.s.ServletContextHandler#2ecf5915{/,null,AVAILABLE} (org.eclipse.jetty.server.handler.ContextHandler:744)
[2021-03-13 18:17:38,503] INFO Started http_8083#6badba10{HTTP/1.1}{0.0.0.0:8083} (org.eclipse.jetty.server.ServerConnector:266)
[2021-03-13 18:17:38,503] INFO Started #1981ms (org.eclipse.jetty.server.Server:379)
[2021-03-13 18:17:38,503] INFO Advertised URI: http://50.140.197.220:8083/ (org.apache.kafka.connect.runtime.rest.RestServer:248)
[2021-03-13 18:17:38,503] INFO REST server listening at http://50.140.197.220:8083/, advertising URL http://50.140.197.220:8083/ (org.apache.kafka.connect.runtime.rest.RestServer:207)
[2021-03-13 18:17:38,503] INFO Kafka Connect started (org.apache.kafka.connect.runtime.Connect:55)
[2021-03-13 18:17:38,518] ERROR Stopping after connector error (org.apache.kafka.connect.cli.ConnectStandalone:113)
java.lang.NoClassDefFoundError: org/apache/kafka/common/config/ConfigDef$CaseInsensitiveValidString
at com.wepay.kafka.connect.bigquery.config.BigQuerySinkConfig.getConfig(BigQuerySinkConfig.java:505)
at com.wepay.kafka.connect.bigquery.BigQuerySinkConnector.config(BigQuerySinkConnector.java:79)
at org.apache.kafka.connect.connector.Connector.validate(Connector.java:132)
at org.apache.kafka.connect.runtime.AbstractHerder.validateConnectorConfig(AbstractHerder.java:277)
at org.apache.kafka.connect.runtime.standalone.StandaloneHerder.putConnectorConfig(StandaloneHerder.java:164)
at org.apache.kafka.connect.cli.ConnectStandalone.main(ConnectStandalone.java:107)
Caused by: java.lang.ClassNotFoundException: org.apache.kafka.common.config.ConfigDef$CaseInsensitiveValidString
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at org.apache.kafka.connect.runtime.isolation.PluginClassLoader.loadClass(PluginClassLoader.java:104)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
It complains about not finding this class
Caused by: java.lang.ClassNotFoundException: org.apache.kafka.common.config.ConfigDef$CaseInsensitiveValidString
However, under directory
/d4T/hduser/bigquery-kafka-connect-sink/share/kafka/plugins/wepay-kafka-connect-bigquery-2.1.0/lib
it is in kafka-clients-1.1.0.jar
jar tvf kafka-clients-1.1.0.jar|grep org.apache.kafka.common.config.ConfigDef$CaseInsensitiveValidString
2051 Fri Mar 23 22:54:26 GMT 2018 org/apache/kafka/common/config/ConfigDef$1.class
1175 Fri Mar 23 22:54:26 GMT 2018 org/apache/kafka/common/config/ConfigDef$2.class
2876 Fri Mar 23 22:54:26 GMT 2018 org/apache/kafka/common/config/ConfigDef$3.class
1132 Fri Mar 23 22:54:26 GMT 2018 org/apache/kafka/common/config/ConfigDef$4.class
1801 Fri Mar 23 22:54:26 GMT 2018 org/apache/kafka/common/config/ConfigDef$CompositeValidator.class
3274 Fri Mar 23 22:54:26 GMT 2018 org/apache/kafka/common/config/ConfigDef$ConfigKey.class
1255 Fri Mar 23 22:54:26 GMT 2018 org/apache/kafka/common/config/ConfigDef$Importance.class
1104 Fri Mar 23 22:54:26 GMT 2018 org/apache/kafka/common/config/ConfigDef$NonEmptyString.class
2144 Fri Mar 23 22:54:26 GMT 2018 org/apache/kafka/common/config/ConfigDef$NonEmptyStringWithoutControlChars.class
922 Fri Mar 23 22:54:26 GMT 2018 org/apache/kafka/common/config/ConfigDef$NonNullValidator.class
2072 Fri Mar 23 22:54:26 GMT 2018 org/apache/kafka/common/config/ConfigDef$Range.class
583 Fri Mar 23 22:54:26 GMT 2018 org/apache/kafka/common/config/ConfigDef$Recommender.class
1513 Fri Mar 23 22:54:26 GMT 2018 org/apache/kafka/common/config/ConfigDef$Type.class
293 Fri Mar 23 22:54:26 GMT 2018 org/apache/kafka/common/config/ConfigDef$Validator.class
1943 Fri Mar 23 22:54:26 GMT 2018 org/apache/kafka/common/config/ConfigDef$ValidList.class
2196 Fri Mar 23 22:54:26 GMT 2018 org/apache/kafka/common/config/ConfigDef$ValidString.class
1269 Fri Mar 23 22:54:26 GMT 2018 org/apache/kafka/common/config/ConfigDef$Width.class
34225 Fri Mar 23 22:54:26 GMT 2018 org/apache/kafka/common/config/ConfigDef.class
So I have no idea what is missing in here?
The jars loaded are shown below
jvm.classpath = /d4T/hduser/bigquery-kafka-connect-sink/share/kafka/plugins/wepay-kafka-connect-bigquery-2.1.0/lib:/data6/hduser/kafka_2.12-1.1.0/libs:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/aopalliance-repackaged-2.5.0-b32.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/argparse4j-0.7.0.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/commons-lang3-3.5.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/connect-api-1.1.0.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/connect-file-1.1.0.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/connect-json-1.1.0.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/connect-runtime-1.1.0.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/connect-transforms-1.1.0.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/guava-20.0.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/hk2-api-2.5.0-b32.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/hk2-locator-2.5.0-b32.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/hk2-utils-2.5.0-b32.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/jackson-annotations-2.9.4.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/jackson-core-2.9.4.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/jackson-databind-2.9.4.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/jackson-jaxrs-base-2.9.4.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/jackson-jaxrs-json-provider-2.9.4.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/jackson-module-jaxb-annotations-2.9.4.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/javassist-3.20.0-GA.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/javassist-3.21.0-GA.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/javax.annotation-api-1.2.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/javax.inject-1.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/javax.inject-2.5.0-b32.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/javax.servlet-api-3.1.0.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/javax.ws.rs-api-2.0.1.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/jersey-client-2.25.1.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/jersey-common-2.25.1.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/jersey-container-servlet-2.25.1.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/jersey-container-servlet-core-2.25.1.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/jersey-guava-2.25.1.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/jersey-media-jaxb-2.25.1.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/jersey-server-2.25.1.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/jetty-client-9.2.24.v20180105.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/jetty-continuation-9.2.24.v20180105.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/jetty-http-9.2.24.v20180105.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/jetty-io-9.2.24.v20180105.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/jetty-security-9.2.24.v20180105.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/jetty-server-9.2.24.v20180105.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/jetty-servlet-9.2.24.v20180105.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/jetty-servlets-9.2.24.v20180105.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/jetty-util-9.2.24.v20180105.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/jopt-simple-5.0.4.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/kafka-clients-1.1.0.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/kafka-log4j-appender-1.1.0.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/kafka-streams-1.1.0.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/kafka-streams-examples-1.1.0.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/kafka-streams-test-utils-1.1.0.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/kafka-tools-1.1.0.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/kafka_2.12-1.1.0-sources.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/kafka_2.12-1.1.0-test-sources.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/kafka_2.12-1.1.0.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/log4j-1.2.17.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/lz4-java-1.4.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/maven-artifact-3.5.2.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/metrics-core-2.2.0.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/osgi-resource-locator-1.0.1.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/plexus-utils-3.1.0.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/reflections-0.9.11.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/rocksdbjni-5.7.3.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/scala-library-2.12.4.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/scala-logging_2.12-3.7.2.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/scala-reflect-2.12.4.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/slf4j-api-1.7.25.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/slf4j-log4j12-1.7.25.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/snappy-java-1.1.7.1.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/validation-api-1.1.0.Final.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/zkclient-0.10.jar:/data6/hduser/kafka_2.12-1.1.0/bin/../libs/zookeeper-3.4.10.jar
os.spec = Linux, amd64, 3.10.0-1062.9.1.el7.x86_64
os.vcpus = 6
Thanks all.
I was using an older Kafka version.
I upgraded Kafka in the cluster from kafka_2.12-1.1.0 to the latest stable version kafka_2.12-2.7.0. I also upgraded zookeeper from zookeeper-3.4.6 to apache-zookeeper-3.6.2-bin version.
In addition in the run file I added the following:
#!/bin/ksh
unset CLASSPATH
export CLASSPATH=/d4T/hduser/bigquery-kafka-connect-sink/share/kafka/plugins:$KAFKA_HOME/libs
$KAFKA_HOME/bin/connect-standalone.sh \
/d4T/hduser/bigquery-kafka-connect-sink/etc/connect-standalone.properties \
/d4T/hduser/bigquery-kafka-connect-sink/etc/bigquery-sink.properties
where the first part of CLASSPATH comes from plugins
plugin.path=/d4T/hduser/bigquery-kafka-connect-sink/share/kafka/plugins
This solved the issue

The finer points of runnable jar creation (Jersey & Genson)

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)
com.owlike.genson.ext.jaxrs.JerseyAutoDiscoverable
org.glassfish.jersey.logging.LoggingFeatureAutoDiscoverable
org.glassfish.jersey.server.filter.internal.ServerFiltersAutoDiscoverable
org.glassfish.jersey.internal.spi.ForcedAutoDiscoverable (2)
org.glassfish.jersey.jaxb.internal.JaxbAutoDiscoverable
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

Problems packaging apps with Jersey deps into jars

My group publishes executable jars (not applets, just to be clear) for nearly all of our functionality. One of our new executables is a Web service client that relies on Jersey. I'm trying to use the automatic POJO mapping facility to unmarshal responses (i.e., I have JSONConfiguration.FEATURE_POJO_MAPPING set to true in the ClientConfig) but when I execute the jar I get the "I don't know how to unmarshal this response" message:
SEVERE: A message body reader for Java class edu.mit.broad.picard.bass.GetSite, and Java type class edu.mit.broad.picard.bass.GetSite, and MIME media type application/json was not found
The app works just fine if I run it from my IDE (IntelliJ). I'm assuming it's a problem with the way in which the jar file is packaged but I don't know the details of Jersey (or Jackson, for that matter) well enough to get this fixed. Any hints?
This is Java 1.7, Jersey bundle 1.17.1 and Jackson 1.9.13. All the com/sun/**/* and org/codehaus/**/* files are being included in the jar.
Thanks for your help!!
Edit:
I checked the META-INF dir for the needed .../services dir. Here's what's in it:
cm59f-0fa:zamboni jrose$ jar tvf GenerateGetSite.jar | grep META-INF | grep services
0 Thu Aug 15 10:43:32 EDT 2013 META-INF/services/
0 Thu Feb 28 15:29:04 EST 2013 META-INF/services/com.sun.jersey.server.impl.model.method.dispatch.ResourceMethodDispatchProvider
514 Thu Feb 28 15:29:04 EST 2013 META-INF/services/com.sun.jersey.spi.HeaderDelegateProvider
563 Thu Feb 28 15:29:04 EST 2013 META-INF/services/com.sun.jersey.spi.StringReaderProvider
147 Thu Feb 28 15:29:04 EST 2013 META-INF/services/com.sun.jersey.spi.container.ContainerProvider
60 Thu Feb 28 15:29:04 EST 2013 META-INF/services/com.sun.jersey.spi.container.ContainerRequestFilter
0 Thu Feb 28 15:29:04 EST 2013 META-INF/services/com.sun.jersey.spi.container.ContainerResponseFilter
377 Wed Feb 27 20:17:28 EST 2013 META-INF/services/com.sun.jersey.spi.container.ResourceMethodCustomInvokerDispatchProvider
376 Wed Feb 27 20:17:28 EST 2013 META-INF/services/com.sun.jersey.spi.container.ResourceMethodDispatchProvider
64 Thu Feb 28 15:29:04 EST 2013 META-INF/services/com.sun.jersey.spi.container.WebApplicationProvider
267 Thu Feb 28 15:29:04 EST 2013 META-INF/services/com.sun.jersey.spi.inject.InjectableProvider
44 Wed Feb 27 20:17:06 EST 2013 META-INF/services/javax.enterprise.inject.spi.Extension
882 Mon Dec 19 14:53:22 EST 2011 META-INF/services/javax.script.ScriptEngineFactory
79 Wed Feb 27 20:17:06 EST 2013 META-INF/services/javax.servlet.ServletContainerInitializer
2880 Thu Feb 28 15:29:04 EST 2013 META-INF/services/javax.ws.rs.ext.MessageBodyReader
2654 Thu Feb 28 15:29:04 EST 2013 META-INF/services/javax.ws.rs.ext.MessageBodyWriter
56 Thu Feb 28 15:29:04 EST 2013 META-INF/services/javax.ws.rs.ext.RuntimeDelegate`
My guess would be that you are creating one jar that contains the contents of all of your jar dependencies. If this is the case, the issue is probably due to improper construction of your one jar. Jersey relies on resources in META-INF/services for its proper operation. You need to make sure that the contents of META-INF/services get merged into your one jar.
One option that is working for me is the maven-shade-plugin, which includes a transformer that does exactly this merging:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
</transformers>
</configuration>
</plugin>

JavaFX Builder 1.0 unable to open a file

I get the following error when I try to open a .fxml file from Netbeans:
StaffRota.fxml:101: error:
java.lang.IllegalArgumentException: Invalid URL or resource not found
the code I have in that xml is:
<ImageView id="image1.jpg" layoutX="150.0" layoutY="18.0">
<image>
<Image url="/theatre/room/allocation/src/misc/image1.jpg" preserveRatio="true" smooth="true" />
</image>
</ImageView>`
My java application builds and deploys fine (and renders the image correctly). Why would JavaFX builder complain? Is it because the image is within the application?
Here's what I get if I do -tvf tra.jar:-
C:\Users\..\Documents>jar -tvf tra.jar
0 Mon Jun 17 19:54:26 BST 2013 META-INF/
425 Mon Jun 17 19:54:26 BST 2013 META-INF/MANIFEST.MF
0 Mon Jun 17 19:54:26 BST 2013 theatre/
0 Mon Jun 17 19:54:26 BST 2013 theatre/room/
0 Mon Jun 17 19:54:26 BST 2013 theatre/room/allocation/
..
2563 Mon Jun 17 19:54:26 BST 2013 theatre/room/allocation/src/misc/image1.jpg
..
Fixed by changing the url to #../src/misc/image1.jpg

Reading txt file from jar fails but reading image works

I have an issue which has been bothering me for days... I checked similar questions but couldn't find a solution.
I use NetBeans IDE. I build the project jar file i.e "Clock.jar" which contains a "clock" named folder in which some images, a text file and all project classes are found.
The following code for creating an image icon works
return new ImageIcon(getClass().getResource("/clock/button_close.png"));
But the following code for reading the text file fails
InputStream name = getClass().getResourceAsStream("/clock/input.txt");
BufferedReader reader = new BufferedReader(new InputStreamReader(name));
As you may have guessed the NullPointer Exception is thrown meaning probably it couln't locate the file.
But how come the image icon is constructed successfully (by passing it the URL returned from getResource) but the txt file cannot be found (by passing it an input stream from getResourceAsStream).
Thanks in advance, for any answer ( I mean it :) )
jar -tvf Clock.jar
0 Wed May 15 14:44:36 EEST 2013 META-INF/
202 Wed May 15 14:44:34 EEST 2013 META-INF/MANIFEST.MF
0 Wed May 15 14:44:36 EEST 2013 clock/
649 Wed May 15 14:44:36 EEST 2013 clock/Clock$1$1.class
789 Wed May 15 14:44:36 EEST 2013 clock/Clock$1.class
2026 Wed May 15 14:44:36 EEST 2013 clock/Clock.class
709 Wed May 15 14:44:36 EEST 2013 clock/ClockDialog$1.class
830 Wed May 15 14:44:36 EEST 2013 clock/ClockDialog$2.class
750 Wed May 15 14:44:36 EEST 2013 clock/ClockDialog$3.class
713 Wed May 15 14:44:36 EEST 2013 clock/ClockDialog$4.class
741 Wed May 15 14:44:36 EEST 2013 clock/ClockDialog$5.class
708 Wed May 15 14:44:36 EEST 2013 clock/ClockDialog$6.class
1081 Wed May 15 14:44:36 EEST 2013 clock/ClockDialog$7.class
981 Wed May 15 14:44:36 EEST 2013 clock/ClockDialog$8.class
9640 Wed May 15 14:44:36 EEST 2013 clock/ClockDialog.class
702 Wed May 15 14:44:36 EEST 2013 clock/ClockFrame$1.class
708 Wed May 15 14:44:36 EEST 2013 clock/ClockFrame$2.class
734 Wed May 15 14:44:36 EEST 2013 clock/ClockFrame$3.class
743 Wed May 15 14:44:36 EEST 2013 clock/ClockFrame$4.class
531 Wed May 15 14:44:36 EEST 2013 clock/ClockFrame$5.class
1046 Wed May 15 14:44:36 EEST 2013 clock/ClockFrame$6.class
9464 Wed May 15 14:44:36 EEST 2013 clock/ClockFrame.class
782 Wed May 15 14:44:36 EEST 2013 clock/ErrorReporter.class
1826 Wed May 15 14:44:36 EEST 2013 clock/IconButton.class
2693 Wed May 15 14:44:36 EEST 2013 clock/MessagePool.class
2824 Wed May 15 14:44:36 EEST 2013 clock/SystemInfo.class
2212 Wed May 15 14:44:36 EEST 2013 clock/button_close.png
6540 Wed May 15 14:44:36 EEST 2013 clock/button_close_highlighted.png
5668 Wed May 15 14:44:36 EEST 2013 clock/input.txt
Looking at the source again closely, try..
URL url = getClass().getResource("/clock/input.txt");
InputStream name = url.openStream();
I recall that the Class::getResourceAsStream variant deals with paths slightly differently than simply Class::getResource - I am sure it should work for the latter one.

Categories

Resources