I'm building a web service in java, deploying it under Jboss-as-7.1.1.Final, based on org.apache.cxf.
I need to expose a web method that takes in input a date field that can reach many centuries in the past.
At the moment I'm using java.util.Date.
So, my web method is
public UpdatePersonResponse updatePerson(UpdatePersonRequest request) {
...
}
the request bean UpdatePersonRequest has:
...
private Date birthday;
...
In the soap request that I'm testing I put:
<!--Optional:-->
<birthday>1452-04-15</birthday>
The apache cxf logs show:
16:07:36,568 INFO [org.apache.cxf.interceptor.LoggingInInterceptor] ... Inbound Message
[...]
<birthday>1452-04-15</birthday>
(this is correct)
A custom log I added into the set method of the request bean shows:
16:07:36,843 DEBUG com.xxx.xxx.service.request.UpdatePersonRequest ... called setBirthday with argument [06/04/52 0.00]
(this is wrong)
Then the request bean is valorized as follows:
UpdatePersonRequest [... birthday=Thu Apr 06 00:00:00 CET 1452, ...]
(this is wrong)
So I obtain 1452 April 06, and not 1452 April 15.
I tried with different dates, for example,
soap:
<birthday>1452-04-30</birthday>
custom log:
21:11:51,607 DEBUG [com.xxx.xxx.service.request.UpdatePersonRequest] ... called setBirthday with argument [21/04/52 0.00]
(wrong)
The bean is:
UpdatePersonRequest [... birthday=Fri Apr 21 00:00:00 CET 1452 ...]
(again wrong)
I obtain April 21 and not April 30.
I tried with several dates and noticed that the issue occurs for dates prior then 15 Oct 1582. For more recent dates all works fine and the request bean is correctly valorized.
Is there some java.util.Date limitation that I'm not considering?
Should I use another java Type to represent these kind of dates, and what?
Thank you very much.
EDIT
The effect is that the date I entered into the soap request is converted in Julian date and then the Date I persist on the database will be this converted date.
But I'd like to write on DB the exact date I enter in the request and not a corrected one, in other words I want the caller to deal with the right date system to use, and not any conversion be made automatically by the system.
How can I obtain this?
You are encountering the switch from the Julian to the Gregorian calendar. This is a historical event, not a feature of Java. Googling "Gregorian calendar" will tell you more.
Related
I have application written in spring that allows user to filter data by date.
Filters model:
data class FilterCommand(
#field:DateTimeFormat(pattern = "dd/MM/yyyy") val dateFrom: Date?,
#field:DateTimeFormat(pattern = "dd/MM/yyyy") val dateTo: Date?,
val author: String?,
val state: String?
)
Everything works fine, except when user chooses 07/06/2019 in UI, I get exactly same value in Spring in current timezone.
Is it possible to tell spring to treat this incoming data as UTC?
Or to convert it somehow on model level?
Date I receive: Fri Jun 07 00:00:00 CEST 2019
Date I would like to get: Fri Jun 07 00:00:00 UTC 2019
You can configure the timezone directly in the JVM, so if you set it to UTC, all dates will be on UTC.
In ATG i got below exception, when this.getSmtpEmailSender().sendEmailMessage(msg) method called. But same code working fine with different environment. May be it configuration issue. what i need to check.
/com/ncr/base/common/services/EmailService
java.lang.Exception: The final format argument for a vlog call is a throwable, but is not referenced. The throwable will be logged, but please use an explicit Throwable argument before the format string to eliminate ambiguity.
**** Warning Fri Dec 21 02:49:02 -05:00 2018 1545378542129 /com/ncr/base/common/services/EmailService at atg.nucleus.logging.VariableArgumentApplicationLoggingUtil.getUnreferencedThrowable(VariableArgumentApplicationLoggingUtil.java:744)
**** Warning Fri Dec 21 02:49:02 -05:00 2018 1545378542129 /com/ncr/base/common/services/EmailService at atg.nucleus.logging.VariableArgumentApplicationLoggingUtil.vlogError(VariableArgumentApplicationLoggingUtil.java:344)
/com/ncr/base/common/services/EmailService nested exception is:
com.sun.mail.smtp.SMTPSenderFailedException: 501 5.1.7 Invalid address
My guess is one of your email addresses is not valid in either the To or From fields.
ATG allows you to configure defaults for the /atg/dynamo/service/SMTPEmail/ components and I think that you are missing a configuration for the environment in question. I would recommend you open dyn/admin and compare the configuration for SMTP email for environments which are working vs ones which are not.
I am working on a tool which uses ews-java-api to create, update and delete calendar items in Outlook agenda. It has been working fine, but now sometimes when it tries to update some calendar item, I get following error:
microsoft.exchange.webservices.data.core.exception.service.remote.ServiceResponseException: At least one recipient isn't valid., A message can't be sent because it contains no recipients.
at microsoft.exchange.webservices.data.core.response.ServiceResponse.internalThrowIfNecessary(ServiceResponse.java:278)
at microsoft.exchange.webservices.data.core.response.ServiceResponse.throwIfNecessary(ServiceResponse.java:267)
at microsoft.exchange.webservices.data.core.request.MultiResponseServiceRequest.execute(MultiResponseServiceRequest.java:165)
at microsoft.exchange.webservices.data.core.ExchangeService.internalUpdateItems(ExchangeService.java:691)
at microsoft.exchange.webservices.data.core.ExchangeService.updateItem(ExchangeService.java:762)
at microsoft.exchange.webservices.data.core.service.item.Item.internalUpdate(Item.java:279)
at microsoft.exchange.webservices.data.core.service.item.Item.update(Item.java:400)
at be.vrt.quintiqexchange.main.QuintiqAdapter.insertUpdateCalendarItems(QuintiqAdapter.java:879)
at be.vrt.quintiqexchange.main.QuintiqAdapter.updateCalendarItems(QuintiqAdapter.java:796)
at be.vrt.quintiqexchange.main.QuintiqAdapter.run(QuintiqAdapter.java:286)
at java.lang.Thread.run(Thread.java:745)
Recently all the exchange accounts have been migrated from local Outlook servers to Office365 cloud servers. Maybe this has something to do with it? Or anybody have any idea on what is going wrong?
Following code is to perform the update for an item:
Item it = alitems.get(i);
...
it.update(ConflictResolutionMode.AlwaysOverwrite);
Following is the url being used to access office365 ews:
exchangewebservice = https://outlook.office365.com/EWS/Exchange.asmx
Thanks in advance
Edit: I use ews-java-api version 2.0
Edit: Here you can see that the error occurs on one line and than the next line, with the same recipient it doesn't occur...
microsoft.exchange.webservices.data.core.exception.service.remote.ServiceResponseException: At least one recipient isn't valid., A message can't be sent because it contains no recipients.
at microsoft.exchange.webservices.data.core.response.ServiceResponse.internalThrowIfNecessary(ServiceResponse.java:278)
at microsoft.exchange.webservices.data.core.response.ServiceResponse.throwIfNecessary(ServiceResponse.java:267)
at microsoft.exchange.webservices.data.core.request.MultiResponseServiceRequest.execute(MultiResponseServiceRequest.java:165)
at microsoft.exchange.webservices.data.core.ExchangeService.internalUpdateItems(ExchangeService.java:691)
at microsoft.exchange.webservices.data.core.ExchangeService.updateItem(ExchangeService.java:762)
at microsoft.exchange.webservices.data.core.service.item.Item.internalUpdate(Item.java:279)
at microsoft.exchange.webservices.data.core.service.item.Item.update(Item.java:400)
at be.vrt.quintiqexchange.main.QuintiqAdapter.insertUpdateCalendarItems(QuintiqAdapter.java:880)
at be.vrt.quintiqexchange.main.QuintiqAdapter.updateCalendarItems(QuintiqAdapter.java:703)
at be.vrt.quintiqexchange.main.QuintiqAdapter.run(QuintiqAdapter.java:283)
at java.lang.Thread.run(Thread.java:745)
WARN be.vrt.quintiqexchange.main.QuintiqAdapter - At least one recipient isn't valid., A message can't be sent because it contains no recipients.by UPDATE for subject: on Thu Jun 23 14:00:00 CEST 2016 Thu Jun 23 19:00:00 CEST 2016 of user name.lastname#domain.com
INFO be.vrt.quintiqexchange.main.QuintiqAdapter - Appointment updated for subject: NIET DAG on Fri Aug 05 10:00:00 CEST 2016 Fri Aug 05 18:00:00 CEST 2016 of user name.lastname#domain.com
INFO be.vrt.quintiqexchange.main.QuintiqAdapter - Appointment updated for subject: PROEF st5 on Mon Aug 22 10:00:00 CEST 2016 Mon Aug 22 20:30:00 CEST 2016 of user name.lastname#domain.com
This means that the recipient isn't really the issue, I guess...
p.s. I replaced the original mailaddress but believe me, it's a correct mailadres :)
In my case, if the address is not properly trimmed and has any whitespace characters at all, EWS vomits this exception up.
Is there some way to get modified date of this file?
I want to check the data every day and download it only if has changed, I tried with HttpURLConnection and con.getHeaderFields() but no results:
{null=[HTTP/1.1 200 OK], Access-Control-Allow-Origin=[*], Age=[158], Cache-Control=[max-age=7200], Connection=[close], Content-Length=[235409], Content-Type=[text/plain], Date=[Wed, 19 Dec 2012 10:00:52 GMT], Expires=[Wed, 19 Dec 2012 11:58:13 GMT], Server=[Apache/2], X-Android-Received-Millis=[1355911252001], X-Android-Sent-Millis=[1355911251975]}
Is there a better way of getting an md5 hash and compare it with a local file?
Nope, there is no general way to get the modified date of a URL. Computing the MD5 hash of the HTTP response body and comparing that against the local file is the best way.
I'm trying to use javamail to download a mailbox of 1000 messages of hotmail.
The problem is after an hour or so, I get a Pop Session timeout exception, and I can't fetch messages anymore.
C: TOP 3210 0
S: +OK 1444 byte(s)
X-Message-Delivery: Vj0zLjQuMDt1cz0wO2k9MDtsPTA7YT0x
X-Message-Status: n:0
X-SID-PRA: Super Wall <apps+ocdlfcez#facebookmail.com>
X-SID-Result: Pass
X-Message-Info: R00BdL5giqoqgO8FeGWl8Lch6n3is6BT1wNitKPj0Jb+fghk1p9MsC+MFGyB2nflerotq/xZ5r8LiguM+3GjEOSj3umkoXeU
Received: from mx-out.facebook.com ([204.15.20.140]) by bay0-mc7-f15.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.2668);
Tue, 8 Apr 2008 15:14:55 -0700
Received: from api.facebook.com (intlb01-mip1.sctm.tfbnw.net [10.1.240.6])
by mx-out.facebook.com [email018.sctm.facebook.com] (8.13.6/8.13.6) with ESMTP id m38MEtOg030239
for <xgameprogrammer#hotmail.com>; Tue, 8 Apr 2008 15:14:55 -0700
X-Facebook: from zuckmail ([168.143.164.188])
by api.facebook.com with HTTP (ZuckMail);
Date: Tue, 8 Apr 2008 15:14:55 -0700
To: Ahmed Saleh <xgameprogrammer#hotmail.com>
From: Super Wall <apps+ocdlfcez#facebookmail.com>
Reply-to: Facebook <apps+ocdlfcez#facebookmail.com>
Subject: You just received a new photo from Lejla Boric
Message-ID: <03df95f3306af0a88432e7fcca22f7ac#api.facebook.com>
X-Priority: 3
X-Mailer: ZuckMail [version 1.00]
X-Facebook-Notify: platform_email
Errors-To: apps+ocdlfcez#facebookmail.com
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="b1_03df95f3306af0a88432e7fcca22f7ac"
Return-Path: apps+ocdlfcez#facebookmail.com
X-OriginalArrivalTime: 08 Apr 2008 22:14:55.0926 (UTC) FILETIME=[F9D6A560:01C899C5]
.
C: RETR 3210
S: -ERR POP3 session timed out
javax.mail.MessagingException: No inputstream from datasource;
SentDate : Wed Apr 09 01:14:55 AST 2008
nested exception is:
As I said in my comment, this is just a simple case of the session timing out. Like anything, the mail server will have a time limit to prevent excessive access, which is how would describe downloading emails for over an hour!
There is nothing wrong with your code, your just asking too much of hotmail / the mail server!
Though, just some friendly advice: the next time you ask a question here on SO, please don't post irrelevant information like you have done here. In cases like yours, it is helpful to see atleast a snippet of the code that is responsible for that part of the application that is functioning incorrectly and any exceptions - we'd also need to see the line(s) of code mentioned in the stack trace... However, a start would be to actually ask a question instead of this stating a fact, like you have done here!