JODD Message parsing failed; <--- java.lang.NullPointerException - imap

I'm using Jodd version 3.9 and I would like to read an outlook account (Microsoft Exchange).
]
int port = 993;
ImapSslServer imapServer = new ImapSslServer("mail.myhost.it", port, "authuser", "authpass");
imapServer.setProperty("mail.imap.connectiontimeout", "15000");
ReceiveMailSession session = imapServer.createSession();
session.open();
_log.info("total number of inbox emails : " + session.getMessageCount());
ReceivedEmail[] emails = session.receiveEmailAndMarkSeen(EmailFilter.filter().flag(Flags.Flag.SEEN, false));
but i get this error at the line : session.receiveEmailAndMarkSeen(...)
jodd.mail.MailException: Message parsing failed; <---
java.lang.NullPointerException
this is a debug:
A8 FETCH 4 (BODYSTRUCTURE)
* 4 FETCH (BODYSTRUCTURE (("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 1401 35 NIL NIL NIL NIL) "mixed" ("boundary" "----=_Part_1029639_1159929762.1507643405808") NIL NIL))
[ERROR] 11 ott 04:57:31.467 PM [com.afterbit.jobs.EmailJob] (mGxTfT0) EXCEPTION session.receiveEmailAndMarkSeen : jodd.mail.MailException: Message parsing failed; <--- java.lang.NullPointerException
A9 CLOSE
A8 OK FETCH completed.
A9 OK CLOSE completed.
I cannot understand why...

[SOLVED] I hope this help... and save time (i have spend many days..)
there is a conflict between javamail and apache CXF.
apache cxf has a inner file geronimo-javamail_1.4_spec-1.7.1.jar .. so if you add into your project also mail.jar (javamail) and use IMAP protocol, it can generate error like above!

Related

Syntax error in BODYSTRUCTURE. Unexpected token: [qstring: "Multipart message"]

Almost 2 years ago I made this post.
Mailkit Fetch "Unexpected token in IMAP response: [qstring: "Multipart message"]"
During this time I choose GetMessage instead of Fetch.
Now, I´m testing SignalR, just to show a ProgressBar during Check Mailbox and revisiting some threads, I decided to change my code to use Fetch instead o GetMessage, the time difference to have all info I need is HUGE.
But, even upgrading Mailkit to latest version, I´m back on same issue, but this time error message changed to Syntax error in BODYSTRUCTURE. Unexpected token: [qstring: "Multipart message"]
In thread I mention, the conclusion was a problem in Mail Server, not on specific message. What I agree.
Now I sure it is a problem with outlook.office365.com
Here is the log part where Fetch fire exception
S: * 56961 FETCH (ENVELOPE ("Fri, 22 Sep 2017 14:05:47 +0000" "=?iso-8859-1?Q?Not_Fara_0000276_s=E9rie_1___-_Ped_int_0032?= =?iso-8859-1?Q?3__Ped_cli_313?=" ((NIL NIL "workflow" "kermoklast.com")) NIL NIL ((NIL NIL "fiscal" "genera.com") (NIL NIL "nfe" "kermoklast.com") (NIL NIL "kjkilber" "gmail.com") (NIL NIL "ven" "kermoklast.com") (NIL NIL "prod" "kermoklast.com") (NIL NIL "vennac" "kermoklast.com")) NIL NIL NIL "<20170922140643.FF5ED40100B#proxy.email-ssl.com>") BODYSTRUCTURE (("text" "html" ("charset" "iso-8859-1") NIL NIL "Quoted-Printable" 7170 95 NIL NIL NIL NI
By the way, yes string above ends with "NI"

CamelExchangeException: Cannot write response to ... caused by UnsupportedException

I have a camel route in grails. The exception goes away when I comment out the unmarshall line in the processor as if it was taking too long for the TCP response to be sent back in time. If my assessment is correct, if there a setting in netty to send the response back without waiting?
Thanks.
from("netty4:tcp://172.25.200.66:12345?
clientMode=true&disconnectOnNoReply=false&connectTimeout=100000
&reconnect=true&allowDefaultCodec=false&decoder=#jsonDecoderFactory")
.to("log:dump?showAll=true")
.bean("messageProcessorService", "processMessage")
def processMessage (String msg) {
log.debug("MessageProcessorService processMessage")
def object = unmarshall(msg)
}
2017-01-13 13:20:58,186 | WARN | camel.component.netty4.NettyConsumer |
Caused by: [org.apache.camel.CamelExchangeException - Cannot write response to /172.25.200.66:12345.
Exchange[ID-wulg2-chij-udev-local-41278-1484313632001-0-20][Message: []].
Caused by: [java.lang.UnsupportedOperationException - unsupported message
type: Collections$UnmodifiableList (expected: ByteBuf, FileRegion)]]
org.apache.camel.CamelExchangeException: Cannot write response to
/172.25.200.66:12345.
Exchange[ID-wulg2-chij-udev-local-41278-1484313632001-0-20][Message: []].
Caused by: [java.lang.UnsupportedOperationException - unsupported message
It turns out that option "sync=false" sets the endpoint to one-way. Thus not requiring to write responses back.

Event Sync Token (412 response status )

I'm using RestTemplate to make the GET call to asana's REST Api.
By using postmen when i'm calling:
https://app.asana.com/api/1.0/events?resource=PROJECT_ID
I'm getting a message and a sync token ( this is the same case when the sync token is too old and needs to be renewed ).
By using the RestTemplate, when the sync token is too old \ its the first call i'm making and I need a sync token, I'm getting a 412 response "Prediction Faild".
This happens also in postman, but i'm getting along with the "error" message the new sync token.
With the RestTemplate all i'm getting is this error:
Aug 06, 2015 3:56:55 PM org.springframework.web.client.RestTemplate handleResponseError
WARNING: GET request foPROJECT_ID21650756795165" resulted in 412 (Precondition Failed); invoking error handler
Exception in thread "main" org.springframework.web.client.HttpClientErrorException: 412 Precondition Failed
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:90)
at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:494)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:451)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:409)
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:385)
at availo.worker.asana.MainTask.getEvents(MainTask.java:86)
at availo.worker.asana.MainTask.getProjects(MainTask.java:76)
at availo.worker.asana.MainTask.main(MainTask.java:115)
Any suggestions?
Thanks!
This worked for me. It lets you read the message that comes with the error:
restTemplate.setErrorHandler(new DefaultResponseErrorHandler(){
protected boolean hasError(HttpStatus statusCode) {
return false;
}});
When first subscribing to Events on a resource you will receive a 412 Precondition Failed response code due to the fact that there is no sync token established yet. You should extract that sync token and use it in your next request to begin receiving events.
It looks like RestTemplate is invoking an error handler due to the 412 response code, which is understandable as a 412 is an error code.
If you can override DefaultResponseErrorHandler.handleError(), check that the response is a 412, then extract the sync token you could pass that in your next request to get events on the resource.
Another option is to use our Java client library, which should handle all of this for you.
This is what it might look like using our client:
System.out.println("Watching for events on project: " + project.name);
for (Event event : client.events.get(project.id)) {
System.out.println("User: " + event.user.name + "\nAction: " + event.action + "\nResource: " + event.resource);
}

Umbraco Log Error Failed to load Xml from file

I get lots of Errors in my Umbraco 7.2.6 log file. And sometimes the CMS is broken, needs to restart IIS or browser. All errors are somethings with the load or save XML Lock or Thread aborted. I use the default Umbraco config on a simple shared hosting environment.
But It often works well. (so no file permission or somethings I expect)
What is wrong?
2015-07-07 09:45:02,833 [10] INFO umbraco.BusinessLogic.Log - [T15/D3] Log scrubbed. Removed all items older than 2015-05-08 09:45:02
2015-07-07 09:45:40,726 [10] ERROR umbraco.content - [T8/D3] Failed to load Xml from file.
System.Threading.ThreadAbortException: Thread was being aborted.
at System.Threading.WaitHandle.WaitOneNative(SafeHandle waitableSafeHandle, UInt32 millisecondsTimeout, Boolean hasThreadAffinity, Boolean exitContext)
at System.Threading.WaitHandle.InternalWaitOne(SafeHandle waitableSafeHandle, Int64 millisecondsTimeout, Boolean hasThreadAffinity, Boolean exitContext)
at System.Threading.WaitHandle.WaitOne(Int32 millisecondsTimeout, Boolean exitContext)
at System.Threading.WaitHandle.WaitOne(Int32 millisecondsTimeout)
at Umbraco.Core.AsyncLock.Lock(Int32 millisecondsTimeout)
at umbraco.content.EnsureFileLock()
at umbraco.content.LoadXmlFromFile()
2015-07-07 09:45:40,741 [10] ERROR Umbraco.Web.WebServices.ScheduledPublishController - [T55/D3] Error executing scheduled task
System.Threading.ThreadAbortException: Thread was being aborted.
at umbraco.content.LoadXmlFromFile()
at umbraco.content.LoadXmlLocked(SafeXmlReaderWriter safeXml, Boolean& registerXmlChange)
at umbraco.content..ctor()
at umbraco.content.<.cctor>b__17()
at System.Lazy`1.CreateValue()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Lazy`1.LazyInitValue()
at System.Lazy`1.get_Value()
at Umbraco.Web.WebServices.ScheduledPublishController.Index()
2015-07-07 09:45:40,757 [10] ERROR Umbraco.Web.Scheduling.ScheduledPublishing - [T7/D3] An error occurred with the scheduled publishing. The base url used in the request was: http://acc.xxxxxxx.nl:80/umbraco/, see http://our.umbraco.org/documentation/Using-Umbraco/Config-files/umbracoSettings/#ScheduledTasks documentation for details on setting a baseUrl if this is in error
System.Net.WebException: The remote server returned an error: (400) Bad Request.
at System.Net.WebClient.UploadDataInternal(Uri address, String method, Byte[] data, WebRequest& request)
at System.Net.WebClient.UploadString(Uri address, String method, String data)
at System.Net.WebClient.UploadString(String address, String data)
at Umbraco.Web.Scheduling.ScheduledPublishing.PerformRun()
2015-07-07 09:46:14,905 [10] INFO Umbraco.Core.PluginManager - [T19/D3] Starting resolution types of Umbraco.Core.PropertyEditors.IParameterEditor
2015-07-07 12:55:10,801 [17] ERROR umbraco.content - [T18/D11] Failed to save Xml to file.
System.TimeoutException: Failed to enter the lock within timeout.
at Umbraco.Core.AsyncLock.Lock(Int32 millisecondsTimeout)
at umbraco.content.EnsureFileLock()
at umbraco.content.<SaveXmlToFileAsync>d__d.MoveNext()
2015-07-07 14:03:09,702 [9] ERROR umbraco.content - [T7/D3] Failed to load Xml from file.
System.TimeoutException: Failed to enter the lock within timeout.
at Umbraco.Core.AsyncLock.Lock(Int32 millisecondsTimeout)
at umbraco.content.EnsureFileLock()
at umbraco.content.LoadXmlFromFile()
This issue was related to http://issues.umbraco.org/issue/U4-6802
it is fixed in the Umbraco v7.2.8 release.

Grails + spring-security-core:2.0-RC4 + spring-security-ldap:2.0-RC2

I'm using Grails 2.4 + spring-security-core:2.0-RC4.
I want to use LDAP for authentication but allow only usernames that are in the database and enabled for login.
I already have three domains: user, role and UserRole.
I add compile ":spring-security-ldap:2.0-RC2" in BuildConfig.groovy
and followed the example below but It doesn't work:
This is the error I am getting:
Error | 2015-03-25 18:05:38,542 [http-bio-8090-exec-2] ERROR authentication.RequestHolderAuthenticationFilter - An internal error occurred while trying to authenticate the user. Message: Uncategorized exception occured during LDAP processing; nested exception is javax.naming.NamingException: [LDAP: error code 1 - 000004DC: LdapErr: DSID-0C0906E9, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, v1db1 –
https://chlebik.wordpress.com/2014/10/27/ldap-authentication-and-db-authorisation-with-grails-spring-security/
How do I resolve this?

Resources