Using MailGun on AppEngine Java - java

I'm trying to get the libraries needed to send mail on AppEngine.
The docs (https://cloud.google.com/appengine/docs/standard/java/mail/mailgun) state that these need to be added if using Maven:
jersey-core
1.19.4
jersey-client
1.19.4
jersey-multipart
1.19.4
Adding them however, results in an error message in Eclipse.
The type javax.ws.rs.ext.RuntimeDelegate$HeaderDelegate cannot be
resolved. It is indirectly referenced from required .class files
That can be resolved by adding javax.ws.rs-api-2.0.1, but using that jar seems problematic.
Appengine is throwing an error:
Caused by: java.lang.ExceptionInInitializerError
... 44 more
Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: org.glassfish.jersey.internal.RuntimeDelegateImpl
at com.sun.jersey.core.header.MediaTypes.<clinit>(MediaTypes.java:65)
... 62 more
Caused by: java.lang.ClassNotFoundException: org.glassfish.jersey.internal.RuntimeDelegateImpl
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at com.google.apphosting.runtime.ApplicationClassLoader.findClass(ApplicationClassLoader.java:45)
In a thread here though that error org.glassfish.jersey.internal.RuntimeDelegateImpl NOT FOUND is said to be solvable by removing javax.ws.rs-api-2.0
Other suggestions include using jersey2, but that requires additional configuration I believe and the AppEngine docs don't show how to do that.
How can I send mail on Appengine using Mailgun???

I solved it by using Jersey 2.27 (JAX-RS 2.1 / Jersey 2.26+) available as a download from https://jersey.github.io/download.html
I needed the following jars:
hk2-api-2.5.0-b32.jar
hk2-locator-2.5.0-b42.jar
hk2-utils-2.5.0-b32.jar
javax.inject-1.jar
javax.inject-2.5.0-b42.jar
jersey-client.jar
jersey-common.jar
jersey-guava-2.26-b03.jar (from Jersey 2.25.1)
jersey-media-jaxb.jar
javax.ws.rs-api-2.1.jar
And modified the AppEngine sample to use Jersey 2.26+ as below:
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Form;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
public static void sendSimpleMessage(String recipient) {
Client clientMail = ClientBuilder.newBuilder().build();
clientMail.register(HttpAuthenticationFeature.basic("api", MAILGUN_API_KEY));
WebTarget targetMail = clientMail.target("https://api.mailgun.net/v3/" + MAILGUN_DOMAIN_NAME + "/messages");
Form formData = new Form();
formData.param("from", "Mailgun Sandbox <"+DOMAIN_MAIL_ADDRESS+">");
formData.param("to", recipient);
formData.param("subject", "Simple Mailgun Example");
formData.param("text", "Plaintext content");
Response response = targetMail.request().post(Entity.entity(formData, MediaType.APPLICATION_FORM_URLENCODED_TYPE));
System.out.println("Mail sent : " + response);
}
The MAILGUN_API_KEY is available from MailGun. MAILGUN_DOMAIN_NAME is my custom domain and DOMAIN_MAIL_ADDRESS is the address I wish to send from.
Note: I have guava-gwt and gauva on my classpath too, so perhaps it was the addition of jersey-guava that did the trick. Actually, jersey-gauva was only in jaxrs-ri-2.25.1 and not in jaxrs-ri-2.27 (JAX-RS 2.1 / Jersey 2.26+). It was definitely needed though.

Related

Embeded Tomcat version 9 Not Working to create container for API

I am trying to run tomcat container using dependency 'tomcat-embed-core', version: '9.0.65'.
While using this the I am not able to start container, If I move to version 8.5.41 or any version of tomcat-embeded-core 8.*, it is working fine. I am using CFXServlet for servlet. Below is code example.
Package imported:
import java.io.File;
import org.apache.catalina.Context;
import org.apache.catalina.startup.Tomcat;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.apache.tomcat.util.descriptor.web.FilterDef;
import org.apache.tomcat.util.descriptor.web.FilterMap;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.filter.DelegatingFilterProxy;
Code snippet I used :
Tomcat tServer = new Tomcat();
tServer.setHostname('127.0.0.1');
tServer.setPort(4434);
tServer.getHost().setAppBase(".");
Context ctx = tServer.addContext("/", new File(".").getAbsolutePath());
tServer.addServlet( ctx, CXFServlet.class.getSimpleName(), CXFServlet.class.getName() );
tServer.getHost().setAutoDeploy(true);
tServer.getHost().setDeployOnStartup(true);
ctx.addServletMappingDecoded("/test/*", CXFServlet.class.getSimpleName());
ctx.addApplicationListener(ContextLoaderListener.class.getName());
ctx.addParameter("contextClass",AnnotationConfigWebApplicationContext.class.getName());
ctx.addParameter("contextConfigLocation", RestConfig.class.getName());
Class filterClass = DelegatingFilterProxy.class;
FilterDef myFilterDef = new FilterDef();
myFilterDef.setFilterClass(filterClass.getName());
myFilterDef.setFilterName("springSecurityFilterChain");
ctx.addFilterDef(myFilterDef);
FilterMap myFilterMap = new FilterMap();
myFilterMap.setFilterName("springSecurityFilterChain");
myFilterMap.addURLPattern("/*");
ctx.addFilterMap(myFilterMap);
tServer.start();
tServer.getServer().await();
In build.gradle I have added below dependancy,
// https://mvnrepository.com/artifact/org.apache.tomcat.embed/tomcat-embed-core implementation group: 'org.apache.tomcat.embed', name: 'tomcat-embed-core', version: '9.0.60'
using above dependacy not able to connect http://127.0.0.1:4434/test
If I move to version 8.5.82 its working fine.
I have requirement to use tomcat 9 compatibility, So anyone help me on this.
Didn't found any error log in app.
Tomcat 9 is not adding a Connector automatically to your server , so you'll have to trigger it yourself using :
tServer.getConnector();
This will add the default connector to server and server start responding
So code should be like
Tomcat tServer = new Tomcat();
tServer.setHostname('127.0.0.1');
tServer.setPort(4434);
tServer.getConnector();

Jersey Client Error - Unable to Parse Invalid Content-Type Header (need workaround)

I'm using Jersey Client 2.29 I believe.
When handling a request the server responds with Content-Type = application/ (of course that is a bogus value it is supposed to be application/json). jersey blows up because it can't parse the subtype of the media type:
java.util.concurrent.CompletionException: org.glassfish.jersey.message.internal.HeaderValueException: Unable to parse "Content-Type" header value: "application/"
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$AsyncSupply.run(CompletableFuture.java:1702)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.glassfish.jersey.message.internal.HeaderValueException: Unable to parse "Content-Type" header value: "application/"
at org.glassfish.jersey.message.internal.InboundMessageContext.exception(InboundMessageContext.java:314)
at org.glassfish.jersey.message.internal.InboundMessageContext.singleHeader(InboundMessageContext.java:309)
at org.glassfish.jersey.message.internal.InboundMessageContext.getMediaType(InboundMessageContext.java:422)
at com.test.web.ext.filter.LoggingFilter.filter(LoggingFilter.java:94)
at org.glassfish.jersey.client.ClientFilteringStages$ResponseFilterStage.apply(ClientFilteringStages.java:109)
at org.glassfish.jersey.client.ClientFilteringStages$ResponseFilterStage.apply(ClientFilteringStages.java:97)
at org.glassfish.jersey.process.internal.Stages.process(Stages.java:147)
at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:259)
at org.glassfish.jersey.client.JerseyInvocation.lambda$invoke$1(JerseyInvocation.java:743)
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.invoke(JerseyInvocation.java:741)
at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:432)
at org.glassfish.jersey.client.JerseyCompletionStageRxInvoker.lambda$method$1(JerseyCompletionStageRxInvoker.java:46)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
... 3 more
Caused by: javax.ws.rs.ProcessingException: java.lang.IllegalArgumentException: Error parsing media type 'application/'
at org.glassfish.jersey.message.internal.InboundMessageContext$5.apply(InboundMessageContext.java:428)
at org.glassfish.jersey.message.internal.InboundMessageContext$5.apply(InboundMessageContext.java:422)
at org.glassfish.jersey.message.internal.InboundMessageContext.singleHeader(InboundMessageContext.java:307)
... 18 more
Caused by: java.lang.IllegalArgumentException: Error parsing media type 'application/'
at org.glassfish.jersey.message.internal.MediaTypeProvider.fromString(MediaTypeProvider.java:69)
at org.glassfish.jersey.message.internal.MediaTypeProvider.fromString(MediaTypeProvider.java:37)
at javax.ws.rs.core.MediaType.valueOf(MediaType.java:196)
at org.glassfish.jersey.message.internal.InboundMessageContext$5.apply(InboundMessageContext.java:426)
... 20 more
Caused by: java.text.ParseException: End of header.
at org.glassfish.jersey.message.internal.HttpHeaderReaderImpl.getNextCharacter(HttpHeaderReaderImpl.java:155)
at org.glassfish.jersey.message.internal.HttpHeaderReaderImpl.next(HttpHeaderReaderImpl.java:116)
at org.glassfish.jersey.message.internal.HttpHeaderReaderImpl.next(HttpHeaderReaderImpl.java:111)
at org.glassfish.jersey.message.internal.HttpHeaderReader.nextToken(HttpHeaderReader.java:104)
at org.glassfish.jersey.message.internal.MediaTypeProvider.valueOf(MediaTypeProvider.java:90)
at org.glassfish.jersey.message.internal.MediaTypeProvider.fromString(MediaTypeProvider.java:67)
... 23 more
github-MediaTypeProvider
I have no control of this 3rd party server and I have to be able to process this request.
Is there anyway around this?
Some property, setting, registering a custom media type provider, anything?
P.S.
I have successfully used ByteBuddy to redefine this method at runtime and handle the error with some extra special sauce but that is a major hack... I'd love a better option if it exists.
Client Configuration
final Client client = ClientBuilder.newBuilder()
.property(ClientProperties.REQUEST_ENTITY_PROCESSING, RequestEntityProcessing.CHUNKED)
.property(ClientProperties.FOLLOW_REDIRECTS, false)
.sslContext(tls)
.hostnameVerifier(new NoOpHostnameVerifier())
.register(new CookiePersistFilter(NARRATIVE)) // #Priority(HEADER_DECORATOR)
.register(new LoggingFilter(NARRATIVE)) // #Priority(USER)
.register(MyFilter.class) // #Priority(50000)
.register(JsonReader.class)
.register(JsonWriter.class)
.register(HTMLReader.class)
.register(MultiPartFeature.class)
.build();
Filters are executed in this order:
MyFilter
LoggingFilter
CookiePersistFilter
As Paul Samsotha pointed out, I can fix this with a ClientResponseFilter using high priority. Here is one way one could do it.
import javax.annotation.Priority;
import javax.ws.rs.client.ClientRequestContext;
import javax.ws.rs.client.ClientResponseContext;
import javax.ws.rs.client.ClientResponseFilter;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.ext.Provider;
import com.selinc.winchester.common.narrative.INarrative;
import com.selinc.winchester.sentinel.Sentinel;
import com.selinc.winchester.wrestler.ResponsePriorities;
#Provider
#Priority(25000) // Note the priority ordering is reverse of ClientRequestFilter
public final class ResponseHeaderWorkaroundFilter implements ClientResponseFilter
{
#Override
public void filter(final ClientRequestContext requestContext, final ClientResponseContext responseContext)
{
try
{
// Attempt to read the Content-Type header.
responseContext.getMediaType();
}
catch (Throwable error)
{
// On error, set the Content-Type header to some default value.
responseContext.getHeaders()
.putSingle(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
}
}
}

Error when using jar but not in the library itself

I built a Java library to send message in IBM MQ.
It is working fine when I execute the code on the library project.
However, when I use the .jar into another tool (JMeter), an error occurs.
java.lang.NoSuchMethodError: com.ibm.mq.jmqi.JmqiFactory.getInstance(Lcom/ibm/mq/jmqi/JmqiThreadPoolFactory;Lcom/ibm/mq/jmqi/JmqiPropertyHandler;)Lcom/ibm/mq/jmqi/JmqiEnvironment;
at com.ibm.msg.client.mqlight.MQLightComponent.getImplementationInfo(MQLightComponent.java:220) ~[mq-jms-8.0.0.3.jar:8.0.0.3 - p800-003-150615.2]
at com.ibm.msg.client.commonservices.trace.Trace.getVersion(Trace.java:1692) ~[mq-jms-7.0.1.3.jar:?]
at com.ibm.msg.client.commonservices.trace.Trace.createFFSTString(Trace.java:1650) ~[mq-jms-7.0.1.3.jar:?]
at com.ibm.msg.client.commonservices.trace.Trace.ffstInternal(Trace.java:1536) ~[mq-jms-7.0.1.3.jar:?]
at com.ibm.msg.client.commonservices.trace.Trace.ffst(Trace.java:1444) ~[mq-jms-7.0.1.3.jar:?]
at com.ibm.msg.client.jms.JmsFactoryFactory.getInstance(JmsFactoryFactory.java:209) ~[mq-jms-7.0.1.3.jar:7.0.1.3 - k701-103-100812]
at com.ibm.mq.jms.MQConnectionFactory.initialiseMQConnectionFactory(MQConnectionFactory.java:3325) ~[mq-jms-7.0.1.3.jar:7.0.1.3 - k701-103-100812]
at com.ibm.mq.jms.MQConnectionFactory.<init>(MQConnectionFactory.java:274) ~[mq-jms-7.0.1.3.jar:7.0.1.3 - k701-103-100812]
at my.package.MQ_Manager.createConnection(MQ_Manager.java:36) ~[my-jar.jar:?]
at my.package.MQ_Manager.<init>(MQ_Manager.java:27) ~[my-jar.jar:?]
at my.package.Producer.<init>(Producer.java:18) ~[my-jar.jar:?]
at my.package.Request.sendRequest(Request.java:116) ~[my-jar.jar:?]
at my.package.Request$sendRequest$2.call(Unknown Source) ~[?:?]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47) ~[groovy-all-2.4.16.jar:2.4.16]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) ~[groovy-all-2.4.16.jar:2.4.16]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120) ~[groovy-all-2.4.16.jar:2.4.16]
at Script1.run(Script1.groovy:14) ~[?:?]
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:321) ~[groovy-all-2.4.16.jar:2.4.16]
at org.codehaus.groovy.jsr223.GroovyCompiledScript.eval(GroovyCompiledScript.java:72) ~[groovy-all-2.4.16.jar:2.4.16]
at javax.script.CompiledScript.eval(Unknown Source) ~[?:1.8.0_31]
at org.apache.jmeter.util.JSR223TestElement.processFileOrScript(JSR223TestElement.java:223) ~[ApacheJMeter_core.jar:5.1 r1853635]
at org.apache.jmeter.protocol.java.sampler.JSR223Sampler.sample(JSR223Sampler.java:71) ~[ApacheJMeter_java.jar:5.1 r1853635]
at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:622) ~[ApacheJMeter_core.jar:5.1 r1853635]
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:546) ~[ApacheJMeter_core.jar:5.1 r1853635]
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:486) ~[ApacheJMeter_core.jar:5.1 r1853635]
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:253) ~[ApacheJMeter_core.jar:5.1 r1853635]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_31]
Corresponding code:
MQConnectionFactory factory = new MQConnectionFactory();
factory.setHostName(properties.getProperty("HOST"));
factory.setPort(Integer.parseInt(properties.getProperty("PORT")));
factory.setChannel(properties.getProperty("CHANNEL"));
factory.setTransportType(WMQConstants.WMQ_CM_CLIENT);
factory.setQueueManager(properties.getProperty("QUEUE_MANAGER"));
factory.setAppName(properties.getProperty("APP_NAME"));
Connection connection = factory.createConnection(properties.getProperty("APP_USER"), properties.getProperty("APP_PASSWORD"));
connection.start();
return connection;
Error occurs at this line MQConnectionFactory factory = new MQConnectionFactory();
Any idea? Thank you.
Update 1
To create the .jar I :
Clicked on Export
Selected Runnable JAR file
Selected Extract required libraries into generated JAR
Update 2
Moreover when I built the Jar, I get this warning. Do you think that is important?
This operation repacks references libraries. Please review the licences associated with libraries you wish ti reference to make sure you are able to repack them using this application. Note also that this operation does not copy signature files from orignal libraies to the generated JAR file.
After disccussing the issue with the OP I went ahead a verified the issue myself.
The result is that its working for me ...
Step 1:
Created a maven project with included the following code
package test;
import javax.jms.JMSException;
import com.ibm.mq.jms.MQConnectionFactory;
public class JmeterTest {
public JmeterTest() {
}
public void test() throws JMSException {
MQConnectionFactory factory = new MQConnectionFactory();
factory.setAppName("myApp");
}
public static void main(String[] args) {
System.out.println("test");
}
}
Step 2:
Exported this from eclipse as runnable jar and copied into JMeter (\lib\ext\).
Note that a export with library handling package required jars into generated jar does not work. Use Extract into generated jar or Copy into subfolder (and then copy the jars from the subfolder into \lib\ext as well).
related dependecies are:
com.ibm.mq.allclient-9.0.4.0.jar
bcokix-jdk15on-1.57.jar
bcprov-jdk15on-1.57.jar
javax.jms-api-2.0.1.jar
Step 3:
Started JMeter and created a ThreadGroup with a JSR223 Sampler.
import test.JmeterTest;
new JmeterTest().test();
Then started the test. No error occurred.
Step 4:
Instead of exporting a library, you could directly (after adding the dependencies) add the required code into the script panel:
import javax.jms.JMSException;
import com.ibm.mq.jms.MQConnectionFactory;
MQConnectionFactory factory = new MQConnectionFactory();
factory.setAppName("myApp");
Worked as well
Conclusion: Interference from other dependencies on the jmeter classpath are the likeliest cause of the issue.

