eclipse: java.lang.ClassNotFoundException: org.eclipse.emf.ecore.EObject driving me bananas? - eclipse

Hell folks, i have eclipse Version: Helios Service Release 1 Build id: 20100917-0705.
Does someone know how to get rid of this nasty exception?
I've tried with a brand new indigo installation, brand new tomcat 7.0.22, to no avail, what could be wrong with my project?
I'm using geotools.
Ok, I somewhat found the cause. When I use Geotools' DataStoreFinder.getDataStore() method the exception shows up. if I use other methods everything's fine.
What puzzles me, and the main reason to ask this question here, is because one would expect other kind of exception, like a geotools exception, but, why an eclipse exception? however, if someone finds ever the reason, I'll be more than glad to listen about it.
if you want to replicate it, these are the steps to follow:
download geotools (exception 'works' with vers 2.7 and 8)
eclipse indigo or helios
apache tomcat 6 or 7
jdk 1.6
create a simple servlet and just call DataStoreFinder.getDataStore() inside the doget or dopost method.

Just a guess, but sounds like you don't have EMF installed and Geotools must depend on it. EObject is the EMF base class. If you used p2 to install Geotools though, it should have made sure that EMF was already installed. If however you just copied the plugins for it into your Eclipse installation and did not have EMF, you would see this.

Related

Class not found when using JAX-RS with Eclipse and Glassfish

I am using Eclipse Luna (versions 4.4.2) and Glassfish 4 to build a REST web-app using JAX-RS.
The following piece of code, which is just a very simple post to the REST api that was previously working just fine, has started throw a very strange error:
#POST
public Response addToWatchlist(WatchlistEntry watchlistentry)
{
return Response.ok(watchlist_service.addToWatchlist(watchlistentry).toString()).build();
}
The error is below:
Warning: StandardWrapperValve[Jersey Web Application]: Servlet.service() for servlet Jersey Web Application threw exception
java.lang.ClassNotFoundException: javax.xml.parsers.ParserConfigurationException not found by org.eclipse.persistence.moxy
All I have been able to find out about this is this webpage:
https://java.net/jira/browse/JERSEY-2888
One of the comments says this has been fixed in EclipseLink 2.6.1 and Jersey 2.19.
I am pretty new to using MAVEN and eclipse - assuming the above is correct, how do I get my Maven Project in Eclipse to update the Jersey version? Also how do I update the EclipseLink version? Their site only seems to have version 2.6.0 available: http://www.eclipse.org/eclipselink/#download
I assume all this can be done through eclipse itself?
All help appreciated!
EDIT 1: It seems like eclipselink 2.6.1 has been released on Oct 15th 2015, as you can see here: http://www.eclipse.org/eclipselink/releases/
However, as you can see here, it doesn't seem to have been incorporated into eclipse for "help -> update software": http://download.eclipse.org/rt/eclipselink/updates/
Which is highly annoying.
I am building my REST website, and no PUT or POST will work because of this error.
Does anybody know how to get 2.6.1 working? I am using a Maven jersey-quickstart-webapp Project.
This bug is a royal pain in the face.
EDIT 2: I've got a hack working today. When I check programmtically what version of eclipselink is being used at runtime like below, it tells me it is version 2.6.1, even though the bug remains:
Class<?> myClass = Class.forName("org.eclipse.persistence.Version");
Method myMethod = myClass.getMethod("getVersion");
String version = myMethod.invoke(null).toString();
System.out.println("version = " + version);
In a related question (How to find what version of EclipseLink my Eclipse Project is using?) I found out how to find the actual jar files glassfish is using for eclipse. They are in the glassfish/modules directory. Inside the org.eclipse.persistence.core.jar file has will be a readme.html which tells you the version of eclipselink that glassfish is using. For me it was 2.6.
I manually updated the org.eclipse.persistence.core.jar and the org.eclipse.persistence.moxy.jar file with the latest versions from the maven site. While this is quite hacky, as I don't know what else is effected by doing this, it does get over this problem. If I find out the correct way to do this, I will write an answer below, for all and sundry.
Going through the Jersey JIRA and eclipse link website it seems like Eclipse link 2.6.1 is still under development i.e. not yet released. That's why its not available for download.
To use an updated version of Jersey in maven you need to give depending to the newer version 2.19 in your pom.xml.
But, since eclipse link 2.6.1 is yet to be released, even if you use newer version of Jersey it might be of little use. But still you can give it a try.
To update version of jersey, find the following dependency and update the value of version tag in your pom.xml file
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>2.22.1</version>
</dependency>
Which server are you deploying your project into? I've had A LOT of problems with Glassfish 4.1.1 (incluiding that error). I downgraded to 4.1 and everything runs fine. It may be due to a problem with 4.1.1 newest modules (jars incluided in the server). I hope it helps. Its not the best solution but for me was a temporary workaround 'till I find which modules are failing.
The problem was solved by updating the version of eclipselink that glassfish was using. Eclipse updated it's version, but glassfish needs it's own update. The list of jar files that need to be placed in the glassfish/modules directory is given in this answer: How to change EclipseLink in GlashFish 4.0?

Eclipse: Can not find the tag library descriptor for "http://java.sun.com/jsf/core" using JBoss

