2

我正在尝试将 LinkedIn 集成到我的 Java Web 应用程序中,但是当我尝试从linkedin中获取Person对象时出现以下异常。授权/登录/获取访问令牌的过程运行良好且成功。但是在访问linkedin对象时,我遇到了一些问题。

以下是代码片段:

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());

直到代码工作正常,但是当我说,

Person person = client.getProfileForCurrentUser();

我得到了这个例外:

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

我正在为 LinkedIn API 使用以下依赖项

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

2 回答 2

3

版本 1.0.416 缺少 jax.properties 文件。

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

我遵循的步骤: 1. 签出 src 并检索 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. 如果您只在当前路径中使用它,它可能会起作用,但这个修复对我有用.

于 2014-02-23T18:37:43.210 回答
0

除了 maven,您还需要添加linkedin-j jar 来构建路径。这是下载 jar 的链接http://www.java2s.com/Code/Jar/l/Downloadlinkedinjjar.htm @milind_db

于 2016-06-28T06:17:18.303 回答