Apache POI cannot create XMLSlideShow object

I am using an old version of Apache POI (3.8) on my Domino server. I want to create some presentation files so I started with a basic sample code:
package org.quintessens.poi;
import java.io.IOException;
import org.apache.poi.xslf.usermodel.XMLSlideShow;
import org.apache.poi.xslf.usermodel.XSLFSlideLayout;
import org.apache.poi.xslf.usermodel.XSLFSlideMaster;
public class Presentation {
public void createXSLF() throws IOException{
System.out.println("createXSLF()");
//create an empty presentation
XMLSlideShow ppt = new XMLSlideShow();
System.out.println("Available slide layouts:");
//getting the list of all slide masters
for(XSLFSlideMaster master : ppt.getSlideMasters()){
//getting the list of the layouts in each slide master
for(XSLFSlideLayout layout : master.getSlideLayouts()){
//getting the list of available slides
System.out.println(layout.getType());
}
}
}
}
I have registered the class as a managed bean as followed:
<?xml version="1.0" encoding="UTF-8"?>
<faces-config>
<managed-bean>
<managed-bean-name>Prez</managed-bean-name>
<managed-bean-class>org.quintessens.poi.Presentation</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
</faces-config>
I added a button on my XPage to call it:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:button value="XSLF" id="button1">
<xp:eventHandler event="onclick" submit="true" refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:Prez.createXSLF()}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
</xp:view>
When I run the code I get an error 500 message.
If I check my log I read:
2016-09-21 20:50:27 HTTP JVM: createXSLF() 2016-09-21 20:50:27
HTTP JVM: CLFAD0211E: Exception thrown. For more detailed information,
please consult error-log-0.xml located in C:/Program
Files/IBM/Domino/data/domino/workspace/logs 2016-09-21 20:50:27 HTTP
JVM: CLFAD0246E: Exception occurred servicing request for:
/apps/quintessens/ApachePO.nsf/test.xsp - HTTP Code: 500. For more
detailed information, please consult error-log-0.xml located in
C:/Program Files/IBM/Domino/data/domino/workspace/logs
Sadly, the error log does not tell me much:
2016-09-21T20:50:26.872+02:00 ALLVARLIG CLFAD0211E: Exception thrown
2016-09-21T20:50:26.875+02:00 ALLVARLIG CLFAD0246E: Exception occurred
servicing request for: /apps/quintessens/ApachePO.nsf/test.xsp - HTTP
Code: 500
I tried to use the HSLF usermodel which goes well but which I do not want to use.
What should I do?

