activecampaign / postmark-java Goto Github PK
View Code? Open in Web Editor NEWOfficial Java client library for the Postmark HTTP API
Home Page: https://postmarkapp.com
License: MIT License
Official Java client library for the Postmark HTTP API
Home Page: https://postmarkapp.com
License: MIT License
Hi, I'm trying to use the postmark-java dependency and all seems well except for our current logging configuration seems to be getting overridden by the log4j2.properties file from the postmark-java library.
I'm not sure if this properties file should be included in the jar or not - from reading online it's usually warned against for this exact reason.
My current log4j2 configuration is through log4j2.xml, while debugging the application I can see that without the postmark-java dependency my configuration looks like below (XmlConfiguration, level shown as DEBUG):
While with the dependency added, the logger is now using values from log4j2.properties (Note the difference here, originally the config was XmlConfiguration, it's now PropertiesConfiguration, also level is now OFF), and no longer logging anything
Seeing this from time to time:
org.glassfish.jersey.message.internal.HeaderValueException:Too many "Content-Type" header values: "[application/json, application/json]"
org.glassfish.jersey.message.internal.OutboundMessageContext.singleHeader(OutboundMessageContext.java:199)
org.glassfish.jersey.message.internal.OutboundMessageContext.getMediaType(OutboundMessageContext.java:270)
org.glassfish.jersey.client.ClientRequest.ensureMediaType(ClientRequest.java:511)
org.glassfish.jersey.client.ClientRequest.writeEntity(ClientRequest.java:441)
org.glassfish.jersey.client.internal.HttpUrlConnector._apply(HttpUrlConnector.java:367)
org.glassfish.jersey.client.internal.HttpUrlConnector.apply(HttpUrlConnector.java:265)
org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:297)
org.glassfish.jersey.client.JerseyInvocation.lambda$invoke$1(JerseyInvocation.java:643)
org.glassfish.jersey.client.JerseyInvocation.call(JerseyInvocation.java:665)
org.glassfish.jersey.client.JerseyInvocation.lambda$runInScope$3(JerseyInvocation.java:659)
org.glassfish.jersey.internal.Errors.process(Errors.java:292)
org.glassfish.jersey.internal.Errors.process(Errors.java:274)
org.glassfish.jersey.internal.Errors.process(Errors.java:205)
org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:390)
org.glassfish.jersey.client.JerseyInvocation.runInScope(JerseyInvocation.java:659)
org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:642)
org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:445)
org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:346)
com.wildbit.java.postmark.client.HttpClient.execute(HttpClient.java:62)
com.wildbit.java.postmark.client.HttpClientHandler.execute(HttpClientHandler.java:62)
com.wildbit.java.postmark.client.ApiClient.deliverMessage(ApiClient.java:67)
Hello,
Here my code:
TemplatedMessage message = new TemplatedMessage(from, "[email protected]");
message.setTemplateId(6025382);
Map<String,Object> model = new HashMap<>();
model.put("firstName", "William");
model.put("lastName", "uiop");
model.put("action_url", "https://github.com/wildbit/postmark-java/issues/new?op=78");
message.setTemplateModel(model);
// send email with template
MessageResponse response;
response = client.deliverMessageWithTemplate(message);
and generates an unexpected error:
java.lang.IllegalStateException: InjectionManagerFactory not found.
at org.glassfish.jersey.internal.inject.Injections.lambda$lookupInjectionManagerFactory$0(Injections.java:98)
at java.util.Optional.orElseThrow(Optional.java:290)
at org.glassfish.jersey.internal.inject.Injections.lookupInjectionManagerFactory(Injections.java:98)
at org.glassfish.jersey.internal.inject.Injections.createInjectionManager(Injections.java:68)
at org.glassfish.jersey.client.ClientConfig$State.initRuntime(ClientConfig.java:432)
at org.glassfish.jersey.internal.util.collection.Values$LazyValueImpl.get(Values.java:341)
at org.glassfish.jersey.client.ClientConfig.getRuntime(ClientConfig.java:826)
at org.glassfish.jersey.client.ClientRequest.getConfiguration(ClientRequest.java:285)
at org.glassfish.jersey.client.JerseyInvocation.validateHttpMethodAndEntity(JerseyInvocation.java:143)
at org.glassfish.jersey.client.JerseyInvocation.<init>(JerseyInvocation.java:112)
at org.glassfish.jersey.client.JerseyInvocation.<init>(JerseyInvocation.java:108)
at org.glassfish.jersey.client.JerseyInvocation.<init>(JerseyInvocation.java:99)
at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:456)
at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:357)
at com.wildbit.java.postmark.client.HttpClient.execute(HttpClient.java:61)
at com.wildbit.java.postmark.client.HttpClientHandler.execute(HttpClientHandler.java:60)
at com.wildbit.java.postmark.client.ApiClient.deliverMessageWithTemplate(ApiClient.java:157)
at ...
I am running a website through Spring Boot 2 and the version 1.1 of the Postmark library.
Please, can you help?
As discussed in this issue #33
We're still getting this error time to time. We're using 1.8.0 version.
Do you have any idea on this?
Thank you
At this line:
https://github.com/wildbit/postmark-java/blob/master/src/main/java/com/wildbit/java/postmark/Postmark.java#L51
the stack trace is written to console. In clustered environments this message could get lost, as the console output is disabled. Logging messages are usually directed using a logging framework.
One dependency is already using slf4j:
[INFO] +- eu.medsea.mimeutil:mime-util:jar:2.1.3:compile
[INFO] | +- org.slf4j:slf4j-api:jar:1.5.6:compile
[INFO] | +- org.slf4j:slf4j-log4j12:jar:1.5.6:runtime
[INFO] | \- log4j:log4j:jar:1.2.14:runtime
Unfortunately it's an older version. Another option would be to use JUL directly. However, usually slf4j is being used as it's compatible with all major frameworks and is also offering basic logging for those who don't want to include them.
Hi, seeing these errors time to time:
org.glassfish.jersey.message.internal.HeaderValueException: Too many "Content-Type" header values: "[application/json]" at org.glassfish.jersey.message.internal.OutboundMessageContext.singleHeader(OutboundMessageContext.java:199) at org.glassfish.jersey.message.internal.OutboundMessageContext.getMediaType(OutboundMessageContext.java:270) at org.glassfish.jersey.client.ClientRequest.ensureMediaType(ClientRequest.java:511) at org.glassfish.jersey.client.ClientRequest.writeEntity(ClientRequest.java:441) at org.glassfish.jersey.client.internal.HttpUrlConnector._apply(HttpUrlConnector.java:369) at org.glassfish.jersey.client.internal.HttpUrlConnector.apply(HttpUrlConnector.java:267) at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:297) at org.glassfish.jersey.client.JerseyInvocation.lambda$invoke$1(JerseyInvocation.java:675) at org.glassfish.jersey.client.JerseyInvocation.call(JerseyInvocation.java:697) at org.glassfish.jersey.client.JerseyInvocation.lambda$runInScope$3(JerseyInvocation.java:691) at org.glassfish.jersey.internal.Errors.process(Errors.java:292) at org.glassfish.jersey.internal.Errors.process(Errors.java:274) at org.glassfish.jersey.internal.Errors.process(Errors.java:205) at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:390) at org.glassfish.jersey.client.JerseyInvocation.runInScope(JerseyInvocation.java:691) at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:674) at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:450) at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:351) at com.wildbit.java.postmark.client.HttpClient.execute(HttpClient.java:62) at com.wildbit.java.postmark.client.HttpClientHandler.execute(HttpClientHandler.java:62) at com.wildbit.java.postmark.client.ApiClient.deliverMessageWithTemplate(ApiClient.java:167) at io.wamo.clients.mail.provider.PostmarkClient.sendWithTemplateId(PostmarkClient.java:56)
java.lang.NullPointerException: null at java.util.LinkedList$ListItr.next(LinkedList.java:897) at java.util.AbstractCollection.toString(AbstractCollection.java:472) at org.glassfish.jersey.message.internal.OutboundMessageContext.singleHeader(OutboundMessageContext.java:199) at org.glassfish.jersey.message.internal.OutboundMessageContext.getMediaType(OutboundMessageContext.java:270) at org.glassfish.jersey.client.ClientRequest.ensureMediaType(ClientRequest.java:511) at org.glassfish.jersey.client.ClientRequest.writeEntity(ClientRequest.java:441) at org.glassfish.jersey.client.internal.HttpUrlConnector._apply(HttpUrlConnector.java:369) at org.glassfish.jersey.client.internal.HttpUrlConnector.apply(HttpUrlConnector.java:267) at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:297) at org.glassfish.jersey.client.JerseyInvocation.lambda$invoke$1(JerseyInvocation.java:675) at org.glassfish.jersey.client.JerseyInvocation.call(JerseyInvocation.java:697) at org.glassfish.jersey.client.JerseyInvocation.lambda$runInScope$3(JerseyInvocation.java:691) at org.glassfish.jersey.internal.Errors.process(Errors.java:292) at org.glassfish.jersey.internal.Errors.process(Errors.java:274) at org.glassfish.jersey.internal.Errors.process(Errors.java:205) at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:390) at org.glassfish.jersey.client.JerseyInvocation.runInScope(JerseyInvocation.java:691) at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:674) at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:450) at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:351) at com.wildbit.java.postmark.client.HttpClient.execute(HttpClient.java:62) at com.wildbit.java.postmark.client.HttpClientHandler.execute(HttpClientHandler.java:62) at com.wildbit.java.postmark.client.ApiClient.deliverMessageWithTemplate(ApiClient.java:167) at io.wamo.clients.mail.provider.PostmarkClient.sendWithTemplateId(PostmarkClient.java:56)
we are using in safe thread with last version of the library which is 1.8.0
There are cases when HTTP status code is outside of scope that library can handle, like 503 status, which would be classified as Unknown error.
For errors, we should preserve all the information we can, which would be in this case HTTP status code next to the response message.
This library's logging dependencies need work. Here is the dependency report from Gradle:
+--- com.wildbit.java:postmark:1.7
| +--- org.glassfish.jersey.core:jersey-client:2.33
| | +--- jakarta.ws.rs:jakarta.ws.rs-api:2.1.6
| | +--- org.glassfish.jersey.core:jersey-common:2.33
| | | +--- jakarta.ws.rs:jakarta.ws.rs-api:2.1.6
| | | +--- jakarta.annotation:jakarta.annotation-api:1.3.5
| | | +--- org.glassfish.hk2.external:jakarta.inject:2.6.1
| | | \--- org.glassfish.hk2:osgi-resource-locator:1.0.3
| | \--- org.glassfish.hk2.external:jakarta.inject:2.6.1
| +--- org.glassfish.jersey.inject:jersey-hk2:2.33
| | +--- org.glassfish.jersey.core:jersey-common:2.33 (*)
| | +--- org.glassfish.hk2:hk2-locator:2.6.1
| | | +--- org.glassfish.hk2.external:jakarta.inject:2.6.1
| | | +--- org.glassfish.hk2.external:aopalliance-repackaged:2.6.1
| | | +--- org.glassfish.hk2:hk2-api:2.6.1
| | | | +--- org.glassfish.hk2.external:jakarta.inject:2.6.1
| | | | +--- org.glassfish.hk2:hk2-utils:2.6.1
| | | | | \--- org.glassfish.hk2.external:jakarta.inject:2.6.1
| | | | \--- org.glassfish.hk2.external:aopalliance-repackaged:2.6.1
| | | \--- org.glassfish.hk2:hk2-utils:2.6.1 (*)
| | \--- org.javassist:javassist:3.25.0-GA
| +--- javax.activation:activation:1.1.1
| +--- com.fasterxml.jackson.core:jackson-core:2.10.0 -> 2.11.4
| +--- com.fasterxml.jackson.core:jackson-annotations:2.10.0 -> 2.11.4
| +--- com.fasterxml.jackson.core:jackson-databind:2.10.0 -> 2.11.4 (*)
| +--- eu.medsea.mimeutil:mime-util:2.1.3
| | +--- org.slf4j:slf4j-api:1.5.6 -> 1.7.30
| | +--- org.slf4j:slf4j-log4j12:1.5.6
| | | +--- org.slf4j:slf4j-api:1.5.6 -> 1.7.30
| | | \--- log4j:log4j:1.2.14
| | \--- log4j:log4j:1.2.14
| +--- org.apache.logging.log4j:log4j-api:2.9.1 -> 2.14.1
| \--- org.apache.logging.log4j:log4j-core:2.9.1 -> 2.14.1 (*)
I see a few issues here:
You should not expose log4j-core as a transitive dependency. Depending on log4j-api
isn't too bad as at least it's just an API and not a logging implementation, but probably more standard for a library like this would be a dependency on slf4j-api or just use JUL.
Your eu.medsea.mimeutil:mime-util
dependency transitively exposes an slf4j implementation slf4j-log4j12
as well as a log4j implementation log4j:log4j:1.2.14
(!). This is (very) wrong and until this is fixed upstream, you should exclude both of these transitive dependencies in your library so that projects including postmark-java don't get them transitively either.
As per #26, I do note your library includes a log4j2.properties
file. It should not -- configuring logging is a consuming application concern, not a library concern.
For Gradle, one way to work around 1 and 2 above is to exclude these dependencies in consuming projects, but this should not be necessary:
implementation("com.wildbit.java:postmark:1.7") {
exclude("org.slf4j", "slf4j-log4j12")
exclude("log4j", "log4j")
exclude("org.apache.logging.log4j", "log4j-core")
}
Summary: We use Quarkus framework (Right now at 2.16.7.Final
) and the existing 1.9.0
Postmark version.
Quarkus has recently launched Quarkus 3.0
and 3.1
that completely move to Jakarta EE 10 (that doesn't keep compatibility with Java EE/Jakarta 8.
Existing issue
These would move to jakarta.*...
Describe the solution you'd like
A version that supports Jakarta EE.
Additional context
https://medium.com/@AlexanderObregon/how-to-migrate-from-java-ee-to-jakarta-ee-tips-and-best-practices-f19530c3bb1d
I have a RESTful web service application in java deployed on google app-engine which uses jersey 1.18.6.
I want to use postmark java client to send transactional emails from it.
When I integrated it, i was seeing the following exception:
javax.ws.rs.core.Response$Status$Family.familyOf(I)Ljavax/ws/rs/core/Response$Status$Family
From what I could find, I think this error was because of there were two different (and probably incompatible) version of jersey being used ,1.18.6 for jersey-server, jersey-guice and jersey-bundle and 2.25.1 for jersey-client (by postmark).
Then I tried to make the jersey version 1.18,6 throughout, so in the my main project pom, while including the dependency for postmark, I excluded the jersey-client (by added exclusions header) and separately added jersey-client dependency in my main project .
But then I got the following error:
java.lang.NoClassDefFoundError: javax/ws/rs/core/MultivaluedHashMap
This is I think the class MultivaluedHashMap is present only in jax-rs 2.x versions (which is compatible with jersey 2.x versions)
So my questions are:
Currently the lib does not support use with spring boot higher than version 3, due to the javax. Do you have any plans to update the lib?
UnrecognizedPropertyException: Unrecognized field "FirstOpen" when
converting DataHandler().fromJson(jason, OutboundMessageOpen.class)
per example of Open tracking webhook
{
"FirstOpen": true,
"Client": {
"Name": "Chrome 35.0.1916.153",
"Company": "Google",
"Family": "Chrome"
} .....
Hi,
I get the following error message when sending a simple mail using the latest library.
Track trace:
com.fasterxml.jackson.databind.exc.InvalidFormatException: Can not deserialize value of type java.util.Date from String "2018-04-13T14:50:37.4008047-04:00": not a valid representation (error: Failed to parse Date value '2018-04-13T14:50:37.4008047-04:00': Can not parse date "2018-04-13T14:50:37.4008047-0400": while it seems to fit format 'yyyy-MM-dd'T'HH:mm:ss.SSSZ', parsing fails (leniency? null))
at [Source: {"To":"[email protected]","SubmittedAt":"2018-04-13T14:50:37.4008047-04:00","MessageID":"46f56d35-e169-4efa-a12d-160726177ae9","ErrorCode":0,"Message":"OK"}; line: 1, column: 35] (through reference chain: com.wildbit.java.postmark.client.data.model.message.MessageResponse["SubmittedAt"])
at com.fasterxml.jackson.databind.exc.InvalidFormatException.from(InvalidFormatException.java:74)
at com.fasterxml.jackson.databind.DeserializationContext.weirdStringException(DeserializationContext.java:1410)
at com.fasterxml.jackson.databind.DeserializationContext.handleWeirdStringValue(DeserializationContext.java:926)
at com.fasterxml.jackson.databind.deser.std.StdDeserializer._parseDate(StdDeserializer.java:819)
at com.fasterxml.jackson.databind.deser.std.StdDeserializer._parseDate(StdDeserializer.java:788)
at com.fasterxml.jackson.databind.deser.std.DateDeserializers$DateBasedDeserializer._parseDate(DateDeserializers.java:172)
at com.fasterxml.jackson.databind.deser.std.DateDeserializers$DateDeserializer.deserialize(DateDeserializers.java:259)
at com.fasterxml.jackson.databind.deser.std.DateDeserializers$DateDeserializer.deserialize(DateDeserializers.java:242)
at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:504)
at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:104)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:276)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:140)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3814)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2858)
at com.wildbit.java.postmark.client.data.DataHandler.fromJson(DataHandler.java:47)
at com.wildbit.java.postmark.client.ApiClient.deliverMessage(ApiClient.java:56)
Any suggestions?
Thanks in advance,
Rob
It seems this issue started to happen recently since the 8th of November, it seems that contains breaking changes for some reason, I was using Message and TemplateMessage and sending emails to multiple addresses with a comma-separated form like [email protected],[email protected]
.
Currently, it starts to fire exceptions in the log:
Caused by: com.wildbit.java.postmark.client.exception.InvalidMessageException: Error parsing 'To': Illegal email address '[email protected],[email protected]'. It must contain the '@' symbol.,
at com.wildbit.java.postmark.client.HttpClientErrorHandler.throwErrorBasedOnStatusCode(HttpClientErrorHandler.java:37),
at com.wildbit.java.postmark.client.HttpClientHandler.execute(HttpClientHandler.java:68),
at com.wildbit.java.postmark.client.ApiClient.deliverMessageWithTemplate(ApiClient.java:167),
at providers.emails.PostmarkEmailSenderServiceImp.sendMailWithTemplateTask(PostmarkEmailSenderServiceImp.java:170),
at providers.emails.PostmarkEmailSenderServiceImp.lambda$sendMailWithTemplate$1(PostmarkEmailSenderServiceImp.java:69),
at providers.emails.PostmarkEmailSenderServiceImp.lambda$sendMailScheduler$5(PostmarkEmailSenderServiceImp.java:112)
so, I wanted to fix that and I see there is a function called .setTo()
that accepts an array or a map in Message
and accepts Map only in TemplatedMessage
which I don't understand and is confusing:
.setTo
?.setTo
accept only a map in TemplatedMessage
, why I don't have a function that accepts a list in TemplatedMessage
like Message
, as I have addresses and without names in my current situation.Al-Mothafar Al-Hasan<[email protected]>
and Al-Mothafar Al-Hasan<[email protected]>
.Hi,
it's possible to set metadata in the TemplatedMessage version?
With Message I use
message.setMetadata(meta);
Thank's
I just did an update for my dependency of this library from 1.5.5 to 1.5.6 and this issue happened, reverting back to 1.5.5 solved the issue
[debug] - [ ] - a.s.UserAlertsMaintenanceService - javax.ws.rs.ProcessingException: javax.ws.rs.ProcessingException
java.util.concurrent.CompletionException: javax.ws.rs.ProcessingException: javax.ws.rs.ProcessingException
at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314)
at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)
at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:645)
at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506)
at java.base/java.util.concurrent.CompletableFuture.postFire(CompletableFuture.java:610)
at java.base/java.util.concurrent.CompletableFuture.postFire(CompletableFuture.java:1186)
at java.base/java.util.concurrent.CompletableFuture$BiApply.tryFire(CompletableFuture.java:1208)
at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:479)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
Caused by: javax.ws.rs.ProcessingException: javax.ws.rs.ProcessingException
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at java.base/java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:600)
at java.base/java.util.concurrent.ForkJoinTask.reportException(ForkJoinTask.java:678)
at java.base/java.util.concurrent.ForkJoinTask.invoke(ForkJoinTask.java:737)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateParallel(ReduceOps.java:919)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:233)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
Caused by: javax.ws.rs.ProcessingException: null
at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:287)
at org.glassfish.jersey.client.JerseyInvocation.lambda$invoke$1(JerseyInvocation.java:767)
at org.glassfish.jersey.internal.Errors.process(Errors.java:316)
at org.glassfish.jersey.internal.Errors.process(Errors.java:298)
at org.glassfish.jersey.internal.Errors.process(Errors.java:229)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:414)
at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:765)
at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:428)
at org.glassfish.jersey.client.JerseyInvocation$Builder.get(JerseyInvocation.java:324)
at com.wildbit.java.postmark.client.HttpClient.execute(HttpClient.java:66)
Caused by: java.lang.NullPointerException: null
at java.base/java.util.LinkedList$ListItr.next(LinkedList.java:897)
at org.glassfish.jersey.internal.util.collection.Views$1$1.next(Views.java:96)
at org.glassfish.jersey.client.internal.HttpUrlConnector.setOutboundHeaders(HttpUrlConnector.java:428)
at org.glassfish.jersey.client.internal.HttpUrlConnector._apply(HttpUrlConnector.java:387)
at org.glassfish.jersey.client.internal.HttpUrlConnector.apply(HttpUrlConnector.java:282)
at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:278)
at org.glassfish.jersey.client.JerseyInvocation.lambda$invoke$1(JerseyInvocation.java:767)
at org.glassfish.jersey.internal.Errors.process(Errors.java:316)
at org.glassfish.jersey.internal.Errors.process(Errors.java:298)
at org.glassfish.jersey.internal.Errors.process(Errors.java:229)
[error] - [ ] - a.d.TaskInvocation - null
javax.ws.rs.ProcessingException: null
at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:287)
at org.glassfish.jersey.client.JerseyInvocation.lambda$invoke$1(JerseyInvocation.java:767)
at org.glassfish.jersey.internal.Errors.process(Errors.java:316)
at org.glassfish.jersey.internal.Errors.process(Errors.java:298)
at org.glassfish.jersey.internal.Errors.process(Errors.java:229)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:414)
at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:765)
at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:428)
at org.glassfish.jersey.client.JerseyInvocation$Builder.get(JerseyInvocation.java:324)
at com.wildbit.java.postmark.client.HttpClient.execute(HttpClient.java:66)
Caused by: java.lang.NullPointerException: null
at java.base/java.util.LinkedList$ListItr.next(LinkedList.java:897)
at org.glassfish.jersey.internal.util.collection.Views$1$1.next(Views.java:96)
at org.glassfish.jersey.client.internal.HttpUrlConnector.setOutboundHeaders(HttpUrlConnector.java:428)
at org.glassfish.jersey.client.internal.HttpUrlConnector._apply(HttpUrlConnector.java:387)
at org.glassfish.jersey.client.internal.HttpUrlConnector.apply(HttpUrlConnector.java:282)
at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:278)
at org.glassfish.jersey.client.JerseyInvocation.lambda$invoke$1(JerseyInvocation.java:767)
at org.glassfish.jersey.internal.Errors.process(Errors.java:316)
at org.glassfish.jersey.internal.Errors.process(Errors.java:298)
at org.glassfish.jersey.internal.Errors.process(Errors.java:229)
The version of Apache Tika currently used in the latest release has 2 known vulnerabilities: CVE-2022-25169 and CVE-2022-30126. The second one seems to be critical for the use-case in the project. Both issues are fixed in version 2.4.0.
If my assumption is correct, could we have a security fix release?
What is the UPPER_CAMEL_CASE error in this context?
Caused by: java.lang.NoSuchFieldError: UPPER_CAMEL_CASE
at com.wildbit.java.postmark.client.data.DataHandler.<init>(DataHandler.java:20)
at com.wildbit.java.postmark.client.data.DataHandler.<init>(DataHandler.java:25)
at com.wildbit.java.postmark.client.HttpClientHandler.<init>(HttpClientHandler.java:22)
at com.wildbit.java.postmark.client.BaseApiClient.<init>(BaseApiClient.java:18)
at com.wildbit.java.postmark.client.ApiClient.<init>(ApiClient.java:43)
at com.wildbit.java.postmark.Postmark.getApiClient(Postmark.java:62)
I already have the dependencies:
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jdk8</artifactId>
<version>2.10.0</version>
</dependency>
<dependency>
<groupId>com.wildbit.java</groupId>
<artifactId>postmark</artifactId>
<version>1.2.1</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
I checked and found that the issue is related to jackson-datatype however adding it does not exactly fix the error.
It would be useful if the object mapper used to serialize the template parameters was customizable.
For example, the built-in object mapper uses PropertyNamingStrategy.UPPER_CAMEL_CASE
while we prefer LOWER_CAMEL_CASE
Also, we're using Kotlin so registering the kotlin module would be very useful
Hi all,
A few months ago I changed the API to TLS
and with that I refactored the code to use the version 1.5.6.
Everything was working fine with the (simplified) code below:
ApiClient client = PMApiClient.getApiClient();
String htmlBody = "<p>Hello world</a></p>";
Message message = new Message("<from email>", <to email>", "Hello from Postmark!", htmlBody);
message.addHeader("Powered by", "Bookmemate");
...
For a month (or even longer) all emails lost their formatting and all my clients received something like that
Powered by:Bookmemate
Feedback-ID: s1867426-_:s1867426:a109200:postmark
X-Complaints-To: [email protected]
X-Job: 109200_1867426
X-PM-Message-Id: 07c82a3b-73e6-4373-9eba-a678fcec16d7
X-PM-RCPT: |bTF8MTA5MjAwfDE4Njc0MjZ8dGhvbWFzQGJvb2ttZW1hdGUuY29t|
X-PM-Message-Options: v1;9Hcc_PIAriBnYBOfaIwCcyIPcaJJ4QcTBG0Vjf0upsKfpR9qOJtFHrXwPywaBTAW0yivONdmCE8g_Gy1UcqUBBDOwW7mU_BYoMQKRhXnXR0
MIME-Version: 1.0
X-virtual-MTA: ord-104-245-209-198
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<p style=3D"font-family:Helvetica,Arial,sans-serif"><span style=3D"col=
or:#000">Dear Thomas Dittmar,</span></p><p style=3D"font-family:Helvet=
ica,Arial,sans-serif"><span style=3D"color:#000">Please find attached =
your Invoice.</span></p><p style=3D"font-family:Helvetica,Arial,sans-s=
erif"><span style=3D"color:#000">Sincerely,</span><br><span style=3D"c=
olor:#000">Smith Haircutters</span><br><span style=3D"color:#000">john=
@smith.com</span></p><img src=3D"https://ea.pstmrk.it/open/v3_ytvfB5yr=
Mc05cc23gp9WhZ-ZvRAqmnFzqi-eLw67F9KW9nQ7IqDFOFc4-6G25dmnjBWPFhCkbjZ7Z1=
XE8TiYC9adTorfeR3Oyh0LwuVeLxKymFDHGC4iU1ahz6nnnicM9nUQz6Z3lwTvPaPsZati=
oh9UZe55Rx8idp9YrymsVIBkmNMsEgXitD7djPI66Sv9ZbBq79X5XdPLfcAkPAOquargTr=
nr-0OaDhIcaa_zBTOXC5AHRZwY3cCJRDi7b626QRUjiDuUcvpoB95iQxo1GaP5cpeCwFze=
D_AWjgH2hMUmMNt6ziDVq7oQozcZ0aZ3wd7VFr_MW9h6fhIZXQRnjvVs81KqpFLVMctp_b=
4--SB_4cHb3vgLjulbtFpiHuuD0YSa7lia3W89oPhVv55cz5bXMk3hPXBVpBI1oxdL-SvJ=
sT962ztgAV85sW_z889Z" width=3D"1" height=3D"1" border=3D"0" alt=3D"" /=
>
It turns out that this line message.addHeader("Powered by", "Bookmemate");
caused that problem.
Because all emails were successfully sent I never received an error on my end and hence, nobody, apart from the end users that received the garbage, saw any issues.
This is unacceptable. If you change the API that drastically, please inform the users that pay for this service or at least raise an error so that it can be fixed.
The other thing is, why is this API not backwards compatible? Meaning, the old code and the new code should work in parallel.
Best regards,
Thomas
Director of Bookmemate
When sending mail or parsing webhook I get the following exception:-
The nano seconds in the timestamp are causing an issue.
com.fasterxml.jackson.databind.exc.InvalidFormatException: Can not construct instance of java.util.Date from String value ("2018-03-14T19:11:00.5478435-04:00"): not a valid representation (error: Failed to parse Date value '2018-03-14T19:11:00.5478435-04:00': Can not parse date "2018-03-14T19:11:00.5478435-0400": while it seems to fit format 'yyyy-MM-dd'T'HH:mm:ss.SSSZ', parsing fails (leniency? null))
Vulnerability scanners report Apache Tika 2.4 as vulnerable, can you upgrade?
https://www.cve.org/CVERecord?id=CVE-2022-33879
This mean that creating attachments on the fly hard for nothing (IMHO).
Using version 1.2.0 with Jackson 2.9.8 I was unable to decode an inbound webhook received from Postmark due to the date format that was used.
The webhook contained the following;
"Date": "26 May 2019 10:39:51 -0400",
which resulted in the following error;
com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot parse date "26 May 2019 10:39:51 -0400": not compatible with any of standard forms ("yyyy-MM-dd'T'HH:mm:ss.SSSZ", "yyyy-MM-dd'T'HH:mm:ss.SSS", "EEE, dd MMM yyyy HH:mm:ss zzz", "yyyy-MM-dd"))
Could this format be added as an alias?
One specific example:
public String retryFailedInboundMessage(String id) throws PostmarkException, IOException {
String response = execute(HttpClient.REQUEST_TYPES.PUT, getEndpointUrl(inboundMessagesEndpoint + id + "/retry"));
return dataHandler.fromJson(response, String.class);
}
Calling this method with a valid / retriable message ID results in a Jackson exception because response
is now a JSON-encoded Object, not just a String value. It seems sane to keep the return type as String
, by decoding the JSON response to BaseMessageResponse.class
and returning the String value.
bypassInboundMessage()
also should be updated -- and some of the other methods that return a generic HashMap seem like also using the BaseMessageResponse there might be a better choice (since they're also getting the Integer ErrorCode, String Message response) -- in which case returning BaseMessageResponse
rather than BaseMessageResponse.getMessage()
might be best.
I've added a PR, #21, in case that's of any help.
When using postmark's lib with java version greater than 8 there's a warning about illegal access caused by the jaxb dependency.
See here - javaee/jaxb-v2#1197
Upgrading from version 2.3.0 to 2.3.1 should resolve that issue.
Btw, does postmark use jaxb at all? I excluded it from my dependencies and everything seems to work fine
Your latest release introduces the org.slf4j:slf4j-simple
dependency. I guess this is breaking the usage for majority of the users, due to the slf4j multiple-bindings. For example, all SpringBoot users would not be able to start the app:
Exception in thread "main" java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.slf4j.impl.SimpleLoggerFactory loaded from file:/home/ise/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-simple/1.7.36/a41f9cfe6faafb2eb83a1c7dd2d0dfd844e2a936/slf4j-simple-1.7.36.jar). If you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml: org.slf4j.impl.SimpleLoggerFactory
You should only depend on the slf4j api and do not introduce the implementation.
Workaround:
// postmark
implementation("com.wildbit.java:postmark:1.8.+") {
exclude group: 'org.slf4j', module: 'slf4j-simple'
}
When setTrackLinks
Message.TRACK_LINKS enum has 'text', 'Html' and 'HtmlAndText'
Postmark exception:
The value for 'TrackLinks' is not valid. Valid options are: null, 'None', 'HtmlAndText', 'HtmlOnly', 'TextOnly'
Hello,
We have an app that is utilizing this app to make an api call to get message details from the postmark email that is giving us an SSLException: Connection Reset. Upon doing more digging it looks like there is a potential we are using all of our "Pools" and it is causing these api calls to fail.
This is a article on stack I found that seems to be relevant to this issue.
Here is the link provided in the answer from Jude Niroshan, https://howtodoinjava.com/spring-boot2/resttemplate/resttemplate-httpclient-java-config/
Here is a stack trace for what we are seeing on our end up until we blow up in our application.
Exception:
javax.net.ssl.SSLException
Message:
Connection reset
Stacktrace:
sun.security.ssl.Alert.createSSLException(Alert.java:127)
sun.security.ssl.TransportContext.fatal(TransportContext.java:331)
sun.security.ssl.TransportContext.fatal(TransportContext.java:274)
sun.security.ssl.TransportContext.fatal(TransportContext.java:269)
sun.security.ssl.SSLTransport.decode(SSLTransport.java:138)
sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1401)
sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1309)
sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:440)
org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory.executeHandshake(SSLConnectionSocketFactory.java:303)
org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:275)
org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:251)
org.apache.hc.client5.http.impl.io.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:181)
org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:447)
org.apache.hc.client5.http.impl.classic.InternalExecRuntime.connectEndpoint(InternalExecRuntime.java:162)
org.apache.hc.client5.http.impl.classic.InternalExecRuntime.connectEndpoint(InternalExecRuntime.java:172)
org.apache.hc.client5.http.impl.classic.ConnectExec.execute(ConnectExec.java:142)
org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
org.apache.hc.client5.http.impl.classic.ProtocolExec.execute(ProtocolExec.java:192)
org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
org.apache.hc.client5.http.impl.classic.HttpRequestRetryExec.execute(HttpRequestRetryExec.java:96)
org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
org.apache.hc.client5.http.impl.classic.ContentCompressionExec.execute(ContentCompressionExec.java:152)
org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
org.apache.hc.client5.http.impl.classic.RedirectExec.execute(RedirectExec.java:115)
org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
org.apache.hc.client5.http.impl.classic.InternalHttpClient.doExecute(InternalHttpClient.java:170)
org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:245)
org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:188)
org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:162)
com.postmarkapp.postmark.client.HttpClient.execute(HttpClient.java:90)
com.postmarkapp.postmark.client.HttpClientHandler.execute(HttpClientHandler.java:61)
com.postmarkapp.postmark.client.HttpClientHandler.execute(HttpClientHandler.java:44)
com.postmarkapp.postmark.client.ApiClient.getTemplate(ApiClient.java:114)
Any help is much appreciated! I look forward to working with y'all to help debug this.
Allan
Hi
I'm having an issue after adding postmark to my app. I'm using the Play Framework v.2.6.x (which uses Logback for logging by default).
After I added postmark to my app, I started getting lots of log information from several libraries that are used in the app (debug info mostly). I if remove postmark, the problem goes way.
I've been able to silence the log, by adding my own log4.properties to override the one that comes in postmark. But I don't use log4j directly, so that file is only there to silence what postmark brings.
Is this really necessary? or is there a way around it?
Thanks
I can't find any documentation specifying whether we can use a single ApiClient instance, or if we need a separate ApiClient for each thread.
Bounce.java is the only class containing the getMessageID naming inconsistency.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.