JacksonFactory problem

2,108 views
Skip to first unread message

amit...@sial.com

unread,
Feb 13, 2014, 6:26:23 AM2/13/14
to google-a...@googlegroups.com
Hi  Google apps Team,

PFA image regarding error.
   
         OR
package com.sial;

import java.io.File;
import java.util.Arrays;
import java.util.List;
import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.*;
import com.google.api.client.json.jackson.JacksonFactory;
import com.google.api.services.admin.directory.Directory;
import com.google.api.services.admin.directory.model.Users;

public class DirectorySamples {
private static final JsonFactory JSON_FACTORY = new JacksonFactory();
private static final List<String> SCOPES = Arrays.asList(

public static void main(String[] args) {
try {

HttpTransport httpTransport = new NetHttpTransport();

GoogleCredential credential = new GoogleCredential.Builder()
.setTransport(httpTransport)
.setJsonFactory(JSON_FACTORY)
.setServiceAccountId(
.setServiceAccountUser("super...@mydomain.com")
.setServiceAccountScopes(SCOPES)
.setServiceAccountPrivateKeyFromP12File(
new File(
"C://Users//arai1//My programs//GoogleDirectory//GoogleAppsDirectory//src//com//sial//0f7279aacd6f525c76bede6b92e9f60c42a6e07f-privatekey.p12"))
.build();

Directory admin = new Directory.Builder(httpTransport,
JSON_FACTORY, credential)
.setApplicationName("User Sync Service")
.setHttpRequestInitializer(credential).build();

Directory.Users.List list = admin.users().list();
Users users = list.execute();
System.out.println("************" + users.toString());
System.gc();
} catch (Exception e) {
e.printStackTrace();
}
}

}


ERROR

Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/jackson/JsonFactory
at com.google.api.client.json.jackson.JacksonFactory.<init>(JacksonFactory.java:38)
at com.sial.DirectorySamples.<clinit>(DirectorySamples.java:21)
Caused by: java.lang.ClassNotFoundException: org.codehaus.jackson.JsonFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 2 more






I am trying to Access Google Directory using my googl-clien-api .
But there is some error regarding Jackson factory 

How can I resolve this plz help me regarding this.


Thanks & Regards
Amit

This message and any files transmitted with it are the property of Sigma-Aldrich Corporation, are confidential, and are intended solely for the use of the person or entity to whom this e-mail is addressed. If you are not one of the named recipient(s) or otherwise have reason to believe that you have received this message in error, please contact the sender and delete this message immediately from your computer. Any other use, retention, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited.
Jacmkson Error.png

Vinny P

unread,
Feb 13, 2014, 9:38:09 PM2/13/14
to google-a...@googlegroups.com
On Thu, Feb 13, 2014 at 5:26 AM, <amit...@sial.com> wrote:
Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/jackson/JsonFactory
at com.google.api.client.json.jackson.JacksonFactory.<init>(JacksonFactory.java:38)
at com.sial.DirectorySamples.<clinit>(DirectorySamples.java:21)
Caused by: java.lang.ClassNotFoundException: org.codehaus.jackson.JsonFactory
How can I resolve this plz help me regarding this.


Most of the time, this occurs when the runtime can't find the Jackson library. Have you added the Jackson JARs to your Eclipse project and added them to your build path? 
 
 
-----------------
-Vinny P
Technology & Media Advisor
Chicago, IL

App Engine Code Samples: http://www.learntogoogleit.com

Benjamin Com

unread,
Feb 16, 2016, 12:01:35 PM2/16/16
to Google App Engine
Hi Vinny,
Presuming the OP is using Maven (which I am), isn't this a bug in the "Google Client API" maven project? If that project requires Jackson to work, then it should indicate Jackson as a dependency. In that case, any of us depending on "Google Client API" should be enough, and it will transitively register a dependency on Jackson. It will do this IMPLICITLY, without any of us needing to explicitly indicate that dependency. As we don't actually depend on Jackson directly, it would be bad design for us to explicitly list it due to knowledge of internal implementation of "Google Client API."

I am having this error too, but I depend on some older versions of GAE SDK. I will update those first to see if it resolves itself, otherwise I'll use your approach and just force-depend on Jackson (despite having no direct dependency).
Thanks,
-b

(details: I currently use version 1.9.21 in my GAE maven dependencies)

Nick (Cloud Platform Support)

unread,
Feb 16, 2016, 3:55:31 PM2/16/16
to Google App Engine
Hey Benjamin,

That would be a correct analysis, but I have the sneaking suspicion that OP is not using Maven, and thus has forgotten to include the relevant jar dependencies for the API client library.
Reply all
Reply to author
Forward
0 new messages