salut,

je travail avec jboss7 et je veux récupérer du alfresco : ContentResult

j'ai ces jars dans mon application :

alfresco-web-service-client-4.0.d.jar,axis-1.4.jar,axis-saaj-1.2.jar,wsdl4j-1.6.2.jar,wss4j-1.5.4-patched.jar,xmlsec-1.4.1.jar
lors de test j'ai trouvé cette erreur :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
13:46:31,770 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/test].[FileUploadServlet]] (http-localhost-127.0.0.1-8080-6) "Servlet.service()" pour la servlet FileUploadServlet a généré une exception: java.lang.NoSuchMethodError: org.apache.xml.security.transforms.Transform.init()V
	at org.apache.ws.security.WSSConfig.staticInit(WSSConfig.java:244) [wss4j-1.5.4-patched.jar:]
	at org.apache.ws.security.WSSConfig.<init>(WSSConfig.java:256) [wss4j-1.5.4-patched.jar:]
	at org.apache.ws.security.WSSConfig.getNewInstance(WSSConfig.java:265) [wss4j-1.5.4-patched.jar:]
	at org.apache.ws.security.handler.WSHandler.doSenderAction(WSHandler.java:89) [wss4j-1.5.4-patched.jar:]
	at org.apache.ws.axis.security.WSDoAllSender.invoke(WSDoAllSender.java:170) [wss4j-1.5.4-patched.jar:]
	at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32) [axis-1.4.jar:]
	at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118) [axis-1.4.jar:]
	at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83) [axis-1.4.jar:]
	at org.apache.axis.client.AxisClient.invoke(AxisClient.java:127) [axis-1.4.jar:]
	at org.apache.axis.client.Call.invokeEngine(Call.java:2784) [axis-1.4.jar:]
	at org.apache.axis.client.Call.invoke(Call.java:2767) [axis-1.4.jar:]
	at org.apache.axis.client.Call.invoke(Call.java:2443) [axis-1.4.jar:]
	at org.apache.axis.client.Call.invoke(Call.java:2366) [axis-1.4.jar:]
	at org.apache.axis.client.Call.invoke(Call.java:1812) [axis-1.4.jar:]
	at org.alfresco.webservice.content.ContentServiceSoapBindingStub.read(ContentServiceSoapBindingStub.java:467) [alfresco-web-service-client-4.0.d.jar:]
	at com.dq.urbanplanning.web.ged.AlfrescoClientWS.getContentsById(AlfrescoClientWS.java:156) [classes:]
	at com.dq.urbanplanning.web.ged.DisqueFileUploader.read(DisqueFileUploader.java:55) [classes:]
	at com.nbs.tags.form.servlet.FileUploadServlet.processDownloadFile(Unknown Source) [NBS_FormTag-1.0.0.jar:]
	at com.nbs.tags.form.servlet.FileUploadServlet.service(Unknown Source) [NBS_FormTag-1.0.0.jar:]
pour le resoudre j'ai mis ce fichier jboss-deployment-structure.xml sous WEB-INF de mon application


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">
    <ear-subdeployments-isolated>true</ear-subdeployments-isolated>
    <deployment>
        <dependencies>
            <module name="deployment.javaee.api" />
        </dependencies>
        <exclusions>
            <module name="javaee.api" />
        </exclusions>
    </deployment>
    <module name="deployment.javaee.api">
        <dependencies>
            <module name="javaee.api" export="true">
                <imports>
                    <exclude path="org/apache/xml/security/**" />
                </imports>
            </module>
        </dependencies>
    </module>
</jboss-deployment-structure>

pour le test j'utilise ce code :


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
ContentResult contentResult = AlfrescoClientWS.getContentsById(docid,"HTTP://192.168.8.100:9080/alfresco/api",
                    "admin","admin");

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import org.alfresco.webservice.content.Content;
import org.alfresco.webservice.content.ContentFault;
import org.alfresco.webservice.content.ContentServiceSoapBindingStub;
import org.alfresco.webservice.repository.QueryResult;
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.Query;
import org.alfresco.webservice.types.Reference;
import org.alfresco.webservice.types.ResultSet;
import org.alfresco.webservice.types.ResultSetRow;
import org.alfresco.webservice.types.Store;
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;

