alfdev / linkedin-j

Automatically exported from code.google.com/p/linkedin-j
0 stars 0 forks source link

javax.xml.bind.JAXBException: "com.google.code.linkedinapi.schema" doesnt contain ObjectFactory.class or jaxb.index #53

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
When I use

 MyProfile = client.getProfileForCurrentUser();  after I got token.

I go an exception

com.google.code.linkedinapi.client.LinkedInApiClientException: 
javax.xml.bind.JAXBException: "com.google.code.linkedinapi.schema" doesnt 
contain ObjectFactory.class or jaxb.index
    at com.google.code.linkedinapi.client.impl.LinkedInApiJaxbClient.unmarshallObject(LinkedInApiJaxbClient.java:74)
    at com.google.code.linkedinapi.client.impl.BaseLinkedInApiClient.readResponse(BaseLinkedInApiClient.java:1905)
    at com.google.code.linkedinapi.client.impl.BaseLinkedInApiClient.getProfileForCurrentUser(BaseLinkedInApiClient.java:1078)
    at net.shisoft.rmi.server.svr.plugin.ClassLinkedIn.LoadSvr(ClassLinkedIn.java:88)
    at net.shisoft.rmi.server.UserSvr.TestLoad(UserSvr.java:281)
    at net.shisoft.rmi.server.UserSvr$5.run(UserSvr.java:221)
Caused by: javax.xml.bind.JAXBException: "com.google.code.linkedinapi.schema" 
doesnt contain ObjectFactory.class or jaxb.index
    at com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:186)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:128)
    at javax.xml.bind.ContextFinder.find(ContextFinder.java:290)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:372)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:337)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:244)
    at com.google.code.linkedinapi.client.impl.LinkedInApiJaxbClient.getJaxbContext(LinkedInApiJaxbClient.java:126)
    at com.google.code.linkedinapi.client.impl.LinkedInApiJaxbClient.unmarshallObject(LinkedInApiJaxbClient.java:70)
    ... 5 more

Mac OS X 10.6.7            JDK1.6 
What's the problem?

Original issue reported on code.google.com by shisoftg...@gmail.com on 9 May 2011 at 1:13

GoogleCodeExporter commented 9 years ago
I can't seem to reproduce it. Can you explain your scenario in more detail? 
e.g. 
Are you calling the API from RMI?
Are all classes of linkedin-j.jar available in your classpath?
Which version of linkedin-j are you using?

Original comment by nabeelmukhtar on 11 May 2011 at 6:34

GoogleCodeExporter commented 9 years ago
Yes,It called from RMI

Original comment by shisoftg...@gmail.com on 11 May 2011 at 8:14

GoogleCodeExporter commented 9 years ago
Another clue is I uses JarFileLoader to load the  jar file that uses linkedin-j 
like this.But I am sure I loaded all of the jar files that linkedin-j referred
  private static Class LoadPluginJar(String ClassCode, List<Element> re) throws Exception {
        URL[] us = new URL[]{new File("Class" + ClassCode + ".jar").toURI().toURL()};
        JarFileLoader cl = new JarFileLoader(us);
        cl.addFile(System.getProperty("user.dir") + "/lib/Common.jar");
        for (Element gr : re) {
            cl.addFile(System.getProperty("user.dir") + "/lib/" + gr.attributeValue("Name") + ".jar");
        }
        Class c = cl.loadClass("net.shisoft.rmi.server.svr.plugin.Class" + ClassCode);
        //ClassLoader loader = new URLClassLoader(us);
        //Class c = loader.loadClass("net.shisoft.rmi.server.svr.plugin.Class" + ClassCode);
        SvrPluginInterface svrp = (SvrPluginInterface) c.newInstance();
        System.out.println("Loading Plugin..." + ClassCode + "..." + svrp.sayHello("RMIServerTestSession"));
        svrp = null;
        return c;
    }

Original comment by shisoftg...@gmail.com on 14 May 2011 at 10:49

GoogleCodeExporter commented 9 years ago
Any Solutions? Got the same problem!

Original comment by alexande...@googlemail.com on 27 Jun 2011 at 4:28

GoogleCodeExporter commented 9 years ago
Either try loading the resource jaxb.properties as well from the class loader 
or try putting jaxb.properties from linkedin-j.jar in your source path in the 
package com.google.code.linkedinapi.schema.

