AbstractMethodError on Node.getTextContent() - java

Below is the sample code block throwing AbstractMethodError:
import org.w3c.dom.Node;
..
Node root = soapBody.getElementByTagNameNS("http://xxx.xxx/Schema/v9", "Result").item(0); //Namespace
for (int i = 0; i < root.getChildNodes().getLength(); i++) {
Node child = root.getChildNodes().item(i); //Set to SubResult
String result = child.getTextContent(); //Throws error
}
The sample soap response :
soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header/><soapenv:Body><a1:Response xmlns:a1="http://xxx.xxx/Schema/v9"><a1:SubResult>50</<a1:SubResult></a1:Response></soapenv:Body></soapenv:Envelope>
Error thrown:
java.lang.AbstractMethodError: org.apache.axis.message.MessageElement.getTextContent()Ljava/lang/String;
Java version used : 1.5
Tomcat Version - 6.0.41
Checked org.w3c.dom.Node for 1.5 and it does have the method getTextContent()
What could be the possible reason for this error?
Also, why does this appear : org.apache.axis.message.MessageElement instead of org.w3c.Node?

The javadoc of the AbstractMethodError says:
Thrown when an application tries to call an abstract method. Normally,
this error is caught by the compiler; this error can only occur at run
time if the definition of some class has incompatibly changed since
the currently executing method was last compiled.
So it looks like you have some incompatible versions of something in your classpath.
org.apache.axis.message.MessageElement is part of Axis and should implement org.w3c.dom.Node so the versions of those two don't seem to match. Make sure you have matching versions of the two in your classpath.

Related

How can a method exist in one part of the program but not another?

