Error while LinkedIn integration in java

489 views Asked by At

I am trying to integrate LinkedIn into my java web application but I am getting following exception when I tried to fetch the Person object from linkedin. The process of autherization/login/getting accesstoken is working fine and successfully. But while accessing linkedin object I am facing some issue.

Following is the code snippet:

LinkedInRequestToken requestToken = (LinkedInRequestToken) req.getSession().getAttribute("requestToken");
LinkedInOAuthService oauthService = LinkedInOAuthServiceFactory.getInstance().createLinkedInOAuthService(appkey, secretKey);
LinkedInAccessToken accessToken = oauthService.getOAuthAccessToken(requestToken, oauth_verifier);

LinkedInApiClientFactory factory = LinkedInApiClientFactory.newInstance(appId, secretKey);
LinkedInApiClient client = factory.createLinkedInApiClient(accessToken.getToken(), accessToken.getTokenSecret());

till code works fine but when I say,

Person person = client.getProfileForCurrentUser();

I am getting this exception:

com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
Package "com.google.code.linkedinapi.schema" is missing jaxb.properties file.
Have you copied this from the generated source directory or include it in the classpath?
this problem is related to the following location:
at com.google.code.linkedinapi.schema.ObjectFactory

I am using following dependecy for LinkedIn APIs

<dependency>
    <groupId>com.googlecode.linkedin-j</groupId>
    <artifactId>linkedin-j-core</artifactId>
    <version>1.0.416</version>
</dependency>
2

There are 2 answers

0
snapperdragon On BEST ANSWER

Version 1.0.416 has the jax.properties file missing.

See: https://code.google.com/p/linkedin-j/issues/detail?id=53

The steps that I followed: 1. checkout out the src and retrieved the core/src/main/java/com/google/code/linkedinapi/schema/jaxb.properties 2. mkdir -p mkdir -p src/main/resources/com/google/code/linkedinapi/schema/
cp jaxb.properties src/main/resources/com/google/code/linkedinapi/schema 3. It might work if you just have it in the current path, but this fix worked for me.

0
bunny sunny On

Along with maven you also need to add linkedin-j jar to build path. here is the link to download the jar http://www.java2s.com/Code/Jar/l/Downloadlinkedinjjar.htm @milind_db