Original comment by nabeelmukhtar on 28 Jun 2011 at 11:33

GoogleCodeExporter commented 9 years ago
I can't add an explicit loading of the jaxb.properties. I do load my jars (they 
are plugins) with the classloader and use it via reflection. I do this with an 
interface, so I can't specify any loaded class. I can just specify the class 
which implements the interface. 

Also I already do not use your lib, I use your src and try to fix the bug. But 
I get no clou. It seems that is a known problem of your way of loading jaxb 
context in class LinkedInApiJaxbClient - Method getJaxbContext(). Read this 
carefully: 
http://www.opensubscriber.com/message/axis-user@ws.apache.org/12336076.html

I do use a tomcat. So I think that is the problem, but i dont know how to fix 
it. I tried several ways, but it does not work.

What do you think?

Original comment by alexande...@googlemail.com on 28 Jun 2011 at 12:34

GoogleCodeExporter commented 9 years ago
Okay I fixed it:

Class LinkedInApiJaxbClient 
Method getJaxbContext()

protected JAXBContext getJaxbContext() throws JAXBException {

        if (JAXB_CONTEXT == null ) {

            Thread.currentThread().setContextClassLoader(
                    this.getClass().getClassLoader()); //THIS FIXED IT
            JAXB_CONTEXT = JAXBContext.newInstance(JAXB_PACKAGE_NAME);
        } 
        return JAXB_CONTEXT;
    }

Original comment by alexande...@googlemail.com on 28 Jun 2011 at 1:34

GoogleCodeExporter commented 9 years ago
Good,let me try it when i am free,thank you.
�� 2011-6-28 ����9:35�� <linkedin-j@googlecode.com>���

javax.xml.bind.JAXBException: "com.google.code.linkedinapi.schema" doesnt
contain ObjectFactory.class or jaxb.index

//THIS FIXED IT

JAXBContext.newInstance(JAXB_PACKAGE_NAME);

Original comment by shisoftg...@gmail.com on 28 Jun 2011 at 1:38

GoogleCodeExporter commented 9 years ago
I use linkedin-j 1.0.416, and I have the same problem, I don't know how to 
solve it. Can you help me ?

Original comment by neoch...@gmail.com on 3 Oct 2011 at 8:39

