Exception while using JavaMail with Google AppEngine: How to fix this? - java

I am trying to write a Java program using JavaMail to send an email between 2 users. I have NOT added mail.jar and activation.jar files to my appengine project as I read somewhere that this would cause exceptions to be thrown since the functionality is already available with the appengine .jar files. But my program is throwing the following exception:-
Exception in thread "main" com.google.apphosting.api.ApiProxy$CallNotFoundException: The API package 'mail' or call 'Send()' was not found.
- Hide quoted text -
at com.google.apphosting.api.ApiProxy.makeSyncCall(ApiProxy.java:95)
at com.google.apphosting.api.ApiProxy.makeSyncCall(ApiProxy.java:48)
at com.google.appengine.api.mail.MailServiceImpl.doSend(MailServiceImpl.java:95)
at com.google.appengine.api.mail.MailServiceImpl.send(MailServiceImpl.java:32)
at com.google.appengine.api.mail.stdimpl.GMTransport.sendMessage(GMTransport.java:247)
at javax.mail.Transport.send(Transport.java:95)
at javax.mail.Transport.send(Transport.java:48)
at weatherForecast.SendEmail.main(SendEmail.java:40)
I read in the following post: http://forums.smartclient.com/showthread.php?t=8589 that I need to remove appengine .jar files from my project to make things work. But my web application also involves rendering a .jsp file populated with some data which is the welcoming page of my Google App when deployed on google appengine and the project fails to work once I remove the .jars. It does help me in getting rid of the exception though. Can anyone please suggest a way to write an email program and make it work on a google appengine project?

It is likely you are still somehow accidentally including a .jar file that shouldn't be included.
Right click on your project folder and check:
Properties -> java build path
Properties -> Java EE Module dependencies
And also make sure you the jar is not in /war/WEB-INF/lib/, jars that should not be uploaded to google should be stored in a separate location of your project, i recommend /lib/.

If you use Flexible, this is because Google does not support Mail service in the flex environment. Java Mail with the built-in Mail service in GAE are seemed to be designed to work only in the standard Java framework on this Migration tips.. In flexible, three third party's mail API are introduced to be used instead. You may use GMail API for another option.

Related

Google Cloud Tools for Eclipse ClassNotFoundException for GcsFilename

I am trying to run Google's standard App Engine locally within Eclipse. I need to save a file to Cloud Storage. One of the classes I am using is GcsFilename. I am getting a "java.lang.ClassNotFoundException: com.google.appengine.tools.cloudstorage.GcsFilename" exception when I run my application.
I had to add the jar appengine-gcs-client-08.jar to my build path to get the code to compile. When it runs I get the exception mentioned above. Currently the project also includes the following libraries: BigQuery API, BigQuery Data Transfer API, and Cloud Storage. It also has these external jars: axis-1.4.jar, commons-discovery-05.jar, jasxrpc-api-1.1.jar, and wsdl5j-1.6.3.jar
What am I doing wrong?
I was wrong in my original answer here: the com.google.appengine.tools is ok and indeed there is a tutorial using the approach you describe. That tutorial describes the dependencies required when using Maven or Gradle.
You can also use Cloud Tools for Eclipse's Libraries management feature to install the Cloud Storage client libraries into your app, but that uses a different set of classes.

Loading an external class folder in eclipse - java

I am trying to use the LPsolver on a project I am working on. (it contains both jar and DLLs).
When I ran it locally it worked (System.loadLibrary("lpsolver"))
But now I am trying to upload it to an amazon server which is running tomcat.
I can't get the tomcat server to load class library correctly.
Tried to include it in all kind of different locations and loading it but non seemed to work.
Any idea how I can accomplish it ?
Thanks!
EDIT:
Tried lots of stuff I found on the web, mainly ways to include the class library I need inside the project and not a reference through the local vars.but my project does not seem to recognize it. Also wanted to upload it to my amazon web server ( to system32) but I guess because I use the free version that option is not included...

How can I use JavaMail API without the user having to install it?

I want to use JavaMail API and the JavaBeans Activation Framework to send emails in my program, but in order for it to function, JavaMail and JAF need to be installed on the system. I want to be able to run this program on any computer without having to install extra things to make it work. Is there any way to put the JavaMail and JAF jars in the program jar to make it run correctly without any previous installation?
Today you're in luck. The answer is yes. All you need is to copy the required jars to your project. You need to add mail.jar and activation.jar files in your CLASSPATH. Mkyong have a complete example in JavaMail API – Sending email via Gmail SMTP example.
The required libraries also can download http://search.maven.org/
In another hand, if you need a dummy mail server for test, you can use Papercute from Codeplex. Unzip and run.
If you want the user to download a single jar file that contains everything and just run that jar file, see One-JAR.

Deploying war file in google app engine by creating a java class using the jar specific to deploy it

i have searched for various solutions in need of creating a simple java class with a deploy method. This deploy method should get the path of the war file and deploy it in app engine google account. i tried to get the jars of it and use these methods.. but i didnt had any details for help even after searching. so any good suggestions? on how to deploy it directly in google app engine
You mean programmatically deploy to GAE?
Sure, it's possible. Take a look at AppCfg source and extract classes relevant to deploy.

Build a JS server inside of Java for Google AppEngine

I just needed to create a little interface for a project. So I decided to take given code and to run it on Google AppEngine. My problem is, that I'm experienced in JavaScript and got some basic knowledge of Java, but I got no clue how a Java webapp has to be structured. I started Eclipse and installed the AppEngine-addon, downloaded Rhino and env.js (which is necessary for the bunch of code I need to run) but then found me in the situation of sitting on this files not knowing where to put them.
It would be great if someone could tell me in which directory to put which files for Rhino (I assume it's "/war/WEB-INF/lib/"), how to add the env.js-file and how to access all these files inside the .java-file which is the index of the app.
I don't know about app engine in particular, but I have had good success using Rhino jsc to compile script files which extend the Servlet API. The end result is a nice WAR file which you can deploy in any servlet container, and perhaps App Engine as well. See here for my relevant blog post about this technique, and here for a sample Eclipse project.
Have you taken a look at this tutorial on running Rhino on GAE?
It's a link from the official "Will it play in App Engine?" thread.
http://www.appenginejs.org/ may be of interest as well.

Categories

Resources