Error al subir archivo mediante Webservice

cancel
Showing results for 
Search instead for 
Did you mean: 
kunkunkunkun
Member II

Error al subir archivo mediante Webservice

Hola, llevo un par de días con el asunto, y no logro sacarlo adelante, la cosa es que tengo hecho un dialog, similar al "add content" , la única diferencia, es que en vez de subir un archivo que tienes almacenado en tu PC, cuando pulsas el botón, éste maneja una clase java que llama al escáner y obtiene la imagen. (hasta ahí bien, y sencillito).
Una vez que tengo la imagen, en un bufferedimage, mi intención es que automáticamente sea subida mediante webservices. Pero pega un error que no consigo acatar Smiley Frustrated

Este es el log del error:

javax.faces.FacesException: Error calling action method of component with id dialog:dialog-body:_idJsp19
caused by:
javax.faces.el.EvaluationException: Exception while invoking expression #{formulario.guardar}
caused by:
javax.faces.FacesException: java.lang.NoClassDefFoundError: org/alfresco/webservice/types/Store
caused by:
java.lang.NoClassDefFoundError: org/alfresco/webservice/types/Store

Hide Details

javax.faces.FacesException: Error calling action method of component with id dialog:dialog-body:_idJsp19
at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)
at javax.faces.component.UICommand.broadcast(UICommand.java:109)
at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:97)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:171)
at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32)
at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:110)
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:592)
at org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(ChainingSubsystemProxyFactory.java:122)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy190.doFilter(Unknown Source)
at org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:88)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.alfresco.repo.web.filter.beans.NullFilter.doFilter(NullFilter.java:74)
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:592)
at org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(ChainingSubsystemProxyFactory.java:122)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy190.doFilter(Unknown Source)
at org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:88)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:655)
Caused by: javax.faces.el.EvaluationException: Exception while invoking expression #{formulario.guardar}
at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:168)
at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:61)
… 43 more
Caused by: javax.faces.FacesException: java.lang.NoClassDefFoundError: org/alfresco/webservice/types/Store
at org.apache.myfaces.shared_impl.util.ClassUtils.newInstance(ClassUtils.java:282)
at org.apache.myfaces.shared_impl.util.ClassUtils.newInstance(ClassUtils.java:268)
at org.apache.myfaces.config.ManagedBeanBuilder.buildManagedBean(ManagedBeanBuilder.java:49)
at org.apache.myfaces.el.VariableResolverImpl.resolveVariable(VariableResolverImpl.java:314)
at org.springframework.web.jsf.DelegatingVariableResolver.resolveVariable(DelegatingVariableResolver.java:108)
at org.alfresco.web.app.AlfrescoVariableResolver.resolveVariable(AlfrescoVariableResolver.java:94)
at org.apache.myfaces.el.ValueBindingImpl$ELVariableResolver.resolveVariable(ValueBindingImpl.java:570)
at org.apache.commons.el.NamedValue.evaluate(NamedValue.java:124)
at org.apache.myfaces.el.ValueBindingImpl.resolveToBaseAndProperty(ValueBindingImpl.java:458)
at org.apache.myfaces.el.MethodBindingImpl.resolveToBaseAndProperty(MethodBindingImpl.java:183)
at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:117)
… 44 more
Caused by: java.lang.NoClassDefFoundError: org/alfresco/webservice/types/Store
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2357)
at java.lang.Class.getConstructor0(Class.java:2671)
at java.lang.Class.newInstance0(Class.java:321)
at java.lang.Class.newInstance(Class.java:303)
at org.apache.myfaces.shared_impl.util.ClassUtils.newInstance(ClassUtils.java:277)
… 54 more

Y aquí está el código de la clase java que maneja esto:


