cancel
Showing results for 
Search instead for 
Did you mean: 

JCR-RMI with multi-valued property

vijayreddy
Champ in-the-making
Champ in-the-making
I have followed the instructions here: http://wiki.alfresco.com/wiki/Install_Extension_without_a_Compile_-_Plugin

I also have the extension-thread-bound-jcr applied as described here http://forge.alfresco.com/frs/shownotes.php?release_id=298

For a multi-valued property, property.getValues() results in "java.lang.ClassCastException: $Proxy89 cannot be cast to [Ljavax.jcr.Value;"
For a single-valued property, property.getValue() works fine.

Here is the code snippet from my jcrRmiTest.jsp:


<%@page import="java.rmi.Naming" %>
<%@page import="java.util.Properties" %>

<%@page import="javax.jcr.*" %>

<%@page import="org.apache.commons.logging.Log" %>
<%@page import="org.apache.commons.logging.LogFactory" %>

<%@page import="org.apache.jackrabbit.rmi.client.ClientAdapterFactory" %>
<%@page import="org.apache.jackrabbit.rmi.client.LocalAdapterFactory" %>
<%@page import="org.apache.jackrabbit.rmi.remote.RemoteRepository" %>

<%
     /* define locals */
      String vRmiRegistryLocation = null;
      Object vRemoteObjectReference = null;
      Repository vJcrRepository = null;
      LocalAdapterFactory vLocalAdapterFactory = null;
      Session vJcrSession = null;
      Node vJcrNode = null;
      String vRmiServerName = null;
      String vRmiServerPort = null;
      String vRmiBindingName = null;
      Properties vJcrRmiProperties = null;
     
      try
      {

         /* intitalize */
         vJcrRmiProperties = new Properties();
         vLocalAdapterFactory = new ClientAdapterFactory();
         vJcrRmiProperties.load(this.getClass().getClassLoader().getResourceAsStream("/alfresco/extension/jcr-rmi.properties"));
     
         /* get command line argments for connection parameters */
         vRmiServerName = vJcrRmiProperties.getProperty("rmi.jcr.binding.servername");
         vRmiServerPort = vJcrRmiProperties.getProperty("rmi.jcr.binding.port");
         vRmiBindingName = vJcrRmiProperties.getProperty("rmi.jcr.binding.name");

         vRmiRegistryLocation  = "//"+vRmiServerName;
         vRmiRegistryLocation += ":"+vRmiServerPort;
         vRmiRegistryLocation += "/"+vRmiBindingName;
%>
<h1>JCR RMI Test</H1></br>
<b>RMI Registery Server Name        :</b><%=vRmiServerName%></br>
<b>RMI Registery Server Name        :</b><%=vRmiServerName%></br>
<b>Remote JCR reference binding name:</b><%=vRmiBindingName%></br>
</p>
<b>Connection String:</b><%=vRmiRegistryLocation%></br>
<p>
<h2>Testing…</h2></br>
<%
         out.write("looking up remote reference at ["+vRmiRegistryLocation+"]</br>");


         vRemoteObjectReference = Naming.lookup(vRmiRegistryLocation);
        
         out.write("creating local adapter for remotereference ["+vRemoteObjectReference+"]</br>");
         vJcrRepository = vLocalAdapterFactory.getRepository((RemoteRepository)vRemoteObjectReference);
        
         out.write("logging in as admin admin to default workspace</br>");
         vJcrSession = vJcrRepository.login(new SimpleCredentials("admin", "admin".toCharArray()));

         out.write("looking up workspace root node</br>");
         vJcrNode = vJcrSession.getRootNode();
        
         Node cHome = vJcrNode.getNode("app:company_home");
         NodeIterator iter = vJcrSession.getRootNode().getNode("app:company_home").getNode("cm:TestDocs").getNodes();
         Node node = iter.nextNode();
         node = iter.nextNode();
   
         Property property = node.getProperty("mydm:sampleMultiValuedProp");
         Value[] values = property.getValues();
         out.write("node UUID ["+node.getUUID() +"]</br>");

         out.write("root node UUID ["+vJcrNode.getUUID() +"]</br>");
        
         out.write("logging out</br>");
         vJcrSession.logout();
      }
      catch(Exception eTestFailure)
      {
        
         out.write("unexpected exception encountered ["+eTestFailure+"]</br>");
      }
%>

Any pointers?
3 REPLIES 3

vgarmash
Champ in-the-making
Champ in-the-making
I have the same issue for several month. It seems to me like compilation issue:  RMI stubs were compiled with different version of JCR API than 1.0. Unfortunately inside jackrabbit-jcr-rmi-1.4.1.jar in pom.xml they not specified version of this API.


<!– Runtime dependencies –>
    <dependency>
      <groupId>javax.jcr</groupId>
      <artifactId>jcr</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.jackrabbit</groupId>
      <artifactId>jackrabbit-api</artifactId>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>org.apache.jackrabbit</groupId>
      <artifactId>jackrabbit-jcr-commons</artifactId>
    </dependency>
    <dependency>
      <groupId>xerces</groupId>
      <artifactId>xercesImpl</artifactId>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
    </dependency>

Anyway the only way to find out what is going on in there: decompile RMI stubs and look into the source code that were generated… Another way: compile jackrabbit-jcr-rmi-1.4.1.jar from sources using your Maven 2 with your dependencies: may be it will help…

baromojm
Champ in-the-making
Champ in-the-making
We're facing the same problem, using Alfresco 3.0 and jackrabbit jcr-rmi 1.4:
RuntimeExceptionjava.lang.ClassCastException: $Proxy175 cannot be cast to [Ljavax.jcr.Value;

Did you find any solution or further information?

Thanks,
José Rodríguez

baromojm
Champ in-the-making
Champ in-the-making
This is how far away I've been able to get, but I haven't been able to solve it. Any idea?

It fails in the file "jackrabbit-jcr-rmi-1.4.1.jar",
class "public class ServerProperty"
method "public Value[] getValues()"
line: return SerialValueFactory.makeSerialValueArray(property.getValues());
Error in exactly "property.getValues()"

And the stacktrace is:
javax.jcr.RepositoryException: $Proxy174 cannot be cast to [Ljavax.jcr.Value; at org.apache.jackrabbit.rmi.server.ServerObject.getRepositoryException(ServerObject.java:136) at org.apache.jackrabbit.rmi.server.ServerProperty.getValues(ServerProperty.java:78) 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 sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:305) at sun.rmi.transport.Transport$1.run(Transport.java:159) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Transport.java:155) at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619) at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:255) at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:233) at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:142) at org.apache.jackrabbit.rmi.server.ServerProperty_Stub.getValues(Unknown Source) at org.apache.jackrabbit.rmi.client.ClientProperty.getValues(ClientProperty.java:145) at dom.JcrBasicJSFManagedBean.getJcr6thHop(JcrBasicJSFManagedBean.java:60) 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.el.BeanELResolver.getValue(BeanELResolver.java:293) at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:175) at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64) at com.sun.el.parser.AstValue.getValue(AstValue.java:138) at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:206) at javax.faces.component.UIOutput.getValue(UIOutput.java:173) at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:189) at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:320) at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:200) at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:836) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:896) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892) at com.sun.faces.application.ViewHandlerImpl.doRenderView(ViewHandlerImpl.java:245) at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:176) at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106) at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251) at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245) at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:315) at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:287) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:218) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94) at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:98) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:222) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:166) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096) at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:288) at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:647) at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:579) at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:831) at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341) at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263) at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214) at com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnificationPipeline.java:380) at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265) at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)