Can't send SMS; getting 500 error in Java/Scala Google Voice API

I've got this code:
val voice = new Voice("<un>", "<pw>")
voice.login()
// The ID isn't specced well in the source code, not sure what it needs to be
voice.sendSMS("<number>", "hello", "343434")
I'm getting this error thrown in the browser (Play 2.0):
Server returned HTTP response code: 500 for URL: https://www.google.com/voice/b/0/sms/send/]
The stacktrace is:
[info] play - Application started (Dev)
[info] application - index:
https://www.google.com/accounts/ClientLogin - OK
Logged in to Google - Auth token received
https://www.google.com/voice/b/0/settings/tab/phones - OK
https://www.google.com/voice/b/0 - OK
Successfully Received rnr_se.
smsdata: id=hello&phoneNumber=XXXXXXXX&conversationId=343434&text=hello&_rnr_se=XXXXXXXXXXXXXXX
[error] application -
! #6an08o8h8 - Internal server error, for request [GET /smsTest] ->
play.core.ActionInvoker$$anonfun$receive$1$$anon$1: Execution exception [[IOException: Server returned HTTP response code: 500 for URL: https://www.google.com/voice/b/0/sms/send/]]
at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:134) [play_2.9.1.jar:2.0.1]
at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:115) [play_2.9.1.jar:2.0.1]
at akka.actor.Actor$class.apply(Actor.scala:311) [akka-actor.jar:2.0.1]
at play.core.ActionInvoker.apply(Invoker.scala:113) [play_2.9.1.jar:2.0.1]
at akka.actor.ActorCell.invoke(ActorCell.scala:619) [akka-actor.jar:2.0.1]
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:196) [akka-actor.jar:2.0.1]
Caused by: java.io.IOException: Server returned HTTP response code: 500 for URL: https://www.google.com/voice/b/0/sms/send/
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1436) ~[na:1.6.0_31]
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:234) ~[na:1.6]
at com.techventus.server.voice.Voice.sendSMS(Voice.java:1669) ~[google-voice-java-1.14.jar:na]
at controllers.Application$$anonfun$smsTest$1.apply(Application.scala:47) ~[classes/:na]
at controllers.Application$$anonfun$smsTest$1.apply(Application.scala:45) ~[classes/:na]
at play.api.mvc.Action$$anon$1.apply(Action.scala:170) ~[play_2.9.1.jar:2.0.1]
[info] Compiling 1 Scala source to /Users/franklovecchio/Desktop/dev/applications-voip/target/scala-2.9.1/classes...
I'm using the latest jar.
Is there anybody that can send an SMS currently?
Try using JSON Spray which is built on top of Akka. you would need the following imports among many others:
import java.io._;
import java.net.InetAddress;
import java.util.Properties;
import java.util.Date;
import javax.mail._;
import javax.mail.internet._;
import javax.activation._;
import cc.spray.json._
Basically the pseudocode or algorithm is identical to what you would have for an implementation in Java, only you would be coding in Scala.
Twitter's finagle is a good backbone for your server requests and responses.

Categories