import org.alfresco.webservice.authoring.AuthoringServiceSoapBindingStub;
import org.alfresco.webservice.authoring.CheckoutResult;
import org.alfresco.webservice.content.Content;
import org.alfresco.webservice.content.ContentServiceSoapBindingStub;
import org.alfresco.webservice.repository.RepositoryServiceSoapBindingStub;
import org.alfresco.webservice.repository.UpdateResult;
import org.alfresco.webservice.types.CML;
import org.alfresco.webservice.types.CMLAddAspect;
import org.alfresco.webservice.types.CMLCreate;
import org.alfresco.webservice.types.ContentFormat;
import org.alfresco.webservice.types.NamedValue;
import org.alfresco.webservice.types.ParentReference;
import org.alfresco.webservice.types.Predicate;
import org.alfresco.webservice.types.Reference;
import org.alfresco.webservice.types.Store;
import org.alfresco.webservice.types.Version;
import org.alfresco.webservice.types.VersionHistory;
import org.alfresco.webservice.util.AuthenticationUtils;
import org.alfresco.webservice.util.Constants;
import org.alfresco.webservice.util.ContentUtils;
import org.alfresco.webservice.util.Utils;
import org.alfresco.webservice.util.WebServiceFactory;

public class Formulario{
   
   private BufferedImage bimg;
   
    public void guardar(){
      MorenaImage morenaImage;
      MorenaSource scan;
      Image image;      
      //File file = new File("prueba.jpg");      
             
      try{         
         scan = TwainManager.selectSource(null);
            scan.setVisible(false);
           scan.setResolution(300);
           scan.setColorMode();
   
           morenaImage = new MorenaImage(scan);
           image = Toolkit.getDefaultToolkit().createImage(morenaImage);
           bimg = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_RGB);
           bimg.createGraphics().drawImage(image, 0, 0, null);
            //ImageIO.write(bimg,"jpg", file);
            uploadAlfresco();
      }
      catch(Exception e){
         e.printStackTrace();
      }
    }   

            /*————————————————————————————————–*/           
            /*****************************Subir la imagen al servidor Alfresco***********************************/
            /*————————————————————————————————–*/
   
   private void uploadAlfresco(){
      String serverhost = "http://localhost:8080/Alfresco/api";
       String user = "admin";
       String pass = "admin";
        ByteArrayOutputStream temp;
        int longitud, k;
        URL url, urlImagen;
        HttpURLConnection conexion;
        OutputStream salida;
        InputStream entrada;
           
            try{
               WebServiceFactory.setEndpointAddress(serverhost);
               AuthenticationUtils.startSession(user, pass);
            }
            catch(Exception e){
               e.printStackTrace();
            }
        try{
            //Crear la referencia al nodo padre donde se añadira el contenido
         Store store = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
            ParentReference parentReference = new ParentReference(store, null, "/app:company_home", Constants.ASSOC_CONTAINS, null);

            // Asignamos un nombre para el nodo que vamos a crea en company_home 
            String name = "Imagen (" + System.currentTimeMillis() + ")"; 
            parentReference.setChildName("cm:" + name);               

            // Comienza la construcci—n de nodo
            NamedValue[] properties = new NamedValue[1];
            properties[0] = Utils.createNamedValue(Constants.PROP_NAME, name); 
            CMLCreate create = new CMLCreate("1", parentReference, null, null, null, Constants.TYPE_CONTENT, properties);
           
            // Contruimos CML Block, con el nodo
            CML cml = new CML();
            cml.setCreate(new CMLCreate[] {create});
           
            // Creamos y recuperamos el contenido via Repository Web Service 
            UpdateResult[] result = WebServiceFactory.getRepositoryService().update(cml);
            Reference newContentNode = result[0].getDestination();            
           
            // Escribimos el contenido 
            temp = new ByteArrayOutputStream();
            ImageIO.write(bimg, "jpg", temp);
            temp.close();
           
            longitud = temp.size();
            if( longitud > 1024*1024 )
                throw new Exception("La imagen es demasiado grande");
                              
            byte[] bytes = temp.toByteArray();
           
            ContentServiceSoapBindingStub contentService = WebServiceFactory.getContentService();
            ContentFormat contentFormat = new ContentFormat("image/jpeg", "UTF-8");
            Content content = contentService.write(newContentNode, Constants.PROP_CONTENT, bytes, contentFormat);
                
            AuthenticationUtils.endSession();               
           
       }   
      catch (RemoteException e) {
            e.printStackTrace();
             }
        catch (FileNotFoundException e) {
            e.printStackTrace();
             }
        catch (Exception e) {
            e.printStackTrace();
             }
        finally
        {
            AuthenticationUtils.endSession();
        }   
   }
}   
A ver si alguien es capaz de echarme una mano Smiley Happy
Gracias!
4 Replies
kunkunkunkun
Member II

