I am facing problems with using xalan in eclipse plugin.
When I try to create factory instance by:
TransformerFactory tFactory = TransformerFactory.newInstance("org.apache.xalan.processor.TransformerFactoryImpl", null);
I get error:
javax.xml.transform.TransformerFactoryConfigurationError: Provider org.apache.xalan.processor.TransformerFactoryImpl not found
...
I have following libs in plugin classpath: xml-apis.jar, xercesImpl.jar, serializer.jar, xalan.jar
I even can't create class instance by:
c = Class.forName("org.apache.xalan.processor.TransformerFactoryImpl");
Object o = c.newInstance();
It returns ClassNotFoundException
But I can create instances of other classes from same jar and can run same code outside eclipse without problem.
Any idea?
Edit: TransformerFactory instantiating class (say "class1") is part of an external library added in the plugin classpath wheras the xalan.jar is also in plugin classpath. If I move this "class1" into plugin, it finds the provider and works fine.
Though I have seen this problem once, but I am not very sure how i solved it.
If you are using JDK 1.5 or above then try removing xml-apis.jar. It was needed for Java 1.4 to support XML.
Update 1
Ok. From your question I inferred that you are writing a eclipse plug-in. If yes, then have you added the above jars using plugin.xml->Runtime->classpath? If not try to do so. Eclipse plugin considers only its runtime->classpath entries
Update 2
To me it still appears as a classpath resolution issue. Though, its hard to say why its happening. For a try you can also check by changing the order of included jars in plugin.xml->Runtime->classpath.
Hope this will help.
PS: Since you are working on eclipse plug-in development therefore I would suggest you to go through this article Eclipse - a tale of two VMs and many classloaders.
Related
I'm currently getting this error:
java.lang.NoSuchMethodError: org.json.JSONObject.keySet()Ljava/util/Set;
at ee.ut.cs.Parser.accessLint(Parser.java:39)
I have tried cleaning the project to no awail.
I suspect I have an error in the src/plugin/parse-htmlraw/build.xml while creating the jar file but I'm not certain. I understand that this error is because the function does not exist at runtime, but the object is created which means that the class is there, just not that function. I decompiled the .class file in created jar and it has the necessary functions.
Code is available at https://github.com/jaansusi/WCAGgrader
Q: What is wrong with the build that produces this error?
The problem is that even if I put the necessary class files in the jar I create, they are not linked correctly and the class that's called in the jar can't locate functions inside the other classes. The class object JSONObject is created but the functions inside the JSONObject class can't be found.
If you do not find the problematic version, there is a possibility you get it (especially if you are using Spring) from the following dependency -
<artifactId>android-json</artifactId>
<groupId>com.vaadin.external.google</groupId>
excluding it worked for me,
An easy way of analyzing dependencies is the maven-helper plugin in Intellij, see here
Check for the version you have used.
There might be a case where 2 different versions are being used which in turn causes this error.
To their own maven local repository com\Google\code\gson\gson, see if there are two or more version about json, will have to do is to delete the old, and remember to look at any other place in the project is introduced into the old version of the dependence, if any, change the old version of the dependence to the new version is perfectly solved this problem
I am following this guide to incorporate an activation expression (from core expressions) into my own extension point. As the guide says, I have created my extension point schema as follows:
But as you can see, I get errors for the referenced elements. (Element 'xxx' is not defined).
Actually, when I switch to the definition tab and double-click in the schema URL in the Schema inclusions list, I get the error message schema:/org.eclipse.core.expressions/schema/expressionLanguage.exsd could not be found.
My first suspicion was that something might have changed here for Eclispe Kepler, but the docs say anything about it. And I imported the org.eclipse.core.expressions plug-in from the Plug-Ins view into my workspace temporarily and checked if the referenced schema is actually where it is supposed to be (which it is). So this seems to be ok.
My next suspicion was that this had something to do with my target platform, so I double-checked my target platform, but I don't see any issue here. It includes (among others) the features
org.eclipse.platform 4.3.2.v20140221-1852
org.eclipse.platform.source 4.3.2.v20140221-1852
org.eclipse.rcp 4.3.2.v20140221-1700
org.eclipse.rcp.source 4.3.2.v20140221-1700
and the Core Expressions bundles are there as well:
org.eclipse.core.expressions 3.4.501.v20131118-1915
org.eclipse.core.expressions.source 3.4.501.v20131118-1915
I am currently stuck. Any pointer what else I can check or how I can fix this is appreciated.
Does your plug-in file (org.eclipse.core.expression.xxx.jar) actually have the schema file?
Today I had same problem and found that the jar file doesn't have the schema file.
I downloaded source jar file which have the schema file (Actually I found the source jar file from : http://grepcode.com/snapshot/repository.grepcode.com/java/eclipse.org/4.2/org.eclipse.core/expressions/3.4.400) and put the schema file into my jar file and it solves the problem.
Good luck.
Ok, several chaotic attempts of
reloading the target platform
cleaning all projects
restarting Eclipse with -clean switch
seems to have done the trick. I am not sure what caused this, but now the error has vanished (and I hope it stays this way).
I am having a Maven project. When I run the project I am getting error. The cause of the error is
Caused by: java.lang.NoSuchMethodError: org.w3c.tidy.Tidy.setHideComments(Z)V
I thought jar might be missing in Maven repository. But I found the jar in that repository.
I have jtidy-4aug2000r7-dev.jar at C:\.m2\repository\jtidy\jtidy\4aug2000r7-dev
Can some one tell the probable reason for the problem.
I guess the problem might be with the version of the jtidy.jar. The current version you have mentioned is quite old (Aug 4, 2000).
I have googled the version 4aug2000r7-dev.jar and found out
API.
I don't see setHideComments() method in Tidy.java
Please check you do not have multiple version of the same jar.
Try JTidy 8.0-SNAPSHOT here. It contains the method.
A NoSuchMethodError occurs when you load a A class that requires a method on class B that doesn't exist in the version of B that the the JVM has loaded. In this case, the JVM is expecting to find a non-private method with the signature void setHideComments(boolean) ... but it isn't there.
There are three common causes:
You have changed or removed the method in B and recompiled B ... but nor A.
You have the wrong version of some library JAR file; e.g. the JAR containing A depends on a different version of the JAR containing B than the one you have listed as a dependency.
A variant of the previous one is that somehow you have two versions of one or other of the JAR files on the execution classpath.
Assuming that you aren't modifying jtidy, the first explanation does not apply.
Most possibly that your jar file is quite old (Aug 4, 2000) and could be that those method was added later. Try to use this jar
I have a Java (6) application which uses Hibernate (V3.3.2) to read data from HSQLDB, which i build and debug/run with Eclipse (V3.5.1), and it works fine.
I then created a GWT (V1.7) Servlet web app, copied my hibernate classes into it, and added the same User Libraries dependencies. However when i run the servlet and try to access a URL which invokes my code i get this:
java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:152)
at xxx.daoimpl.DAOSession.initialise(DAOSession.java:40)
where DAOSession.java:40 is :
AnnotationConfiguration config = new AnnotationConfiguration ();
Googling for this error suggests i am missing slf4j-api.jar from the classpath, however if i look at the command line for the Debug properties i can see this jar there:
C:\java\jsedk_6\jre\bin\javaw.exe
-agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:54541
-Xmx512m -Dfile.encoding=Cp1252
-classpath
D:\dev\workspace\xxx\src;
D:\dev\workspace\xxx\resources;
D:\dev\workspace\xxx\war\WEB-INF\classes;
C:\java\eclipse\plugins\com.google.gwt.eclipse.sdkbundle.win32_1.7.1.v200909221731\gwt-windows-1.7.1\gwt-user.jar;
C:\java\eclipse\plugins\com.google.gwt.eclipse.sdkbundle.win32_1.7.1.v200909221731\gwt-windows-1.7.1\gwt-dev-windows.jar;
C:\java\hibernate-annotations-3.4.0.GA\hibernate-annotations.jar;
C:\java\hibernate-annotations-3.4.0.GA\lib\ejb3-persistence.jar;
C:\java\hibernate-annotations-3.4.0.GA\lib\hibernate-commons-annotations.jar;
C:\java\hibernate-distribution-3.3.2.GA\hibernate3.jar;
C:\java\hibernate-distribution-3.3.2.GA\lib\required\antlr-2.7.6.jar;
C:\java\hibernate-distribution-3.3.2.GA\lib\required\commons-collections-3.1.jar;
C:\java\hibernate-distribution-3.3.2.GA\lib\required\dom4j-1.6.1.jar;
C:\java\hibernate-distribution-3.3.2.GA\lib\required\javassist-3.9.0.GA.jar;
C:\java\hibernate-distribution-3.3.2.GA\lib\required\jta-1.1.jar;
C:\java\hibernate-validator-4.0.1.GA\hibernate-validator-4.0.1.GA.jar;
C:\java\hibernate-validator-4.0.1.GA\lib\validation-api-1.0.0.GA.jar;
C:\java\hibernate-validator-4.0.1.GA\lib\log4j-1.2.14.jar;
C:\java\hsqldb\lib\hsqldb.jar;
C:\java\restlet-jse-2.0m5\lib\org.restlet.jar;
C:\java\restlet-jee-2.0m5\lib\org.restlet.ext.servlet.jar;
C:\java\restlet-jse-2.0m5\lib\org.restlet.ext.xml.jar;
C:\java\slf4j-1.5.8\slf4j-api-1.5.8.jar;
C:\java\slf4j-1.5.8\slf4j-log4j12-1.5.8.jar
com.google.gwt.dev.HostedMode
...
If i open the jar i can see the LoggerFactory class in there.
Any idea why it isn't being found by the class loader?
Edit 1: If try to access org.slf4j.LoggerFactory from my code, Eclipse compiles it ok, but i get the same error at runtime.
Edit 2: If i add a Test class with a main which calls the same code and run it, it works. So this classpath problem seems specific to the Servlet.
thanks,
jon
It seems that copying the two slf4j jars to the war/WEB-INF/lib sub-project/dir fixed the problem. I'm not really sure why i should need to do this for these two jars and not for all the other Hibernate, Restlet etc jars that the project also uses, though i suppose for consistency i will do that anyway - i guess it will make deployment easier as well.
If someone can provide some sort of explanation as to why this worked and why exactly i need to do it i will select it as the "correct" answer, otherwise i'll select this one.
Can you please reconfirm that you have at least two slf4j.jar files in the classpath, the slf4j-api.jar and exactly one implementation, such as slf4j-jdk14.jar?
You must not have multiple sflj4-implementations in the classpath.
You have a runtime dependency issue so everything compiles fine but the dependency is in your jars. You need to visit the Hibernate site and look at the compatibility matrix and make sure you are matched up correctly then check the dependencies for annotations and core. You log4J jars look fine so it's definitely some quirk.
If it works in Eclipse then logically it's definitely some diff between the 2 runtimes (eclipse and non-eclipse), if the matrix checks out fine then see if you can factor out the commonalities in the 2 then work out the differences -- your answer should be in there.
I had a similar issue except I was using Tomcat and the NoClassDefFound error was on the juli logger. I fixed it by removing the Tomcat dependencies from my classpath when running in hosted mode because hosted mode embeds a Tomcat server that was conflicting. So I would see what happens if you remove some or all of the restlet jars from your classpath to see if they conflict.
I keep getting the following exception on one of our live servers (the others running the same code seem ok):
java.lang.RuntimeException: XPathFactory#newInstance() failed to create an XPathFactory for the default object model: http://java.sun.com/jaxp/xpath/domwith the XPathFactoryConfigurationException: javax.xml.xpath.XPathFactoryConfigurationException: No XPathFctory implementation found for the object model: http://java.sun.com/jaxp/xpath/dom
at javax.xml.xpath.XPathFactory.newInstance(XPathFactory.java:67)
I'm pretty sure that I have the Xalan and Saxon jars in the classpath (using IBM Java 1.5).
Do you have any Ideas what else could be wrong?
Edit:
That's the code that causes the Problem:
XPathFactory factory = XPathFactory.newInstance();
And it's running on a custom web server that's roughly based on the catalina engine.
You need to add the appropriate .jar in your classpath. In my case I used the Saxon-HE library.
There exists a bug in Saxon9 you maybe run into like me.
The bug has been corrected in version 9.5.1.5. So you may download the latest Saxon 9 HE.
Found the answer myself: The problem is the combination of using Java 5 and having an option
-Djava.endorsed.dirs
set to a directory that contained the xalan.jar.
Once removed everything works again.
Make sure you have the appropriate xml-apis.jar and xerces jars in your classpath for the version of xalan that you are using (check the release notes for what, exactly, you need).
Also make sure you don't have multiples as the xercesImpl.jar, xml-apis.jar and xalan.jar need to be in sync.