'java.lang.NoSuchFieldError: ignoreMethodBodies' Exception while creating AST - java

While passing a java source code to the below mentioned code, I get an exception and have no idea how to fix this. Kindlly let me know where I am wrong/ any alternative solution...
Source Code:
char[] source = resultEntryIndustry.text.toCharArray();
ASTParser parser = ASTParser.newParser(AST.JLS3);
parser.setSource(source);
Map options = JavaCore.getOptions();
JavaCore.setComplianceOptions(JavaCore.VERSION_1_5, options);
parser.setCompilerOptions(options);
CompilationUnit cUnit = (CompilationUnit) parser.createAST(null);
Exception thrown:
Exception in thread "main" java.lang.NoSuchFieldError: ignoreMethodBodies
at org.eclipse.jdt.core.dom.CompilationUnitResolver.parse(CompilationUnitResolver.java:491)
at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:1194)
at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:801)
at itjava.model.CompilationUnitStoreIndustry.createCompilationUnitFacadeList(CompilationUnitStoreIndustry.java:71)
at itjava.presenter.WordInfoPresenterIndustry.SetCompilationUnitListAndAccessRepository(WordInfoPresenterIndustry.java:162)
at itjava.industry.code2String.main(code2String.java:31)
ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183): [../../../src/share/back/util.c:820]
The source code parsed is a simple java file used to connect to database using JDBC.

I was facing an almost similar problem and found the fix. Whatever environment you're running the code in, it has some component in its classpath which is not compatible with jdt core.

Related

Getting version mismatch error while updating into DCTM using java

I am trying to update into DCTM through java code, below is the code snippet
IDfDocument communication = (IDfDocument) getDfSession().getObject(DfId.valueOf(communicationId));
communication.setString(ATTR_STATUS, status);
communication.save();
but I am getting the below error
Caused by: DfException:: THREAD: be.ing.ca.xpression.DCTM001P-1; MSG: [DM_OBJ_MGR_E_VERSION_MISMATCH]error: "save of object
090283e589bf689d of type xx_document failed because of version
mismatch: old version was 4"; ERRORCODE: 100; NEXT: null
I thinki am getting this error because there is another process which is trying to modify the object ,and when more than one process try to modify anyobject DCTM throws this exception,
But after lot of searching i dident found any solution which can solve this error
If anyone knows the solution please reply..
Link that i refer
http://www.javablog.fr/?s=version+mismatch
Try calling a fetch() on the object before doing updates.
communication.fetch()
There are some optional parameters AFAIK, but it's been a while since I've been fiddling with DCTM.
Best of luck!

Nashorn failed to call a static method of a 3rd party Java class, any solutions?

The code in Nashorn is to parse a very simple JSON string into a JSONObject (com.alibaba.fastjson.JSONObject), simply going as:
var jso = Java.type('com.alibaba.fastjson.JSONObject').parseObject('{"name": "nothing"}');
But when ran the Java project, I received below error message:
Exception in thread "main" javax.script.ScriptException: TypeError: Java.type("com.alibaba.fastjson.JSONObject").parseObject is not a function in <eval> at line number 1
at jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:470)
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:454)
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:406)
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:402)
at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:155)
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:233)
...
I tried to print(Java.type('com.alibaba.fastjson.JSONObject')), and the class is obviously there with output [JavaClass com.alibaba.fastjson.JSONObject]
Anybody knows what's the root cause of this error, and how to fix it?

z3 java api using mkOptimize

I am using the optimization option of z3 in the java api via context.mkOptimize(). When I execute my code it will show me the following error:
java.lang.UnsatisfiedLinkError: com.microsoft.z3.Native.INTERNALmkOptimize(J)J
My Code:
Context context = new Context();
Optimize mkOptimize = context.mkOptimize();
IntExpr intTest = context.mkIntConst("test");
IntExpr intTen = context.mkInt(10);
BoolExpr assertInt = context.mkLe(intTest, intTen);
mkOptimize.Add(assertInt);
mkOptimize.MkMaximize(intTest);
mkOptimize.Check();
Am I doing something wrong or is this a bug in the java api?
(The exception is thrown when creating the optimize object in the second line)
Found the problem. It was due to the system path which was pointing to two different versions of z3 libraries.

atomchace function in biojava

Hi everyone I'm fairly new to biojava and trying to implement this piece of code:
AtomCache cache = new AtomCache();
cache.setPath("/tmp/");
FileParsingParameters params = cache.getFileParsingParams();
params.setLoadChemCompInfo(true);
StructureIO.setAtomCache(cache);
Structure strucuture = StructureIO.getStructure("4HHB");
after executing these lines im getting the following error message:
Exception in thread "main" java.lang.NoSuchFieldError: lineSplit
at org.biojava.bio.structure.align.util.UserConfiguration.(UserConfiguration.java:87)
at org.biojava.bio.structure.align.util.AtomCache.(AtomCache.java:115)
at protein_structure.main(protein_structure.java:27)
Java Result: 1
I cant figure out the reason for this error, I downloaded the pdb files for the proteins that Im working with (in this case "4HHB" in the /tmp/ directory but still the same error is showing up. can anyone tell me how Atomcache function works? Thanks

ColdFusion using Javaloader error

I have a question regarding calling java class from ColdFusion using Javaloader 1.1.
I attempted to access java class from ColdFusion in a local server, and there was no problem. But when I tried the same thing in office server, I got an error:
"the specified directory
mypath\Javaloader/tmp/AEFACE9B-1C6F-6569-2329 could not be created.
The most Likely cause of this error that mypath \ /
tmp/AEFACE9B-1C6F-6569-2329 already exists on your file system."
And another message
"The error occured in Javaloader.cfc line 269". Javaloader.cfc line
269 is < cfdirectory action="create" directory="#path#" >
what do those error messages mean?
this is my code:
//calling java from coldfusion
<cfscript>
sourcePaths = [expandPath("./src")];
loader = createObject("component", "javaloader.JavaLoader").init(sourceDirectories=sourcePaths);
obj = loader.create("myClass").init();
</cfscript>
I really have no idea. Any solution will be much appreciated. Thank you in advance...

Categories

Resources