Nuxeo Java Remote APIs could not be used from a webapp deployed in JBoss
------------------------------------------------------------------------
Key: NXP-3630
URL: http://jira.nuxeo.org/browse/NXP-3630
Project: Nuxeo Enterprise Platform
Issue Type: Bug
Components: Runtime
Affects Versions: 5.2 M4
Reporter: Sanjay Dalal
Assignee: Thierry Delprat
Priority: Blocker
The following email thread with Subject: "[Nuxeo-dev] using Nuxeo Java remote
APIs" describes the issue and resolution. Let me know if you need more details.
Sanjay Dalal wrote, On 5/12/2009 12:57 PM:
> Hi all,
>
> Found one bug in JBossServiceLocator.java of nuxeo-runtime APIs.
>
> public static String getDefaultSuffix() {
> return System.getProperty("jboss.home.dir") == null ? "/remote" : "/local";
> // if not in jboss return "/remote"
> }
>
> The above check clearly indicates that it is impossible to use Remote APIs
> from a client that is also running in another instance of JBoss. It explains
> why a standalone Java client from command line interface works and the same
> code fails if run from a war deployed in another JBoss instance.
>
> Secondly, you may want to use something as follows to check for system
> properties.
>
> Boolean.getBoolean("org.nuxeo.client.remote") ? "/remote" : "/local";
>
> This will make sure you get the right result even if the property is not set
> or is not true. 2c.
>
> Now on to the next bug/problem...
>
> sanjay
>
>
>
> Sanjay Dalal wrote, On 5/11/2009 2:15 PM:
>> Hi Tiry/Bogdan/all,
>>
>> Considering various classloading issues we faced while running Nuxeo and
>> CollectionSpace (client of Nuxeo repository) in the same JBoss server
>> instance, we are now trying to run these in two separate instances: one
>> hosting Nuxeo and the other hosting CollectionSpace. CollectionSpace is
>> deployed as a war. It deploys Nuxeo jars using OSGI and connects to another
>> server running Nuxeo. We use ports-01 configuration of JBoss to run
>> CollectionSpace server and ports-default configuration for the Nuxeo server.
>>
>> While we can successfully run a standalone Nuxeo client from command line
>> following Bogdan's instructions (README.txt of nuxeo-core-client), a war
>> client (collectionspace) implemented similarly fails. The attached zip file
>> has two log files.
>>
>> 1. java_client.log shows the log from standalone client (attaching for
>> comparison)
>> 2. short_server.log shows the log from a CS war client
>>
>> I have added some System.outs in nuxeo-core-client code with prefix ">>>"
>> for debug purposes.
>>
>> It appears that schemaRemotingWorkaround method of NuxeoClient.java fails
>> (see log) with the following exception while invoked from a war.
>>
>> 2009-05-11 12:34:54,922 ERROR [STDERR] javax.ejb.EJBException: Invalid (i.e.
>> remote) invocation of local interface (null container)
>> 2009-05-11 12:34:54,922 ERROR [STDERR] at
>> org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:80)
>> 2009-05-11 12:34:54,922 ERROR [STDERR] at
>> $Proxy103.getDocumentTypes(Unknown Source)
>> 2009-05-11 12:34:54,922 ERROR [STDERR] at
>> org.nuxeo.ecm.core.schema.SchemaManagerImpl.importTypes(SchemaManagerImpl.java:101)
>>
>> I would think that both the clients use exactly the same nuxeo configuration
>> properties but I might be wrong. Just to be sure, I explicitly set the
>> following properties in both the clients.
>>
>> System.setProperty("org.nuxeo.runtime.server.enabled",
>> Boolean.FALSE.toString());
>> System.setProperty("org.nuxeo.runtime.server.port", "62474");
>> System.setProperty("org.nuxeo.runtime.server.host", "127.0.0.1");
>> System.setProperty("org.nuxeo.runtime.1.3.3.streaming.port", "3233");
>> System.setProperty("org.nuxeo.runtime.streaming.serverLocator",
>> "socket://127.0.0.1:3233");
>> System.setProperty("org.nuxeo.runtime.streaming.isServer",
>> Boolean.FALSE.toString());
>>
>> If I comment out the schemaRemotingWorkaround call, the client successfully
>> completes login. Then it fails with a similar exception while calling
>> openRepository method of the NuxeoClient.
>>
>> Looking forward...
>> thanks,
>> sanjay
>>
>>
>>
>>
>> Tiry wrote, On 4/24/2009 3:42 AM:
>>> Hi,
>>>
>>> This is probably a classloader issue.
>>> Your war client and nuxeo are in the same JVM and share a parent
>>> classloader that is used for jboss-remoting.
>>> You can try to force call-by-value isolation in Jboss to see if this make
>>> it work better.
>>>
>>> Tiry
>>>
>>> Sanjay Dalal a écrit :
>>>> Hi Tiry,
>>>>
>>>> Thank you. That got me past that hurdle. Seems like some properties were
>>>> not loaded from the classpath, so currently I set those from my Java code.
>>>> However, now, I see a ClassCastException for DocumentType (see below). If
>>>> I comment out schemaRemotingWorkaround (attached NuxeoClient.java), it
>>>> makes the connection but then I get the same exception while trying to
>>>> getDefaultRepository down the road. I have packaged the war with all the
>>>> libs that Bogdan has mentioned in his README (see at the bottom of this
>>>> email). I think I have made sure that I am packaging the same jars in the
>>>> war that are also used on the server side of Nuxeo. Do I have to set some
>>>> classloader specific properties? For example in nxserver.cmd of
>>>> webengine-server, I see the following two properties.
>>>>
>>>> -Djava.rmi.server.RMIClassLoaderSpi=org.nuxeo.runtime.launcher.NuxeoRMIClassLoader
>>>> -Dsun.lang.ClassLoader.allowArraySyntax=true
>>>>
>>>> Looking forward...
>>>> thanks,
>>>> sanjay
>>>>
>>>> 17:01:55,790 ERROR [STDERR] java.lang.ClassCastException:
>>>> [Lorg.nuxeo.ecm.core.s
>>>> chema.DocumentType; cannot be cast to
>>>> [Lorg.nuxeo.ecm.core.schema.DocumentType;
>>>> 17:01:55,790 ERROR [STDERR] at $Proxy498.getDocumentTypes(Unknown
>>>> Source)
>>>> 17:01:55,790 ERROR [STDERR] at
>>>> org.nuxeo.ecm.core.schema.SchemaManagerImpl.i
>>>> mportTypes(SchemaManagerImpl.java:101)
>>>> 17:01:55,790 ERROR [STDERR] at
>>>> org.collectionspace.services.nuxeo.NuxeoClien
>>>> t.schemaRemotingWorkaround(NuxeoClient.java:222)
>>>> 17:01:55,790 ERROR [STDERR] at
>>>> org.collectionspace.services.nuxeo.NuxeoClien
>>>> t.doConnect(NuxeoClient.java:174)
>>>> 17:01:55,790 ERROR [STDERR] at
>>>> org.collectionspace.services.nuxeo.NuxeoClien
>>>> t.tryConnect(NuxeoClient.java:135)
>>>> 17:01:55,790 ERROR [STDERR] at
>>>> org.collectionspace.hello.services.Multischem
>>>> aResource.getRepository(MultischemaResource.java:263)
>>>> 17:01:55,790 ERROR [STDERR] at
>>>> org.collectionspace.hello.services.Multischem
>>>> aResource.createPerson(MultischemaResource.java:72)
>>>> 17:01:55,790 ERROR [STDERR] at
>>>> sun.reflect.NativeMethodAccessorImpl.invoke0(
>>>> Native Method)
>>>> 17:01:55,790 ERROR [STDERR] at
>>>> sun.reflect.NativeMethodAccessorImpl.invoke(N
>>>> ativeMethodAccessorImpl.java:39)
>>>> 17:01:55,790 ERROR [STDERR] at
>>>> sun.reflect.DelegatingMethodAccessorImpl.invo
>>>> ke(DelegatingMethodAccessorImpl.java:25)
>>>> 17:01:55,790 ERROR [STDERR] at
>>>> java.lang.reflect.Method.invoke(Method.java:5
>>>> 97)
>>>> 17:01:55,790 ERROR [STDERR] at
>>>> org.jboss.resteasy.core.MethodInjectorImpl.in
>>>> voke(MethodInjectorImpl.java:117)
>>>> 17:01:55,790 ERROR [STDERR] at
>>>> org.jboss.resteasy.core.ResourceMethod.invoke
>>>> OnTarget(ResourceMethod.java:260)
>>>> 17:01:55,790 ERROR [STDERR] at
>>>> org.jboss.resteasy.core.ResourceMethod.invoke
>>>> (ResourceMethod.java:232)
>>>> 17:01:55,790 ERROR [STDERR] at
>>>> org.jboss.resteasy.core.ResourceMethod.invoke
>>>> (ResourceMethod.java:166)
>>>> 17:01:55,790 ERROR [STDERR] at
>>>> org.jboss.resteasy.core.DispatcherUtilities.g
>>>> etJaxrsResponse(DispatcherUtilities.java:142)
>>>> 17:01:55,790 ERROR [STDERR] at
>>>> org.jboss.resteasy.core.SynchronousDispatcher
>>>> .invoke(SynchronousDispatcher.java:356)
>>>> 17:01:55,790 ERROR [STDERR] at
>>>> org.jboss.resteasy.core.SynchronousDispatcher
>>>> .invoke(SynchronousDispatcher.java:173)
>>>> 17:01:55,790 ERROR [STDERR] at
>>>> org.jboss.resteasy.plugins.server.servlet.Htt
>>>> pServletDispatcher.service(HttpServletDispatcher.java:93)
>>>> 17:01:55,790 ERROR [STDERR] at
>>>> org.jboss.resteasy.plugins.server.servlet.Htt
>>>> pServletDispatcher.service(HttpServletDispatcher.java:68)
>>>> 17:01:55,790 ERROR [STDERR] at
>>>> javax.servlet.http.HttpServlet.service(HttpSe
>>>> rvlet.java:803)
>>>> 17:01:55,790 ERROR [STDERR] at
>>>> org.apache.catalina.core.ApplicationFilterCha
>>>> in.internalDoFilter(ApplicationFilterChain.java:290)
>>>> 17:01:55,790 ERROR [STDERR] at
>>>> org.apache.catalina.core.ApplicationFilterCha
>>>> in.doFilter(ApplicationFilterChain.java:206)
>>>> 17:01:55,790 ERROR [STDERR] at
>>>> org.jboss.web.tomcat.filters.ReplyHeaderFilte
>>>> r.doFilter(ReplyHeaderFilter.java:96)
>>>> 17:01:55,790 ERROR [STDERR] at
>>>> org.apache.catalina.core.ApplicationFilterCha
>>>> in.internalDoFilter(ApplicationFilterChain.java:235)
>>>> 17:01:55,790 ERROR [STDERR] at
>>>> org.apache.catalina.core.ApplicationFilterCha
>>>> in.doFilter(ApplicationFilterChain.java:206)
>>>> 17:01:55,790 ERROR [STDERR] at
>>>> org.apache.catalina.core.StandardWrapperValve
>>>> .invoke(StandardWrapperValve.java:230)
>>>> 17:01:55,790 ERROR [STDERR] at
>>>> org.apache.catalina.core.StandardContextValve
>>>> .invoke(StandardContextValve.java:175)
>>>> 17:01:55,790 ERROR [STDERR] at
>>>> org.jboss.web.tomcat.security.SecurityAssocia
>>>> tionValve.invoke(SecurityAssociationValve.java:182)
>>>> 17:01:55,790 ERROR [STDERR] at
>>>> org.jboss.web.tomcat.security.JaccContextValv
>>>> e.invoke(JaccContextValve.java:84)
>>>> 17:01:55,805 ERROR [STDERR] at
>>>> org.apache.catalina.core.StandardHostValve.in
>>>> voke(StandardHostValve.java:127)
>>>> 17:01:55,805 ERROR [STDERR] at
>>>> org.apache.catalina.valves.ErrorReportValve.i
>>>> nvoke(ErrorReportValve.java:102)
>>>> 17:01:55,805 ERROR [STDERR] at
>>>> org.jboss.web.tomcat.service.jca.CachedConnec
>>>> tionValve.invoke(CachedConnectionValve.java:157)
>>>> 17:01:55,805 ERROR [STDERR] at
>>>> org.apache.catalina.valves.AccessLogValve.inv
>>>> oke(AccessLogValve.java:562)
>>>> 17:01:55,805 ERROR [STDERR] at
>>>> org.apache.catalina.core.StandardEngineValve.
>>>> invoke(StandardEngineValve.java:109)
>>>> 17:01:55,805 ERROR [STDERR] at
>>>> org.apache.catalina.connector.CoyoteAdapter.s
>>>> ervice(CoyoteAdapter.java:262)
>>>> 17:01:55,805 ERROR [STDERR] at
>>>> org.apache.coyote.http11.Http11Processor.proc
>>>> ess(Http11Processor.java:844)
>>>> 17:01:55,805 ERROR [STDERR] at
>>>> org.apache.coyote.http11.Http11Protocol$Http1
>>>> 1ConnectionHandler.process(Http11Protocol.java:583)
>>>> 17:01:55,805 ERROR [STDERR] at
>>>> org.apache.tomcat.util.net.JIoEndpoint$Worker
>>>> .run(JIoEndpoint.java:446)
>>>> 17:01:55,805 ERROR [STDERR] at java.lang.Thread.run(Thread.java:619)
>>>> 17:01:55,805 ERROR [STDERR] 57954 [http-127.0.0.1-8080-1] ERROR
>>>> org.jboss.restea
>>>> sy.core.SynchronousDispatcher - failed to execute
>>>>
>>>> Tiry wrote, On 4/23/2009 3:57 PM:
>>>>> Hi,
>>>>>
>>>>> Looks like you are starting 2 remoting servers on the same IP.
>>>>> Changing org.nuxeo.runtime.server.enabled property in your client
>>>>> packaging should disable this.
>>>>> (=> only Nuxeo server should start the remoting server)
>>>>>
>>>>> This shouls fix the first error, and may be the other too (Remoting
>>>>> service not found because activation failed because of the
>>>>> SocketAlreadyInUse error).
>>>>>
>>>>> PS : I still don't understand what you say about Rest API, but probably I
>>>>> we did not understood ...
>>>>>
>>>>> Tiry
>>>>>
>>>>>
>>>>> Sanjay Dalal a écrit :
>>>>>> Hi,
>>>>>>
>>>>>> I had sent this to the main list. Now sending to dev list per Florent's
>>>>>> request. Looking forward
>>>>>>
>>>>>> thanks,
>>>>>> sanjay
>>>>>>
>>>>>> -------- Original Message --------
>>>>>> Subject: Re: [Ecm] looking for restful api sample for create and
>>>>>> update
>>>>>> Date: Tue, 21 Apr 2009 10:59:01 -0700
>>>>>> From: Sanjay Dalal <[email protected]>
>>>>>> To: Bogdan Stefanescu <[email protected]>
>>>>>> CC: ECM List <[email protected]>
>>>>>> References: <[email protected]>
>>>>>> <[email protected]>
>>>>>> <[email protected]>
>>>>>>
>>>>>>
>>>>>>
>>>>>> Sending again with zipped server log. Thanks in advance.
>>>>>>
>>>>>> sanjay
>>>>>>
>>>>>> Sanjay Dalal wrote, On 4/21/2009 10:09 AM:
>>>>>> > Hi Bogdan,
>>>>>> >
>>>>>> > At CollectionSpace, we just delivered 0.1 milestone that has web >
>>>>>> > services that use Nuxeo's RESTful APIs. So, I thought of trying once >
>>>>>> > again the remote Java API route as Nuxeo's RESTful APIs seem to offer
>>>>>> > > very minimal functionality as per our needs. I followed your >
>>>>>> > instructions from README (see email trail below). Note that, I am >
>>>>>> > trying to connect to Nuxeo repository that is available in the same >
>>>>>> > JVM where my war (helloworld.war) using the Nuxeo remote APIs (as per
>>>>>> > > your instructions below) is also deployed. I get JVM_bind exception.
>>>>>> > I > am attaching the server log for your inspection. You can start >
>>>>>> > tracking from line #21052. You can also go back in server.log if you >
>>>>>> > want to check how Nuxeo is deployed. Let me know what am I missing and
>>>>>> > > which port should I use if port#62474 is not correct. Looking
>>>>>> > forward > to hear from you.
>>>>>> >
>>>>>> > thanks,
>>>>>> > sanjay
>>>>>> >
>>>>>> > 2009-04-20 16:48:18,344 DEBUG >
>>>>>> > [org.nuxeo.runtime.model.ComponentManager] Dispatching event: >
>>>>>> > ACTIVATING_COMPONENT:
>>>>>> > service:org.nuxeo.runtime.remoting.RemotingService
>>>>>> >
>>>>>> > 2009-04-20 16:48:18,453 DEBUG [org.jboss.remoting.ServerInvoker] >
>>>>>> > SocketServerInvoker[UNINITIALIZED] did not find server socket factory
>>>>>> > > configuration as mbean service or classname. Creating default server
>>>>>> > > socket factory.
>>>>>> >
>>>>>> > 2009-04-20 16:48:18,453 DEBUG [org.jboss.remoting.ServerInvoker] >
>>>>>> > SocketServerInvoker[UNINITIALIZED] created server socket factory >
>>>>>> > javax.net.defaultserversocketfact...@13acc52
>>>>>> >
>>>>>> > 2009-04-20 16:48:18,453 DEBUG [org.jboss.remoting.ServerInvoker] >
>>>>>> > SocketServerInvoker[UNINITIALIZED] added >
>>>>>> > org.nuxeo.runtime.remoting.transporter.transporterhand...@1cf9df7 for
>>>>>> > > subsystem 'org.nuxeo.runtime.remoting.Server'
>>>>>> >
>>>>>> > 2009-04-20 16:48:18,453 DEBUG >
>>>>>> > [org.jboss.remoting.transport.socket.SocketServerInvoker] >
>>>>>> > SocketServerInvoker[UNINITIALIZED] starting
>>>>>> >
>>>>>> > 2009-04-20 16:48:18,453 ERROR >
>>>>>> > [org.jboss.remoting.transport.socket.SocketServerInvoker] Error >
>>>>>> > starting ServerSocket. Bind port: 62474, bind address: /127.0.0.1
>>>>>> >
>>>>>> > 2009-04-20 16:48:18,453 ERROR [org.jboss.remoting.transport.Connector]
>>>>>> > > Error starting connector.
>>>>>> >
>>>>>> >
>>>>>> > Here is the snippet of the code (derived from your client sample). I >
>>>>>> > have copied the jars you listed in README to >
>>>>>> > $JBOSS_HOME/server/default/cs/lib directory. All the jars you have >
>>>>>> > listed are also packaged with the war.
>>>>>> >
>>>>>> > From my MultischemaResource.java (deployed under helloworld.war)...
>>>>>> >
>>>>>> > synchronized private RepositoryInstance getRepository() throws >
>>>>>> > Exception {
>>>>>> > if(repo != null){
>>>>>> > return repo;
>>>>>> > }
>>>>>> > Collection<File> files = null;
>>>>>> > String bundles = >
>>>>>> > "./cs/lib/nuxeo-runtime-*:./cs/lib/nuxeo-*";//System.getProperty("nuxeo.bundles");
>>>>>> > >
>>>>>> > if(bundles != null){
>>>>>> > files = NuxeoApp.getBundleFiles(new File("."), bundles,
>>>>>> > ":");
>>>>>> > }
>>>>>> > NuxeoApp app = new NuxeoApp();
>>>>>> > app.start();
>>>>>> > verbose("getRepository: deploying bundles: " + files);
>>>>>> > if(files != null){
>>>>>> > app.deployBundles(files);
>>>>>> > }
>>>>>> >
>>>>>> > nxClient = NuxeoClient.getInstance();
>>>>>> > nxClient.tryConnect(CS_NUXEO_HOST, 62474);
>>>>>> > repo = nxClient.openRepository();
>>>>>> > verbose("getRepository: repository root: " + >
>>>>>> > repo.getRootDocument());
>>>>>> > return repo;
>>>>>> > }
>>>>>> >
>>>>>> >
>>>>>> >
>>>>>> > Bogdan Stefanescu wrote, On 3/23/2009 4:46 PM:
>>>>>> >>
>>>>>> >>
>>>>>> >> Hi,
>>>>>> >>
>>>>>> >> I just commited a sample o how to start a nuxeo client application >>
>>>>>> >> and connect to a remote server.
>>>>>> >> See nuxeo-core-client project. Read this for how to run the sample:
>>>>>> >> >>
>>>>>> >> nuxeo-core-client/src/main/java/org/nuxeo/ecm/core/client/sample/README.txt
>>>>>> >> >>
>>>>>> >>
>>>>>> >> Bogdan
>>>>>> >>
>>>>>> >>
>>>>>> >> On Mar 23, 2009, at 9:15 PM, Sanjay Dalal wrote:
>>>>>> >>
>>>>>> >>> Hi,
>>>>>> >>>
>>>>>> >>> Due to classloading problems described in thread, "using Nuxeo Java
>>>>>> >>> >>> APIs ", I have temporarily moved to using the RESTful apis (I
>>>>>> >>> will >>> get back to Java APIs soon).
>>>>>> >>>
>>>>>> >>> I am following the documentation at >>>
>>>>>> >>> http://doc.nuxeo.org/5.2/books/nuxeo-book/html-single/#d1801e6206 to
>>>>>> >>> >>> write my client. While I can browse the repository by calling
>>>>>> >>> the >>> Browse APIs, I am looking for URL and parameter mappings for
>>>>>> >>> CREATE >>> (or POST) and UPDATE (or PUT) operations on a document. I
>>>>>> >>> can see >>> corresponding Restlets in the source tree, however, I
>>>>>> >>> cannot find >>> any documentation at >>>
>>>>>> >>> http://doc.nuxeo.org/5.2/books/nuxeo-book/html-single/#d1801e6206.
>>>>>> >>> >>> Needless to say that with some effort, I can determine the URL
>>>>>> >>> and >>> the parameter mappings from the source code, but APIs should
>>>>>> >>> have >>> been documented unless Nuxeo does not support these
>>>>>> >>> operations using >>> RESTful APIs in 5.2. Let me know.
>>>>>> >>>
>>>>>> >>> Second question, the pattern |"/{repo}/{docid}/{filename}/{verb}"
>>>>>> >>> >>> does not seem to follow "RESTful" URI pattern. Thoughts?|
>>>>>> >>>
>>>>>> >>> thanks,
>>>>>> >>> sanjay
>>>>>> >>> _______________________________________________
>>>>>> >>> ECM mailing list
>>>>>> >>> [email protected] <mailto:[email protected]>
>>>>>> >>> http://lists.nuxeo.com/mailman/listinfo/ecm
>>>>>> >>> To unsubscribe, go to http://lists.nuxeo.com/mailman/options/ecm
>>>>>> >>
>>>>>>
>>>>>>
>>>>>> ------------------------------------------------------------------------
>>>>>>
>>>>>> _______________________________________________
>>>>>> Nuxeo-dev mailing list
>>>>>> [email protected]
>>>>>> http://lists.nuxeo.com/mailman/listinfo/nuxeo-dev
>>>>>
>>>
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.nuxeo.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
_______________________________________________
ECM-tickets mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/ecm-tickets