Main question/TLDR: I am getting a NoSuchMethodError for a method a few levels down in my call stack. But calling the method in my own main function in the same project gives no error. How can that happen? What techniques could I try to narrow down the source of such an error?
Other facts: The documentation shows that the method exists. The source from which the error is raised has the right imports and tries to call the method. There is some weird gobbledygook after the name of the method in the error printout. Could this be the problem?
Specific information for my case:
Full error printout:
Exception in thread "main" java.lang.NoSuchMethodError: java.nio.ByteBuffer.clear()Ljava/nio/ByteBuffer;
at it.unimi.dsi.sux4j.io.ChunkedHashStore.reset(ChunkedHashStore.java:526)
at it.unimi.dsi.sux4j.mph.GOVMinimalPerfectHashFunction.<init>(GOVMinimalPerfectHashFunction.java:335)
at it.unimi.dsi.sux4j.mph.GOVMinimalPerfectHashFunction$Builder.build(GOVMinimalPerfectHashFunction.java:270)
at org.boydwebb.familysearch.runners.examples.ManyGraphWriter.<init>(ManyGraphWriter.java:109)
at org.boydwebb.familysearch.runners.examples.ManyGraphWriter.main(ManyGraphWriter.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.hadoop.util.ProgramDriver$ProgramDescription.invoke(ProgramDriver.java:68)
at org.apache.hadoop.util.ProgramDriver.driver(ProgramDriver.java:139)
at org.boydwebb.familysearch.runner.Runner.run(Runner.java:62)
at org.boydwebb.familysearch.runner.Runner.main(Runner.java:23)
Relevant source: (https://raw.githubusercontent.com/vigna/Sux4J/master/src/it/unimi/dsi/sux4j/io/ChunkedHashStore.java)
Lines I inserted into main to try to get a minimal working example:
ByteBuffer buffer = ByteBuffer.allocateDirect(100);
buffer.clear();
The lines in my original code the yielded the error:
import it.unimi.dsi.sux4j.mph.GOVMinimalPerfectHashFunction;
Long[] table = \*initialize here*\
TransformationStrategy<Long> transformationStrategy = TransformationStrategies.fixedLong();
GOVMinimalPerfectHashFunction.Builder<Long> builder = new GOVMinimalPerfectHashFunction.Builder<>();
builder.keys(Arrays.asList(table));
builder.transform(transformationStrategy);
builder.store(null);
builder.tempDir(null);
builder.signed(0);
toGiantIdx = builder.build();//ERROR HERE
The precompiled library bytecode contains a reference to a method named internally as java.nio.ByteBuffer.clear()Ljava/nio/ByteBuffer; which means a method defined in java.nio.ByteBuffer (maybe overridden in derived class) with declaration
java.nio.ByteBuffer clear();
This requested method exists since Java SE 9. If the code is executed with an older Java runtime, this error will happen.
If your own code is compiled with an older JDK, the compiler resolves the buffer.clear() to point to java.nio.Buffer java.nio.Buffer.clear() method instead (which exists since JDK 1.4).

Rascal: Undeclared Annotation in std:///lang/java/flow/JavaToObjectFlow.rsc

In the following code snippet, I attempted to use the createOFG from JavaToObjectFlow.rsc:
void run(loc source) {
m = createM3FromEclipseProject(source);
set[Declaration] asts = createAstsFromEclipseProject(source, true);
FlowProgram p = createOFG(asts);
}
Upon executing this method, the following error was received:
|std:///lang/java/flow/JavaToObjectFlow.rsc|(4167,1,<153,26>,<153,27>):
Undeclared annotation: decl on Expression
Advice: |http://tutor.rascal-
mpl.org/Errors/Static/UndeclaredAnnotation/UndeclaredAnnotation.html|
Since the error is coming from std:///lang/java/flow/JavaToObjectFlow.rsc and none of our fellow students receive the same error, I am wondering what is going wrong. The error occurs in both the stable and unstable versions of Rascal.
you should be on unstable, as this message points to a known problem on stable.
are you sure you get exactly the same message on unstable? in that case, please tell me what you see on that line (153 of file /lang/java/flow/JavaToObjectFlow.rsc)
If you don't have a source location to click on to get you there, you can always browse the code from any rascal project:

ClassCastException: java.lang.Object incompatible with com.company.base.BaseDocument

I have a piece of code that has to be JDK 1.4 compliant. And below is a snippet which gets a runtime exception.
BaseDocument baseDocument = new BaseDocument();
baseDocument.setGuid("{somethinghere}");
List document = new ArrayList();
document.add(baseDocument);//runtime error
Exception:
java.lang.ClassCastException: [Ljava.lang.Object; incompatible with [Lcom.company.base.BaseDocument;
I don't understand why we cant cast it to a java Object(since Object is the parent class of all Classes in java).
Im using IBM JDK version 1.7 with Eclipse compiler settings set to JDK 1.4
Please explain what mistake I'm doing here. I know generics is the standard, but it has to be JDK 1.4 compliant :(
Thanks in advance!
Actually, the message says:
[Ljava.lang.Object; incompatible with [Lcom.company.base.BaseDocument;
The [ characters are very important. Apparently, something is attempting cast something of type Object[] to BaseDocument[]; i.e. you are dealing with array types here.
However, I have no idea what is actually causing the problem here, because (on the face of it) there should be no instances of BaseDocument[] in the code you have posted. Furthermore, I don't believe your claim that that exception is thrown at that line. Here is the source code of the ArrayList.add method (Java 6 version):
private transient Object[] elementData;
public boolean add(E e) {
ensureCapacity(size + 1); // Increments modCount!!
elementData[size++] = e;
return true;
}
An assignment of a reference into an object array (Object[]) does not entail any runtime type-checks, and cannot throw a ClassCastException.
If you showed us a complete stacktrace, it would be easier to diagnose.

interface exception

i have these codes
UserAgentContext uAgent=new SimpleUserAgentContext();
DocumentBuilderImpl docBuild=new DocumentBuilderImpl(uAgent);
docBuild.parse(new InputSourceImpl("http://dic.amdz.com/"));
when i run , it gives me the following error:
Exception in thread "main" java.lang.IncompatibleClassChangeError: Found interface sun.font.FontManager, but class was expected
at org.lobobrowser.util.gui.FontFactory.createFont(FontFactory.java:210)
at org.lobobrowser.util.gui.FontFactory.createFont_Impl(FontFactory.java:180)
at org.lobobrowser.util.gui.FontFactory.createFont(FontFactory.java:127)
at org.lobobrowser.util.gui.FontFactory.getFont(FontFactory.java:98)
at org.lobobrowser.html.style.StyleSheetRenderState.<clinit>(StyleSheetRenderState.java:43)
at org.lobobrowser.html.domimpl.NodeImpl.<clinit>(NodeImpl.java:39)
at org.lobobrowser.html.parser.DocumentBuilderImpl.createDocument(DocumentBuilderImpl.java:143)
at org.lobobrowser.html.parser.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:97)
at cobratest2.Cobratest2.main(Cobratest2.java:21)
then pointing me to the last line. so the question is, what to do?
The problem is at
org.lobobrowser.util.gui.FontFactory.createFont(FontFactory.java:210)
That class was compiled against an old version of the libraries in whichsun.font.FontManager was a class, but you are trying to run it with newer libraries in which it is now an interface. You will probably have to recompile all of the org.lobobrowser package against current libraries.
And BTW, the link What causes java.lang.IncompatibleClassChangeError? mentioned by e-zinc does contain all the information you need to have figured this out yourself.

ClassFormatError: Illegal class modifiers in class ... 0x209

I have a few some strange issues with my class after migrating from JDK5/Tomcat5 to JDK6/Tomcat7 both with MyEclipse 9.
Whenever I try to access 'myclass' via jsp:usebean I got following error
org.apache.jasper.JasperException: javax.servlet.ServletException: java.lang.ClassFormatError: Illegal class modifiers in class myclass: 0x209
The rest of log points nowhere. By trial and error I have trimmed huge class to the following problematic part:
...
rf = store.getDefaultFolder();
f = (IMAPFolder)rf;
final IMAPStore storeNew = store;
Object val = f.doCommand(new IMAPFolder.ProtocolCommand() { <-- problem propably starts here
public Object doCommand(IMAPProtocol p)
throws ProtocolException {
...
The next strange thing is that my colleague is using the same environment with no problems. I have compared our class files and the only difference is in last but one byte. My class ends with '02 09', his '06 09'
After several days I am out of options how to get rid of it.
EDIT:
I have reinstalled/updated to MyEclipse 9.1. No luck so far.
SOLUTION
After another day trying to reproduce problem with a new project with a single file in it, I have realised that only remaining difference is in project/properties/java build path/libraries. There was J2EE 1.4 Libraries in the main project, so I have replaced it. After adding Java EE 6 Libraries voila. I am able to compile and run w/o any problems

Categories