java.lang.NoSuchMethodError when sending mail using Apache James 3 - java

I just downloaded and setup the Apache James 3 latest beta release on Windows and so far i haven't been able to send a simple message. It looks like there is an issue with the build. The error is -
ERROR 22:45:01,666 | james.mailspooler | Exception processing mail while spooling Unable to process mail Mail1442234701295-757cd62b-eeed-4671-828c-2a7c715acfaa (org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[Message: org.apache.james.core.MailImpl#4262d5d7])
javax.mail.MessagingException: Unable to process mail Mail1442234701295-757cd62b-eeed-4671-828c-2a7c715acfaa (org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[Message: org.apache.james.core.MailImpl#4262d5d7])
.
.
Caused by: javax.mail.MessagingException: Unable to process mail Mail1442234701295-757cd62b-eeed-4671-828c-2a7c715acfaa (org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[Message: org.apache.james.core.MailImpl#4262d5d7])
.
.
Caused by: org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[Message: org.apache.james.core.MailImpl#4262d5d7]
.
.
Caused by: java.lang.NoSuchMethodError: org.apache.james.mime4j.stream.MimeConfig: method <init>()V not found
The relevant class in the JAR shows the supposedly missing constructor so i am at a complete loss. Can anyone guide me in the right direction please?
Thanks in advance!
Edit: Decompiled code snippet from the MimeConfig class shows the constructor
public final class MimeConfig {
/* member class not found */
class Builder {}
.
.
MimeConfig(boolean strictParsing, int maxLineLen, int maxHeaderCount, int maxHeaderLen, long maxContentLen, boolean countLineNumbers,
String headlessParsing, boolean malformedHeaderStartsBody) {
/* 53*/ this.strictParsing = strictParsing;
/* 54*/ this.countLineNumbers = countLineNumbers;
/* 55*/ this.malformedHeaderStartsBody = malformedHeaderStartsBody;
/* 56*/ this.maxLineLen = maxLineLen;
/* 57*/ this.maxHeaderCount = maxHeaderCount;
/* 58*/ this.maxHeaderLen = maxHeaderLen;
/* 59*/ this.maxContentLen = maxContentLen;
/* 60*/ this.headlessParsing = headlessParsing;
}

I got the same error and was searching for an answer. The error is because MimeConfig doesn't have a default constructor. I could get the mail successfully delivered locally by doing to following.
Dowloaded apache-mime4j-core-0.8.0-20150617.024907-738-sources
Created a default public constructor for MimeConfig
Initialized all the variables with values shown in the static class Builder constructor
Added setters for all the variables (Because I was getting NoSuchMethodError for setMaxLineLen)
Created a jar called apache-mime4j-0.8.0-fix.jar and pushed into the lib folder
I use run.sh, so replaced the mime4j core jar name with the above one.
I am sure there is some mismatch between spooler and mime4j. I think the calling code should use the Builder instead of directly trying to instantiate the MimeConfig.
Try these and let me know if it works. It worked for me. I am not sure if this is a permanent fix, but I can go ahead with exploring the V3 features till we get a permanent solution.

The solution is to use the : apache-mime4j-core-0.7.2.jar and apache-mime4j-dom-0.7.2.jar
download the two jars and put them in : james-server-app-3.0.0-beta5-SNAPSHOT\lib.
You can download james-server-app-3.0.0-beta5 from : https://repository.apache.org/content/repositories/snapshots/org/apache/james/james-server-app/3.0.0-beta5-SNAPSHOT/.

Related

Nodejs: Spawn jar (non executable)

I have a Java jar file, which is not executable(does not have a main method).
However I would like to invoke a particular class and its methods from my node.js application. I am currently using the below:
var child = require('child_process').spawn(
'java', ['-cp', "abc.jar", com.abc.ABCClass]
);
How now can I invoke the method in the ABCClass with appropriate arguments?
I currently get an exception such as below:
A JNI error has occurred, please check your installation and try again
Exception in thread "main"
Error: java.lang.NoClassDefFoundError:
org/apache/kafka/clients/consumer/KafkaConsumer
Thanks in advance. I am looking for a solution to call the method in that class.

Internal Action was not loaded Error: java.lang.ClassNotFoundException

I am trying to run an implementation a jason code that is using some Internal Actions. The interpreter is showing that it was not possible to find the "java" code of the internal action, as showed:
Server running on http://191.36.8.42:3272
[aslparser] [peleus.asl:29] warning: The internal action class for 'org.soton.peleus.act.plan(Goals)' was not loaded! Error:
java.lang.ClassNotFoundException: org.soton.peleus.act.plan
[aslparser] [peleus.asl:42] warning: The internal action class for 'org.soton.peleus.act.isTrue(H)' was not loaded! Error:
java.lang.ClassNotFoundException: org.soton.peleus.act.isTrue
[peleus] Could not finish intention: intention 1: +des([on(b3,table),on(b2,b3),on(b1,b2)])[source(self)] <- ... org.soton.peleus.act.plan(Goals); !checkGoals(Goals); .print("Goals ",Goals," were satisfied") /
{Goals=[on(b3,table),on(b2,b3),on(b1,b2)]}Trigger: +des([on(b3,table),on(b2,b3),on(b1,b2)])[noenv,code(org.soton.peleus.act.plan([on(b3,table),on(b2,b3),on(b1,b2)])),code_line(29),code_src("peleus.asl"),error(action_failed),error_msg("no environment configured!"),source(self)]
[peleus] Adding belief clear(table)
This mas2j file is as following:
MAS peleus {
infrastructure: Centralised
agents:
peleus;
}
Part of agent code (written by Felipe Meneguzzi) is showed bellow:
//The next line is line 28
+des(Goals) : true
<- org.soton.peleus.act.plan(Goals);
!checkGoals(Goals);
.print("Goals ",Goals," were satisfied").
+!checkGoals([]) : true <- true.
//The next line is line 40
+!checkGoals([H|T]) : true
<- .print("Checking ", H);
org.soton.peleus.act.isTrue(H);
!checkGoals(T).
I guess it is about the folder structure, how to set up Jason to search for java files in specific locations?
The folders structure is like this:
Peleus\src\org\soton\peleus for java files
Peleus\examples for mas2j and asl tested project
It all depends on how you are executing the application.
If you are using java, the CLASSPATH should be defined to include the missing classes.
if you are using jason script (that uses Ant), the .mas2j file should include the class path as well.
More on that in the FAQ. Notice that CLASSPATH is where .class files are found, not .java source code files. The error regards a missing class, not a missing source code.

ERROR Code=-4220 and SQLSTATE= null

I am using db2 version 10.5 and inserting the values into the DB2JSON, created a simple standalone java program to retrieve all the values from the table(Collection) when I run the query I am getting the following error
Exception in thread "main" java.lang.RuntimeException: com.ibm.db2.jcc.am.SqlException: [jcc][t4][1065][12306][3.69.66] Caught java.io.CharConversionException. See attached Throwable for details. ERRORCODE=-4220, SQLSTATE=null
at com.ibm.nosql.json.api.DBObjectRowHandler.handle(DBObjectRowHandler.java:38)
at com.ibm.nosql.json.api.DBObjectRowHandler.handle(DBObjectRowHandler.java:14)
at com.ibm.nosql.json.api.BaseResultIterator.next(BaseResultIterator.java:119)
at com.ibm.nosql.json.api.DBCursor.fetchResultsEagerly(DBCursor.java:801)
at com.ibm.nosql.json.api.DBCursor.find(DBCursor.java:895)
at com.ibm.nosql.json.api.DBCursor.hasNext(DBCursor.java:278)
at com.ws.Demo.TestingDemo.main(TestingDemo.java:47)
Caused by: com.ibm.db2.jcc.am.SqlException: [jcc][t4][1065][12306][3.69.66] Caught java.io.CharConversionException. See attached Throwable for details. ERRORCODE=-4220, SQLSTATE=null
at com.ibm.db2.jcc.am.gd.a(gd.java:733)
at com.ibm.db2.jcc.am.gd.a(gd.java:66)
at com.ibm.db2.jcc.am.gd.a(gd.java:120)
at com.ibm.db2.jcc.am.kc.a(kc.java:2868)
at com.ibm.db2.jcc.am.kc.p(kc.java:525)
at com.ibm.db2.jcc.am.kc.Z(kc.java:2747)
at com.ibm.db2.jcc.am.ResultSet.getObjectX(ResultSet.java:1438)
at com.ibm.db2.jcc.am.ResultSet.getObject(ResultSet.java:1413)
at com.ibm.nosql.json.api.DBResultSet.getObject(DBResultSet.java:255)
at com.ibm.nosql.json.api.DBData.getObjectX(DBData.java:66)
at com.ibm.nosql.json.api.DBObjectRowHandler.getObjectID(DBObjectRowHandler.java:58)
at com.ibm.nosql.json.api.DBObjectRowHandler.handle(DBObjectRowHandler.java:28)
... 6 more
Caused by: java.nio.charset.MalformedInputException: Input length = 290
at com.ibm.db2.jcc.am.r.a(r.java:19)
at com.ibm.db2.jcc.am.kc.a(kc.java:2864)
... 14 more
Caused by: sun.io.MalformedInputException
at sun.io.ByteToCharUTF8.convert(ByteToCharUTF8.java:292)
at com.ibm.db2.jcc.am.r.a(r.java:16)
... 15 more
I also went throught few posts where it suggest to use db2.jcc.charsetDecoderEncoder=3 but I have no idea where to use it, and also I few other posts it is suggested touse the lastest version db2jcc.jar, I am using the jars that is present inside the db2 10.5 under sqllib folder. Anyone let me know how to fix this
Add the following environment variable(Java VM arguments) in your tomcat settings
-Ddb2.jcc.charsetDecoderEncoder=3
This worked.
You can set the charset decoder encoder using system property inside your Java code.
For example:
System.setProperty("db2.jcc.charsetDecoderEncoder", "3");

java.lang.NoSuchMethodError - Ljava/lang/String;)Ljava/lang/String;

My code is giving an error below;
Exception in thread "main" java.lang.NoSuchMethodError:
com/myApp/Client.cypherCBC(Ljava/lang/String;)Ljava/lang/String;
But it's working fine in an another local environment. My code so far is below;
try {
System.out.println("Encrypted CBC passwd : "
+ Client.cypherCBC("CypherThePassword"));
} catch (Exception e) {
e.printStackTrace();
}
This is due to a run-time JAR or class mismatch. the "Client" class which was there at the time you compile your application has a static method "cypherCBC" which gets String parameter, but at run-time class loader has loaded the "Client" class which doesn't have that kind of method (same name with same signature).
if you can debug the application at runtime, put a break-point at the line which exception was thrown, then try to evaluate following expression,
Client.class.getResource("Client.class")
, then you can find where the class has been leaded from, then you can decompile and try to troubleshoot the issue.
I got the same error while running a web application in Weblogic.
The reason for this error is there are two versions of classes are in the environment.To fix this you have to figure out which .class is using at the run time.
I used following to identify which class is loaded at run time.
-verbose:class
There is a duplicate class on your classpath.
So, That is why JVM is getting confused that which one needs to pick because both classes have a same method with a different signature that you are trying to call.

NoSuchMethodError when the method obviously exists

20:15:43 [INFO] macintosh264 issued server command: /sell hand
20:15:43 [INFO] [XYZShop] MacCommand sell executed
20:15:43 [SEVERE] null
org.bukkit.command.CommandException: Unhandled exception executing command 'sell' in plugin XYZShop v0.1.3
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46)
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:186)
at org.bukkit.craftbukkit.v1_4_6.CraftServer.dispatchCommand(CraftServer.java:510)
at net.minecraft.server.v1_4_6.PlayerConnection.handleCommand(PlayerConnection.java:979)
at net.minecraft.server.v1_4_6.PlayerConnection.chat(PlayerConnection.java:897)
at net.minecraft.server.v1_4_6.PlayerConnection.a(PlayerConnection.java:852)
at net.minecraft.server.v1_4_6.Packet3Chat.handle(Packet3Chat.java:44)
at net.minecraft.server.v1_4_6.NetworkManager.b(NetworkManager.java:290)
at net.minecraft.server.v1_4_6.PlayerConnection.d(PlayerConnection.java:112)
at net.minecraft.server.v1_4_6.ServerConnection.b(SourceFile:39)
at net.minecraft.server.v1_4_6.DedicatedServerConnection.b(SourceFile:30)
at net.minecraft.server.v1_4_6.MinecraftServer.r(MinecraftServer.java:598)
at net.minecraft.server.v1_4_6.DedicatedServer.r(DedicatedServer.java:224)
at net.minecraft.server.v1_4_6.MinecraftServer.q(MinecraftServer.java:494)
at net.minecraft.server.v1_4_6.MinecraftServer.run(MinecraftServer.java:427)
at net.minecraft.server.v1_4_6.ThreadServerApplication.run(SourceFile:849)
Caused by: java.lang.NoSuchMethodError: dev.xyzcraft.net.database.DatabaseHandler.getItem(IS)Ldev/xyzcraft/net/xyzshop/dataObject/MSItem;
at dev.xyzcraft.net.xyzshop.commands.SellCommand.onCommand(SellCommand.java:63)
at dev.xyzcraft.net.xyzshop.util.MacCommand.onCommand(MacCommand.java:44)
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)
... 15 more
I get that exception
here's the code:
https://github.com/macintosh264/XYZShop
Lastly, I'm using a Mod API for a popular video game, Minecraft, entitled Bukkit. Here's the JavaDoc, and library
http://dl.bukkit.org/downloads/bukkit/
http://jd.bukkit.org
"I also have this problem with another project that uses MySQL, and the stack trace occurs WHENEVER the mysql class is used. "
Macintosh264
It seems like whatever your trying to execute (i.e.the method that holds the command) isn't reading it properly. Try re-packaging your project, it's happened to me many times and that is usually an easy fix.

Categories