import org.apache.commons.io.IOUtils;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;

import java.rmi.RemoteException;

import java.util.ArrayList;
import java.util.List;

import javax.activation.MimetypesFileTypeMap;


public class AlfrescoClientWS {

public static ContentResult getContentsById(String contentId, String cmurl, String userName, String pwd)
        throws Exception {
        ContentResult contentResult = new ContentResult();

        // Start the session
        WebServiceFactory.setEndpointAddress(cmurl);
        AuthenticationUtils.startSession(userName, pwd);

        try {
            Store storeRef = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
            ContentServiceSoapBindingStub contentService = WebServiceFactory.getContentService();

            Reference contentReference = new Reference(storeRef, contentId, null);
            Content[] readResult = null;

            try {
                readResult = contentService.read(new Predicate(new Reference[] { contentReference }, storeRef, null), Constants.PROP_CONTENT);
            } catch (ContentFault e) {
                e.printStackTrace();
            } catch (RemoteException e) {
                e.printStackTrace();
            }

            if ((readResult != null) && (readResult[0] != null)) {
                Content content = readResult[0];
                ContentFormat cnf = content.getFormat();
                Reference ref = content.getNode();

                String[] splitedUrl = content.getUrl().split("/");
                String name = splitedUrl[splitedUrl.length - 1];

                InputStream is = ContentUtils.getContentAsInputStream(content);
                byte[] contentByte = IOUtils.toByteArray(is);

                contentResult.setName(name);
                contentResult.setMimetype(cnf.getMimetype());
                contentResult.setId(ref.getUuid());
                contentResult.setUrl(content.getUrl());
                contentResult.setPath(ref.getPath());
                contentResult.setContentByte(contentByte);
                System.out.println(" document has been retrieved");
            }
        } catch (Exception e) {
            System.out.println(e.toString());
        } finally {
            // End the session
            AuthenticationUtils.endSession();

            // System.exit(0);
        }

        return contentResult;
    }

}

mais lors de test je trouve cette erreur :


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
15:26:16,334 ERROR [stderr] (http-localhost-127.0.0.1-8080-5) org.apache.xml.security.c14n.InvalidCanonicalizerException: No message with ID "signature.Canonicalizer.UnknownCanonicalizer" found in resource bundle "org/apache/xml/security/resource/xmlsecurity"

15:26:16,338 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.xml.security.c14n.Canonicalizer.<init>(Unknown Source)

15:26:16,340 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.xml.security.c14n.Canonicalizer.getInstance(Unknown Source)

15:26:16,341 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.xml.security.utils.XMLUtils.outputDOM(Unknown Source)

15:26:16,343 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.ws.axis.security.WSDoAllSender.invoke(WSDoAllSender.java:195)

15:26:16,345 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)

15:26:16,347 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)

15:26:16,348 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)

15:26:16,350 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.axis.client.AxisClient.invoke(AxisClient.java:127)

15:26:16,352 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.axis.client.Call.invokeEngine(Call.java:2784)

15:26:16,352 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.axis.client.Call.invoke(Call.java:2767)

15:26:16,354 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.axis.client.Call.invoke(Call.java:2443)

15:26:16,356 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.axis.client.Call.invoke(Call.java:2366)

15:26:16,358 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.axis.client.Call.invoke(Call.java:1812)

15:26:16,359 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.alfresco.webservice.content.ContentServiceSoapBindingStub.read(ContentServiceSoapBindingStub.java:467)

15:26:16,361 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at com.dq.test.web.ged.AlfrescoClientWS.getContentsById(AlfrescoClientWS.java:158)
l'erreur est liée à cette ligne :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
 readResult = contentService.read(new Predicate(new Reference[] { contentReference }, storeRef, null), Constants.PROP_CONTENT);


merci d'avance