GoogleCodeExporter commented 9 years ago
Include src instead of Lib and check 2 comments before (#7) - there i wrote how 
to fix.

Original comment by alexande...@googlemail.com on 3 Oct 2011 at 8:49

GoogleCodeExporter commented 9 years ago
this doesn't solve my problem

Original comment by neoch...@gmail.com on 3 Oct 2011 at 10:15

GoogleCodeExporter commented 9 years ago
Hi !

Just came across the same problem using the lib from Maven (version 1.0.416).

I actually fixed the problem by adding the 
com/google/code/linkedinapi/schema/jaxb.properties from the source jar in the 
lib jar.

is there a reason why the file was not included in the lib jar ?

Original comment by guinotp...@gmail.com on 6 Oct 2011 at 10:09

GoogleCodeExporter commented 9 years ago
Hi,
This happens to me as well using the maven repository.
This is a serious issue- cannot use the maven dependency version.

Original comment by lior.m...@gmail.com on 9 Oct 2011 at 7:55

GoogleCodeExporter commented 9 years ago
This was my fix...

I checkout out the src and retrieved the  
core/src/main/java/com/google/code/linkedinapi/schema/jaxb.properties

I'm using trunk r409 (Though I doubt it it matters)

http://linkedin-j.googlecode.com/svn/trunk/linkedin-j/core/src/main/java/com/goo
gle/code/linkedinapi/schema/jaxb.properties

I went to my own project and under the resources folder I created:

mkdir -p mkdir -p src/main/resources/com/google/code/linkedinapi/schema/  
cp jaxb.properties src/main/resources/com/google/code/linkedinapi/schema  

For some reason, the jaxb.properties file is missing from the maven build.

It might work if you just have it in the current path, but this fix worked for 
me.

Original comment by sa...@esamir.com on 11 Oct 2011 at 8:42

GoogleCodeExporter commented 9 years ago
Thank guinotp, it's working for me now, but I'm agree with lior, this kind of 
problem is very disturbing

Original comment by neoch...@gmail.com on 11 Oct 2011 at 10:10

GoogleCodeExporter commented 9 years ago
You're welcome...

Will a new Maven release be available soon? It would be helpful if no one will 
no longer have to rebuild the jar...

Original comment by guinotp...@gmail.com on 12 Oct 2011 at 8:05

GoogleCodeExporter commented 9 years ago
In addition to this, there is indeed an issue with the class loader, as Alex 
stated, the fix should be like this:

protected JAXBContext getJaxbContext() throws JAXBException {
    if (JAXB_CONTEXT == null ) {
        final ClassLoader cl = Thread.currentThread().getContextClassLoader();
        try {
            Thread.currentThread().setContextClassLoader(
                this.getClass().getClassLoader()); //THIS FIXED IT
            JAXB_CONTEXT = JAXBContext.newInstance(JAXB_PACKAGE_NAME);
        } finally {
            Thread.currentThread().setContextClassLoader(cl);
        }
    } 
    return JAXB_CONTEXT;
}

But adding a finally is very important...

Original comment by guinotp...@gmail.com on 13 Oct 2011 at 2:03

GoogleCodeExporter commented 9 years ago
Yup, same here. I will have to revert to the old version that I have cached in 
my local repository before this is fixed

Original comment by bozhidar...@gmail.com on 14 Oct 2011 at 8:02

GoogleCodeExporter commented 9 years ago
+1 i would love to see this fixed.  i tried just getting started with 
linkedin-j today and ran into this issue

Original comment by benjamin...@gmail.com on 12 Nov 2011 at 5:56

GoogleCodeExporter commented 9 years ago
BTW, fyi, this issue easily has the most open stars of any other issue, so it 
would probably make sense to mark it as a higher priority.

Original comment by benjamin...@gmail.com on 12 Nov 2011 at 7:51

GoogleCodeExporter commented 9 years ago
Ditto. For those of us using Maven with multi-person projects, this is a very 
annoying problem.

Original comment by shah...@justlynx.com on 14 Nov 2011 at 9:54

GoogleCodeExporter commented 9 years ago
Ping.  This is a frustrating issue to have to deal with.  I'd love for a new 
version with the problem fixed to be uploaded to Maven.

Original comment by benjamin...@gmail.com on 14 Dec 2011 at 2:33

GoogleCodeExporter commented 9 years ago
I'd love to see this fixed too, it's really frustrating.

Original comment by jjer...@gmail.com on 14 Dec 2011 at 6:49

GoogleCodeExporter commented 9 years ago
There's 11 votes for this issue now with only 3 for the next such issue.  This 
really needs to get fixed.

Original comment by benjamin...@gmail.com on 15 Dec 2011 at 1:29

GoogleCodeExporter commented 9 years ago
Would be great to see it fixed

Original comment by egor@technoparkcorp.com on 25 Apr 2012 at 3:17

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
This is fixed in #429 it seems, BUT, there isn't a maven repo with #429, thus 
the problem isn't really fixed for anyone using maven/ivy.

Original comment by njstrif...@gmail.com on 25 Apr 2012 at 9:18

GoogleCodeExporter commented 9 years ago
thank esamir,
previously i got same error,after following your step,problem is resolved
thank u very much...

Original comment by manjegow...@gmail.com on 3 Sep 2013 at 5:59

GoogleCodeExporter commented 9 years ago
Hi,
I am using maven dependency ..
<dependency>
            <groupId>com.googlecode.linkedin-j</groupId>
            <artifactId>linkedin-j-core</artifactId>
            <version>1.0.416</version>
            <scope>compile</scope>
        </dependency>

But facing the exception:----
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

 - with linked exception:

Original comment by vaibhavp...@gmail.com on 17 Feb 2014 at 2:25

GoogleCodeExporter commented 9 years ago
Hello! Do not use maven for linkedin. There is error. Use jar 1.0.429

Best regards, Vadym.
Skype: flexin777
ml: vadym[point]morozov[at]gmail[point]com

Original comment by Vadym.Mo...@gmail.com on 29 May 2014 at 11:26

GoogleCodeExporter commented 9 years ago
No Maven? Seriously!

Facing the same issue. Will download the jar.

Original comment by riteshka...@gmail.com on 20 Feb 2015 at 1:33