Expand my Community achievements bar.

SOLVED

Componet use read from repository, i have an error

Avatar

Former Community Member

Hi,

i write a componet for a Lifecycle ES2. This componet have a parameter PDFURI. This is the Uri to a PDF-File, it is save in the repository. This component is open this PDF with PDFbox - Library. I write this code to load the PDF from repository and open this to use it with PDFbox:

                         Properties connectionProps = new Properties();
                        connectionProps.setProperty("DSC_DEFAULT_EJB_ENDPOINT", "jnp://localhost:1099");
                        connectionProps.setProperty("DSC_TRANSPORT_PROTOCOL","EJB");
                        connectionProps.setProperty("DSC_SERVER_TYPE", "JBoss");
                        connectionProps.setProperty("DSC_CREDENTIAL_USERNAME", "xxxxxx");
                        connectionProps.setProperty("DSC_CREDENTIAL_PASSWORD", "xxxxxx");
                        ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);
                        ResourceRepositoryClient repositoryClient = new ResourceRepositoryClient(myFactory);
                        String resourceUri =  pdfFile;
           
                        Resource Doc = repositoryClient.readResource(resourceUri);
                        java.io.InputStream is = Doc.getContent().getDataDocument().getInputStream();
           
                        //java.io.InputStream is = new FileInputStream(pdfFile);

                        try{
                                PDFParser parser = new PDFParser(is);
                                parser.parse();
                                document = parser.getPDDocument();
                                if( document.isEncrypted() ){
                                        try{
                                                document.decrypt( "" );
                                        }
                                        catch( InvalidPasswordException e ){
                                                System.err.println( "Error: Document is encrypted with a password." );
                            //System.exit( 1 );
                                        }
                                }

I find this error at the Serverlog:

At line 80 is this:

Resource Doc = repositoryClient.readResource(resourceUri);

Have one an idea to this error? Or how can i open and load a file to use with PDFbox in a component?

Thanks

Holger Janssen

1 Accepted Solution

Avatar

Correct answer by
Level 4

Hi Holger,

I believe the snippet you posted below is part of a DSC component which is deployed on a LC server and hence running within the LC server.With that in mind you can try this

The error is happening because you are probably packaging the adobe-repository-client.jar within your component. As this jar has the Resource class it causes a conflict with the call when it reaches the Repostory service as it also has this class packaged with it. To correct it

  1. Stop packaging the adobe-repository-client.jarand referring it into the component.xml classpath
  2. Import the Resource package within your components component.xml. Refer to import-packages details. For Repository service you can find the package details on Page 8 of http://help.adobe.com/en_US/livecycle/8.2/upgrade_changes.pdf

Also from within a DSC you need not provide all those details to ServiceClientFactory. Just use ServiceClientFactory.createInstance() and things should work for you

View solution in original post

2 Replies

Avatar

Correct answer by
Level 4

Hi Holger,

I believe the snippet you posted below is part of a DSC component which is deployed on a LC server and hence running within the LC server.With that in mind you can try this

The error is happening because you are probably packaging the adobe-repository-client.jar within your component. As this jar has the Resource class it causes a conflict with the call when it reaches the Repostory service as it also has this class packaged with it. To correct it

  1. Stop packaging the adobe-repository-client.jarand referring it into the component.xml classpath
  2. Import the Resource package within your components component.xml. Refer to import-packages details. For Repository service you can find the package details on Page 8 of http://help.adobe.com/en_US/livecycle/8.2/upgrade_changes.pdf

Also from within a DSC you need not provide all those details to ServiceClientFactory. Just use ServiceClientFactory.createInstance() and things should work for you

Avatar

Former Community Member

Hi Chetan,

it runs! Great !!! Thanks!!!

Holger