java.lang.NoClassDefFoundError: Could not initialize class org.jfree.chart.JFreeChart
On Windows, a GUI system is always available.
Why such error still occur on Windows?
How to solve?
I use tomcat 7 with JFreeChart 1.0.14.
Please make sure you have library file of jfree in your classpath.
If you are using maven adding this dependency shall work,
<dependency>
<groupId>jfree</groupId>
<artifactId>jfreechart</artifactId>
<version>1.0.14</version>
Its not an issue of windows, make sure you are including the jar of jfreechart in your classpath, if you are using maven use
<dependency>
<groupId>jfree</groupId>
<artifactId>jfreechart</artifactId>
<version>1.0.13</version> <!--Use any valid version-->
</dependency>
If not using maven, downlaod the jar and add to your lib folder
Related
Building a relatively simple jetty app, following the instructions here:
http://www.eclipse.org/jetty/documentation/9.4.x/maven-and-jetty.html
I'm not using Jersey, but mvn jetty:run complains about
Provider com.sun.jersey.server.impl.container.servlet.JerseyServletContainerInitializer not found
My pom.xml does not include any reference to Jersey. In fact, it is quite simple:
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${jettyVersion}</version>
</dependency>
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-solrj</artifactId>
<version>6.0.1</version>
</dependency>
What is making jetty look for Jersey?
Search all of your dependencies for META-INF/services/javax.servlet.ServletContainerInitializer files.
The one that has the entry for com.sun.jersey.server.impl.container.servlet.JerseyServletContainerInitializer is the one causing you problems.
Look at your project dependencies (aka <project><dependencies>) and your project's configuration of jetty-maven-plugin to see if that <plugin> has any extra dependencies added to it (aka <plugin><dependencies>).
Well, after much machination, and gnashing of teeth, I think I stumbled about the answer. Whilst learning about maven, I was playing with shaded uber-jars. I had compiled one of the packages as an uper-jar, and installed it. When maven put it all together, it added a bit too much and broke my dependencies. Removing the shaded jar for local installation and just using it for distribution worked just fine.
I am trying to use spark mllib.jar in web project. I downloaded spark-1.1.0-bin-hadoop2.4 and unzipped. There are some jar found as follows:
datanucleus-api-jdi-3.2.1.jar
datanucleus-core-3.2.2.jar
datanucleus-rdbms-3.2.1.jar
spark-assembly-1.1.0-hadoop2.4.0.jar
spark-examples-1.1.0-hadoop2.4.0.jar
Then I use spark-assembly-1.1.0-hadoop2.4.0.jar to import classification methods. It can be run successfully in java project. However when I add the jar to SomeWebProject/web-inf/lib, it turns out error messages:
validateJarFile ...\web-inf\lib\spark-assembly-1.1.0-hadoop2.4.0.jar jar not loaded. offending class:javax/servlet/servlet.class
I know it because my web project javax.servlet class is duplicated with spark jar. I try to delete spark's javax.servlet. It still not working.
Could you please tell me how to figure it out
and
Can I use other spark jar to run mllib in local mode. This jar is too large and it is about 132 mb and I think some of them are useless. But I cannot find any other available jars. Is this jar the only way to import spark-mllib.jar?
p.s. For some reasons I can not deploy spark in my servers. So I could not use hadoop environments
Thanks very much!!!
If you can use maven then just add these dependencies to your pom.xml:
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-mllib_2.11</artifactId>
<version>1.3.0</version>
</dependency>
I cant find javax.ejb.jar in my .m2 dirctory, I need this jar for import javax.ejb.Schedule; , here is my pom file entry.
<dependency>
<groupId>javax.ejb</groupId>
<artifactId>ejb-api</artifactId>
<version>3.0</version>
<scope>provided</scope>
</dependency>
I am not sure if it will work or not, or its a right way to do things. Can some one please help to make a change in the POM file so that it downloads javax.ejb.jar into the .m2 directory.
Updated
by .m2 I mean in the repository directory in the correct folder
hierarchy (What ever it is).
Why? We have multiple sub projects (In eclipse workspace), In order to resolve dependency we use M2_REPO/path/to/the/required_library_file.jar, Now theses projects are part of code bases, Every developer download the source code, Maven download all jar to the repository directory(of the developer using any OS/Platform). This relative path from M2_REPO helps developer to have consitenat code (for eclipse project). Otherwise everyone will be adding their own path.
If it still doesn't make sense, here is what I want, Please give me an entry for POM file which download the javax.ejb.jar file into .m2 directory what ever the sub path is.
I have to include this jar in every project manually (And every developer needs to them as well from what ever directory have glassfish (C: , D:, E:, or /home/glassfish/modules/)
D:\servers\glassfish-3.1.2\glassfish3\glassfish\modules\javax.ejb.jar
where rest of the jars in each project are included as M2_REPO/path/to/jar which makes less no changes in the code base to commit.
M2_REPO/javax/ejb/ejb-api/3.0/ejb-api-3.0.jar
M2_REPO/javax/enterprise/cdi-api/1.0-SP1/cdi-api-1.0-SP1.jar
M2_REPO/javax/inject/javax.inject/1/javax.inject-1.jar
etc etc
I think I hear what you mean now :)
The maven dependency you specify
<dependency>
<groupId>javax.ejb</groupId>
<artifactId>ejb-api</artifactId>
<version>3.0</version>
<scope>provided</scope>
</dependency>
which you have in .m2/repository/javax/ueb/ejb-api/3.0/ejb-api-3.0.jar does not contain the class/interface javax.ejb.Schedule.
But you found the jar-file in your glassfish server, which does contain javax.ejb.Scheduleand its name is D:\servers\glassfish-3.1.2\glassfish3\glassfish\modules\javax.ejb.jar and now you ask how to get that into the pom?
Well, the Java EE APIs and their official jars in maven are somewhat a study in disharmony.
If you run a search on maven central you will find multiple jars containing exactly that class. You will probably note that all appserver vendors provide their own edition of every aspect of every api in every version.
You should be able to find a jar with the javax.ejb module from glassfish in version 3.1.2
http://search.maven.org/#artifactdetails|org.glassfish|javax.ejb|3.1.2|jar
in which case the dependency would be
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.ejb</artifactId>
<version>3.1.2</version>
<scope>provided</scope>
</dependency>
I found another artifactId here, though maven has your version too.
A (very) weird maven caching problem? Then it might work tomorrow.
<dependency>
<groupId>javax.ejb</groupId>
<artifactId>javax.ejb-api</artifactId>
<version>3.2</version>
</dependency>
Though this is a new version, for compilation it should do.
You may need to provide the repository location in your pom.xml file or in .m2/settings.xml file for the required jar to get downloaded into .m2 directory.
The dependency is declared as provided what means that the container will provide it.
What container are you using? I think Tomcat/Jetty won't provide that jar as it seems so Java EE. In that case just change the scope to compile.
<dependency>
<groupId>javax.ejb</groupId>
<artifactId>ejb-api</artifactId>
<version>3.0</version>
<scope>compile</scope>
</dependency>
More info about dependency scopes:
http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope
I am trying to use EqualsBuilder in the apache commons library. So, I downloaded commons-lang3-3.1.jar from the apache site, and in Eclipse I configured my build path to add it to my set of libraries. I see it listed in my libraries, and if I hit cmd+shift+o it automatically adds this import:
import org.apache.commons.lang3.builder.EqualsBuilder;
However, when I run my application and try to use it, I get:
Could not find class 'org.apache.commons.lang3.builder.EqualsBuilder', referenced from method com.gnychis.awmon.DeviceAbstraction.Interface.equals
Is there something simple I'm missing, here?
Having in build path just satisfies compile time requirement
You need to add it to your project runtime also (If it is web-app, add it to lib folder)
In case you are using maven, add the following dependency to your pom.xml file:
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.9</version>
</dependency>
Or if you ever need "lang" dependencies rather than "lang3", use this one instead:
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
I have the following dependency in my pom.xml
<dependency>
<groupId>javax.sql</groupId>
<artifactId>jdbc-stdext</artifactId>
<version>2.0</version>
<scope>system</scope>
<systemPath>${java.home}/lib/rt.jar</systemPath>
</dependency>
My problem is I'm trying to build on a Mac (10.6.4) which doesn't have an rt.jar.
Is there a different system path I should be using for doing a build on OS X? Is there a clean way to specify this in my pom.xml with out breaking the pom for developers using windows?
The equivalent to this jar is /System/Library/Frameworks/JavaVM.framework/Home/bundle/Classes/classes.jar. But as this dependency is basically a dependency to the JRE, you don't really need it.