Google Cloud Tools for Eclipse ClassNotFoundException for GcsFilename - java

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.

Related

How to push a file to GitHub using an Android app (JAVA)

So i have a excel file on my GitHub that needs to be updated so i plan to update it using a application
How do I push the updated excel file to GitHub directly from the app using a button
(Java language)
Could someone point me in the right direction
Mostly when i search this question the results are about how to push the code to GitHub
If you are using Java you maybe use Gradle(Usually used with android) or Maven as your project builder tool. I just googled quicly "Java git library" for you and JGit came up wich seems to be a fairly simple library to use. Here is a tutotrial on it.
You probably have to initialize the repo as ususal from code or seperately I suggest from code. And you need to implement file handling as well seperatelly from this simple git client implmentation. You might use this other source helpful for that.
But on native android there might be some different library for handling files as well as you should look into intents for passing differernt files or data between applications.
I hope it helps. :)

What is my backend API name? Where is it? Calling Google Cloud endpoint backend API from Android Studio Client

I'd like to use google cloud endpoint v2 to connect to App Engine (and eventually google cloud sql (NOT firebase as I'll be making complex queries)) in my android studio (v3.3) project .
The google cloud SDK, OpenAPI, Endpoints configuration is working (it can receive an echo "hello world" through windows PowerShell) and I built the client libraries following this tutorial: https://cloud.google.com/endpoints/docs/frameworks/java/gen_clients
I've imported my client libraries into the Android Studio project file Libs and am currently following this tutorial to call backend APIs from Android Studio Client:
https://cloud.google.com/endpoints/docs/frameworks/java/calling-from-android
After editing gradle files, it suggests replacing "Tictactoe" in the code below with the name of your backend API
Tictactoe.Builder builder = new Tictactoe.Builder(
AndroidHttp.newCompatibleTransport(), new GsonFactory(), null);
service = builder.build();
I've spent 8 hours trying to figure what that would be. I can't find any file in the imported libraries that works. I've tried using my Google Cloud project id on its own or followed by .appspot.com but nothing works.
I assume it must be somewhere in my Project File, I just need to know where. And not knowing what it's called makes the search tricky.
Note: the Google Cloud site suggests asking technical questions on stackoverflow
This name comes from several #Api annotations that are set when configuring the Endpoints API. It sounds like you probably started off with the appengine-java8/endpoints-v2-backend example, which has the following declaration:
#Api(
name = "echo",
version = "v1",
namespace =
#ApiNamespace(
ownerDomain = "echo.example.com",
ownerName = "echo.example.com",
packagePath = ""
),
...
You can see the full definition in Echo.java.
The important things to note here are both the name field, and the ownerDomain from the namespace. Both of these together are used to generate the Java package that the code will belong in, but the segments of the ownerDomain path are reversed (as is standard in Java packages, which represent the hierarchy in the opposite way of normal DNS segments), so the Java package ends up being com.example.echo.echo. The Java class is just named after the #Api.name field (capitalized), so the class name is just Echo.
So, the fully qualified Java class you're looking for is:
com.example.echo.echo.Echo
or, for your exact code snippet:
com.example.echo.echo.Echo.Builder
This might be confusing because this example uses the word "echo" so many times, it's hard to attribute where each individual echo is coming from, but here's another example:
Let's say you set #Api.name to myApiName, and then set #Api.namespace.ownerDomain to mycompany.com. The fully qualified Java class that you would use from the generated client library is:
com.mycompany.myApiName.MyApiName
However, I would not recommend that you try to manually figure out what the Java package and class name are based on these rules. The much easier thing to do is just look at the client library generated by Endpoints.
When you run gradle endpointsClientLibs, the command outputs the location of the file that it has generated as a .zip file. All you have to do is unzip this file and explore all of the generated code within it to easily see what the Java package structure looks like, and even the exact class definitions that Endpoints is generating for you.
If you're having trouble finding these classes in your IDE, I wonder if you might have accidentally missed steps 4-7 from the Generating a client library instructions:
4) Unzip the file using the unzip utility, or use another ZIP-compatible unarchiving utility:
unzip ./echo-v1-java.zip
5) Change directory: cd echo.
6) Build the client library:
gradle build
The output is in the `build/libs` directory. The exact filename depends on the version of the Java client. It is something like echo-v1-1.23.0-SNAPSHOT.jar.
7) Add the client library JAR to your Java or Android app.

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...

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.

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

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.

Categories

Resources