How to upload files to google drive using java-Google Docs Api? - java

Already I used older version of the API to upload files to Google docs but now the API version is revised, so I couldn't upload.
Previously I used these lines for authorization:
DocsService service = new DocsService("MyDocumentsListIntegration-v1");
service.setUserCredentials(USERNAME, PASSWORD);
But now it is giving this error:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/MessagingException
at sample.main(sample.java:15)
Caused by: java.lang.ClassNotFoundException: javax.mail.MessagingException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more
Can anyone help me?

It seems like you are missing one of the external dependencies, mail.jar, which is part of Sun's JavaMail API.
Check this page for instructions on how to get it as well as all other external dependencies: https://developers.google.com/gdata/articles/java_client_lib

Related

Upload an Object Using the AWS SDK for Java

I am using the following code from AWS documentation:
http://docs.aws.amazon.com/AmazonS3/latest/dev/UploadObjSingleOpJava.html
And i have used the following jars :
And i am getting the following error :
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at com.amazonaws.AmazonWebServiceClient.(AmazonWebServiceClient.java:58)
at UploadObject.main(UploadObject.java:17)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
Any help would be appreciated for the same. I have tried adding the common logging jars but no luck.
Hi there are quite a few third-party library's required for AWS to work. The ones below are the extras packaged with the SDK download. I seem to remember there being one missing though so let me know if this doesn't work and i'll check my dependencys.
All of these can be found in '\aws-java-sdk-1.9.1\third-party'
aspectj-1.6
commons-codec-1.6
commons-logging-1.1.3
freemarker-2.3.1.8
httpcomponents-client-4.3
jackson-annotations-2.3.0
jackson-core-2.3.2
jackson-databind-2.3.2
javax-mail-1.4.6
joda-time-2.2
spring-3.0

NoClassDefFoundError: com/google/appengine/api/urlfetch/ResponseTooLargeException

I am using Google + API to search for people using the following statement.
Plus plus = new Plus.Builder(httpTransport, jsonFactory, null).
setApplicationName("AppName").setGoogleClientRequestInitializer(new
PlusRequestInitializer(API_KEY)).build();
Plus.People.Search searchPeople = plus.people().search(personName).setMaxResults(1L);
PeopleFeed peopleFeed = searchPeople.execute();
I put the dependencies for the library in pom.xml so that it can be build when maven executed
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-plus</artifactId>
<version>v1-rev64-1.13.2-beta</version>
</dependency>
But I get the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/appengine/api/urlfetch/ResponseTooLargeException
at com.google.api.client.extensions.appengine.http.urlfetch.UrlFetchTransport.buildGetRequest(UrlFetchTransport.java:61)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:867)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:399)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:328)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:449)
at com.google.PeopleSearch.googleAccountSearch(PeopleSearch.java:52)
at com.google.Search.main(Search.java:128)
Caused by: java.lang.ClassNotFoundException: com.google.appengine.api.urlfetch.ResponseTooLargeException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Any suggestions?
I had a similar error NoClassDefFoundError: com/google/appengine/api/urlfetch/HTTPMethod , for me it was resolved by copying the App Engine SDK jar file from SDK/lib/user/appengine-api-1.0-sdk-1.9.27.jar into my project's WEB-INF/lib folder (I was not using Maven).

Launch4j - Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/MessagingException

I used launch4j (http://launch4j.sourceforge.net/) software to create an executable of my application created in java netbeans.
I did everything as I saw in a tutorial, just that when I run the exectutavel it creates in my application, it gives this error:
The message shown below is:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/MessagingException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: javax.mail.MessagingException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 6 more
Does anyone can help me solve this problem please.
I've been searching but I can not solve. I apologize for this question but am new to java.
Thank you all.
Greetings
In your launch4j configuration file add the jars like this
<classPath mainClass="your.main.class">
<cp>path/to/javamail.jar</cp>
<cp>path/to/folder/*.jar</cp> // you can also add all the jars in a folder like this
</classPath>
It will automatically bundle them.
Hope this helps
EDIT
Just went through netbeans integration with launch4j and it seems there is no way to write your on config xml file instead it prompts you in launch4J GUI for dependencies. I searched and found this Stackoverflow Post. This is what you want. Good Luck.
Add Java mail jar to classpath.
Download it from here
http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-eeplat-419426.html#javamail-1.4.7-oth-JPR

Exporting Runnable JAR in eclipse with User Libraries included

I am trying to create a runnable JAR file from a project of which I'm importing org.apache.commons.io. I tried exporting and checked the box to include all dependant libraries but I keep getting this output:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/io
/filefilter/TrueFileFilter
at tvSort.Main.main(Main.java:36)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.filefilter.Tr
ueFileFilter
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more
Any help would be appreciated, thank you.
Did you try setting up classpath in the Manifest?
e.g. Class-Path: commons-io-xyzversion.jar
If you can please try to add this manifest entry manually by saving this in a text file and adding it via the jar tool.
Hopefully eclipse has already done this,so did you run the jar with dependencies(jars) in the same folder/path?

How to check pdf is protected using itext in java

I am using itext library to know whether the pdf file is protected or not.
i am also add boncycastle library to my class path but it still showing error:
Caused by: java.lang.ClassNotFoundException: org.bouncycastle.asn1.DEREncodable
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 7 more
Put this library in your classpath bcprov-jdk15on-1.47.jar
UPDATE
Mind your bouncy castle dependencies version according to the IText version you are using. To double check it with maven repositories. eg. here or here

Categories

Resources