I know this question was asked a lot of times, since I searched for hours for a solution, but it was never answered (or at least not for my situation).
I am using Wildfly 8.0 (ex JBoss), so I understand that I do not need to add jstl jars nor JSF jars since the implementation is already shipped with JBoss.
Now even when telling eclipse to use the Wildfly runtime libraries, I get the above error. I checked and the jboss-jstl-api_1.2_spec-1.0.4.Final.jar is part of the library
How can I get through this? I tried putting downloading jstl jars (from https://jstl.java.net/) and putting them in the lib directory but it is not working.
Copying the jars into "lib" works perfectly when I use Tomcat which doesn't have its jstl implementation. But not with Wildfly (maybe because eclipse ignores the jars I put in the lib directory since Wildfly has its own jars? But then why do I get the error in the first place? I am confused).
Thanks to anyone who could help me with this.
Edit: I forgot to precise that even with these errors on all my JSPs, the project builds and works perfectly on the server.
These errors are eclipse specific, it does not recognize the taglibs and displays annoying error messages at taglib declarations and warnings when using these (unknown to eclipse) tags. Plus, I can't use code completion.
Edit: I bypassed the problem, for the moment, by adding standalone myfaces and jstl libraries to the build path. I would like though that eclipse uses the jars available on server side. (For JPA for example I did not need to add the hibernate library to the build path, I simply told eclipse that the JPA implementation si available on server runtime and it worked fine with code completion and everything).
Alright, to not have to add any additional libraries (that are not needed by the server) here's what I had to do in addition to adding the Wildfly runtime library to the project:
Go to Project/Properties/Project Facets/Java Server Faces and chose Library Provided by Target Runtime in the library type (instead of a User Library).
I'm truly disappointed JSF support in eclipse. I'm encountering such caveats all the time.
I'm using JBoss 7.1.1 and even adding JBoss as the Target Runtime of the project didn't help.
The only solution that worked for me, was to define new JSF library inside Eclipse: Window Preferences -> Java -> Build Path -> User Libraries -> click New (pointing to the jsf-impl.jar and jsf-api.jar). And then adding such library to the build path of the project.
It solved all annoying eclipse errors can not find tag library. So it is pretty similar to the #Riccatti first solution.
Btw: answer which I found on the eclipse forum says that this error is usually caused by not existing JSF tag libraries (that are present in jsf-impl.jar) on the classpath.

Eclipse configuration to support dual Equinox/Felix environments

What are some configuration changes to make Eclipse PDE best support working with both Equinox and Felix?
Here's an example problem I'm currently having. I can run my application ok via the Eclipse OSGi Framework launcher. Similarly, there are no compilation problems in PDE. However, when running in Felix I will get NoClassDefFoundErrors:
java.lang.NoClassDefFoundError: org/w3c/dom/DOMException
My understanding is it's my Eclipse setup that is at fault here; org.w3c.dom is not a 'default' OSGi package and shouldn't be loaded when I run it in Eclipse. Similarly, the import in my code for org.w3c.dom.DOMException should be an error.
I know how to fix this for Felix: declare an Import-Package. But that's not my question. My question is how to force Eclipse PDE to take on a closer configuration to Felix... basically to make it stricter in loading packages?
I think Equinox does behave like Felix, if you run it stand alone. It's more of an Eclipse legacy thing than an Equinox thing, as stated on osgi.org.
As far as I know, there isn't any way to override the boot delegation from Eclipse, but I'd love to be proven wrong, as I've faced this problem often.
If you are developing a server application I recommend to not use the PDE at all. I am using maven and the maven bundle plugin to develop my bundles. Then I deploy on Apache karaf. Debugging also is quite simple by using the karaf dev:watch command and remote debugging. I never really missed the PDE features and they never worked well with my maven build.
This sounds like that launcher is setting bootdelegation to legacy mode. See the following page on the OSGi Wiki: http://wiki.osgi.org/wiki/Why_does_Eclipse_find_javax.swing_but_not_Felix%3F

I want to use javax jms

I want to use javax.jms in netbeans project , but netbeans tell my that there is no package like this , what should I do ?
this error occurs when I try from terminal
Exception in thread "main" java.lang.NoClassDefFoundError: javax/jms/MessageListener
You have to have the jms-api.jar in your classpath. I got mine from HornetQ.
Edit
I just saw that you said you were using NetBeans. In that case, you need to have downloaded the version of NetBeans that includes Java EE. Go here and download that. This site seems to have a nice tutorial on how to set it up from there.

JBoss Seam Project errors

I have a JBoss Seam project that a coworker created about a year ago. I'm taking over it now and it needs some work done. So I'm trying to setup the project in Eclipse Indigo. Here is the list of things I have installed so far:
JBoss 4.2.2 GA
JBoss Seam 2.2.0 GA
Glassfish v2.1
JBoss Seam Tools Plugin for Eclipse Indigo
For some reason I am not able to build the project to get an ear for JBoss. The errors I have are one in glassfish-builld.xml which says "Target clean does not exist in this project." And then I have errors in a bunch of generic.jsp file (I have no idea what their purpose is). The error for those is that a library for JBoss Seam called org.jboss.seam.wiki.util.WikiUtil cannot be found.
Can someone point me in the right direction to get this setup and running on JBoss?
Also org.jboss.seam.wiki.util.WikiUtil is a class that is a part of... Seam example project that is added to JBoss Seam distribution in examples/wiki directory. So if you really need it you will be able to find it there. But honestly I don't see any reason to put any dependency to Seam examples in project. Consider just deleting / commening out the code that refers to this class becasue it is probably some quick and dirty test code.
Do you want to run it on Glassfish or Jboss?
Did you import an entire eclipse project or create a new one?
I would first check the referenced libraries to see if there's anything missing(Libraries under Java Build Path for Helios, not sure if that differs from Indigo). Add a -verbose tag to the build and check out the output.