Re: Error al subir archivo mediante Webservice

Jobar me estoy volviendo loco,
Nadie tiene alguna idea?
Smiley Sad
elessar_7190
Member II

Re: Error al subir archivo mediante Webservice

Pues por la pinta (y disparando un poco a ciegas) te diría que es alguna librería, algún jar que te falte, porque te pega el casque aquí:

NoClassDefFoundError: org/alfresco/webservice/types/Store

Es decir, que no ecuentra la clase org.alfresco.webservice.types.Store

Intuyo que te la da, por esta línea de código
Store store = new Store(Constants.WORKSPACE_STORE, "SpacesStore");

Una rápida búsqueda en google me lleva aquí: http://forums.alfresco.com/en/viewtopic.php?f=27&t=27994 A ver si esto te ayuda un poco.
kunkunkunkun
Member II

Re: Error al subir archivo mediante Webservice

Qué va, he montado de nuevo todo el alfresco y empezao de cero con eclipse, y están todas las librerías.
Es raro, porque ese mismo código lo monté hace tiempo en un applet que interactuaba con alfresco y funcionaba bien.
kunkunkunkun
Member II

Re: Error al subir archivo mediante Webservice

A ver, expongo alguna novedad:
Primero, desde mi página JSP a través de un botón llamo a la clase Java.
Esta clase, llama a tu dispositivo (escaner, camara o lo que sea), recoge la imagen, y la sube al servidor Alfresco mediante webservices.

Ahora bien, si lo convierto en Applet funciona, si lo ejecuto desde eclipse, a la perfección.
Pero cuando compilo con Ant desde eclipse, arranco tomcat y alfresco, cuando pincho en el botón, nanai.

Mi pregunta, porqué desde eclipse lo ejecuto como una clase Java, se conecta al servidor alfresco y funciona perfectamente, mientras que si lo llamo desde jsp no funciona???

Llamo mal desde Jsp a la clase y su método java??

He aquí el error:
javax.faces.el.EvaluationException: Exception while invoking expression #{scan.prin}
at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:168)
at javax.faces.component.UICommand.broadcast(UICommand.java:89)
at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:97)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:171)
at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32)
at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:110)
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:592)
at org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(ChainingSubsystemProxyFactory.java:122)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy190.doFilter(Unknown Source)
at org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:88)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.alfresco.repo.web.filter.beans.NullFilter.doFilter(NullFilter.java:74)
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:592)
at org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(ChainingSubsystemProxyFactory.java:122)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy190.doFilter(Unknown Source)
at org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:88)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:655)
Caused by: javax.faces.FacesException: java.lang.NoClassDefFoundError: org/alfresco/webservice/types/Store
at org.apache.myfaces.shared_impl.util.ClassUtils.newInstance(ClassUtils.java:282)
at org.apache.myfaces.shared_impl.util.ClassUtils.newInstance(ClassUtils.java:268)
at org.apache.myfaces.config.ManagedBeanBuilder.buildManagedBean(ManagedBeanBuilder.java:49)
at org.apache.myfaces.el.VariableResolverImpl.resolveVariable(VariableResolverImpl.java:314)
at org.springframework.web.jsf.DelegatingVariableResolver.resolveVariable(DelegatingVariableResolver.java:108)
at org.alfresco.web.app.AlfrescoVariableResolver.resolveVariable(AlfrescoVariableResolver.java:94)
at org.apache.myfaces.el.ValueBindingImpl$ELVariableResolver.resolveVariable(ValueBindingImpl.java:570)
at org.apache.commons.el.NamedValue.evaluate(NamedValue.java:124)
at org.apache.myfaces.el.ValueBindingImpl.resolveToBaseAndProperty(ValueBindingImpl.java:458)
at org.apache.myfaces.el.MethodBindingImpl.resolveToBaseAndProperty(MethodBindingImpl.java:183)
at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:117)
… 43 more
Caused by: java.lang.NoClassDefFoundError: org/alfresco/webservice/types/Store
at org.alfresco.webservice.ejustice.Cliente.<clinit>(Cliente.java:50)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:501)
at java.lang.Class.newInstance0(Class.java:350)
at java.lang.Class.newInstance(Class.java:303)
at org.apache.myfaces.shared_impl.util.ClassUtils.newInstance(ClassUtils.java:277)
… 53 more

Cliente.java (simplemente se conecta mediante webservices y crea una carpeta)

/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.

* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.

* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception.  You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.webservice.ejustice;

import org.alfresco.webservice.repository.UpdateResult;
import org.alfresco.webservice.types.CML;
import org.alfresco.webservice.types.CMLCreate;
import org.alfresco.webservice.types.ContentFormat;
import org.alfresco.webservice.types.NamedValue;
import org.alfresco.webservice.types.ParentReference;
import org.alfresco.webservice.types.Predicate;
import org.alfresco.webservice.types.Reference;
import org.alfresco.webservice.types.Store;
import org.alfresco.webservice.util.Constants;
import org.alfresco.webservice.util.Utils;
import org.alfresco.webservice.util.WebServiceFactory;

/**
* @author Roy Wetherall
*/
public class Cliente
{
    /** Admin user name and password used to connect to the repository */
    protected static final String USERNAME = "admin";
    protected static final String PASSWORD = "admin";
   
    /** The store used throughout the samples */
    protected static final Store STORE = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
   
    protected static final Reference SAMPLE_FOLDER = new Reference(STORE, null, "/app:company_home/cm:ejustice");
   
    protected static void createSampleData() throws Exception
    {
        try
        {
            // Check to see if the sample folder has already been created or not
            WebServiceFactory.getRepositoryService().get(new Predicate(new Reference[]{SAMPLE_FOLDER}, STORE, null));
        }
        catch (Exception exception)
        {
            // Create parent reference to company home
            ParentReference parentReference = new ParentReference(
                    STORE,
                    null,
                    "/app:company_home",
                    Constants.ASSOC_CONTAINS,
                    Constants.createQNameString(Constants.NAMESPACE_CONTENT_MODEL, "ejustice"));

            // Create folder
            NamedValue[] properties = new NamedValue[]{Utils.createNamedValue(Constants.PROP_NAME, "Ejustice")};
            CMLCreate create = new CMLCreate("1", parentReference, null, null, null, Constants.TYPE_FOLDER, properties);
            CML cml = new CML();
            cml.setCreate(new CMLCreate[]{create});
            UpdateResult[] results = WebServiceFactory.getRepositoryService().update(cml);  
           
            // Create parent reference to sample folder
  /*          Reference sampleFolder = results[0].getDestination();
            ParentReference parentReference2 = new ParentReference(
                    STORE,
                    sampleFolder.getUuid(),
                    null,
                    Constants.ASSOC_CONTAINS,
                    Constants.createQNameString(Constants.NAMESPACE_CONTENT_MODEL, "sample_content"));
   */        
            // Create content
     /*      NamedValue[] properties2 = new NamedValue[]{Utils.createNamedValue(Constants.PROP_NAME, "SampleContent.txt")};
            CMLCreate create2 = new CMLCreate("1", parentReference2, null, null, null, Constants.TYPE_CONTENT, properties2);
            CML cml2 = new CML();
            cml2.setCreate(new CMLCreate[]{create2});
            UpdateResult[] results2 = WebServiceFactory.getRepositoryService().update(cml2); 
     */      
            // Set content
     /*       ContentFormat format = new ContentFormat(Constants.MIMETYPE_TEXT_PLAIN, "UTF-8");
            byte[] content = "This is some test content provided by the Alfresco development team!".getBytes();
            WebServiceFactory.getContentService().write(results2[0].getDestination(), Constants.PROP_CONTENT, content, format);
     */      
        }
    }
}

Luego tengo otra clase que hereda de esta, que es la que recoge la imagen y la sube… pero bueno el error lo pega aquí, a la hora de conectarse mediante WebServices.

La clase la llamo desde Jsp de la siguiente forma,

añado los imports,
<%@ page import="org.alfresco.webservice.ejustice.Cliente"%>
<%@ page import="org.alfresco.webservice.ejustice.ContentReadAndWrite"%>

y tengo un botón que me llama al método correspondiente de la clase:
<h:commandButton value="#{sms.scan}" actionListener="#{scan.prin}"/>

Me desespero Smiley Sad