19 Replies Latest reply on Apr 9, 2008 8:17 PM by (himanshu_joshi)

    Error while running java code

      Hi
      I have requirement of converting word document to PDF/A. Iam using the APIs provided by Livecycle ES. I tried to implement the requirement by creating a java program with the jar files provided. But iam getting the following error. Can anyone plz help me?

      ALC-PDG-1000-000: com.adobe.livecycle.generatepdf.client.ConversionException: ALC-PDG-001-000-Conversion failed because of an exception.
      Causing exception message : Remote EJBObject lookup failed for 'ejb/Invocation'; nested exception is:
      javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
      Caused by: java.rmi.RemoteException: Remote EJBObject lookup failed for 'ejb/Invocation'; nested exception is:
      javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
      at com.adobe.idp.dsc.provider.impl.ejb.EjbMessageDispatcher.initialise(EjbMessageDispatcher. java:90)
      at com.adobe.idp.dsc.provider.impl.ejb.EjbMessageDispatcher.doSend(EjbMessageDispatcher.java :119)
      at com.adobe.idp.dsc.provider.impl.base.AbstractMessageDispatcher.send(AbstractMessageDispat cher.java:57)
      at com.adobe.idp.dsc.clientsdk.ServiceClient.invoke(ServiceClient.java:208)
      at com.adobe.livecycle.generatepdf.client.GeneratePdfServiceClient.createPDF(GeneratePdfServ iceClient.java:172)
      at Converttopdfa.main(Converttopdfa.java:44)
      Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
      at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
      at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
      at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
      at javax.naming.InitialContext.lookup(Unknown Source)
      at com.adobe.idp.dsc.provider.impl.ejb.EjbMessageDispatcher.initialise(EjbMessageDispatcher. java:84)
      ... 5 more
      Error OCCURRED: ALC-PDG-001-000-Conversion failed because of an exception.
      Causing exception message : Remote EJBObject lookup failed for 'ejb/Invocation'; nested exception is:
      javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial

      at com.adobe.livecycle.generatepdf.client.GeneratePdfServiceClient.createPDF(GeneratePdfServ iceClient.java:194)
      at Converttopdfa.main(Converttopdfa.java:44)
        • 1. Re: Error while running java code
          Level 1
          Before you can convert a Word doc to a PDF document you have to convert the Word doc to a PDF document, then convert that PDF doc to PDF/A document. You cannot go from Word -> PDF/A. In your reply - can you post you Java code and we will be able to figure out the issue.
          • 2. Re: Error while running java code
            Level 1
            Hi
            Thanks for your reply.Actually i got this error while converting a word document to pdf only. Should i have to deploy Livecycle ES successfully in websphere inorder to run the java program or is it enough if i use the jar files alone provided by them.
            • 3. Re: Error while running java code
              Level 1
              This is my java code:

              import java.io.File;
              import java.io.FileInputStream;
              import java.util.Properties;

              import com.adobe.idp.Document;
              import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
              import com.adobe.livecycle.generatepdf.client.CreatePDFResult;
              import com.adobe.livecycle.generatepdf.client.GeneratePdfServiceClient;

              public class GeneratePdf_CreatePDF {

              public static void main(String[] args)
              {

              //Specify connection properties necessary to invoke LiveCycle ES
              Properties ConnectionProps = new Properties();
              ConnectionProps.setProperty("DSC_DEFAULT_EJB_ENDPOINT", "iiop://localhost:2809 ");
              ConnectionProps.setProperty("DSC_TRANSPORT_PROTOCOL", "EJB");
              ConnectionProps.setProperty("DSC_SERVER_TYPE", "Websphere");
              ConnectionProps.setProperty("DSC_CREDENTIAL_USERNAME", "administrator");
              ConnectionProps.setProperty("DSC_CREDENTIAL_PASSWORD", "password");

              // Create a ServiceClientFactory instance
              ServiceClientFactory factory = ServiceClientFactory.createInstance(ConnectionProps);
              try{
              //Get a Microsoft Word file document to convert to a PDF document and populate a com.adobe.idp.Document object
              String inputFileName = "C:\\test.doc";
              FileInputStream fileInputStream = new FileInputStream(inputFileName);
              Document inDoc = new Document(fileInputStream);
              String adobePDFSettings = "Standard";
              String securitySettings = "No Security";
              String fileTypeSettings = "Standard";
              CreatePDFResult result = new CreatePDFResult();
              result = new GeneratePdfServiceClient(factory).createPDF(
              inDoc,
              inputFileName,
              fileTypeSettings,
              adobePDFSettings,
              securitySettings,
              null,
              null);
              //Get the newly created document
              Document createdDocument = result.getCreatedDocument();
              //Save the file
              createdDocument.copyToFile(new File("C:\\test.pdf"));
              }
              catch (Exception e) {
              System.out.println("Error OCCURRED: " + e.getMessage());
              }
              }
              }
              • 4. Re: Error while running java code
                Level 1
                The API code looks valid. WHen you install LiveCycle ES - you have to configure it to use the PDF Generator service. I will make sure that other people look at this issue to provide more insight.
                • 5. Re: Error while running java code
                  Level 1
                  Hi
                  Thanks again. My doubt is whether i should deploy LiveCycle ES successfully in websphere inorder to run this program(while deploying the EAR files, one failed out of three) or can i use the jar files and execute the program? you have mentioned that configuration is needed to use PDF generator service. Could you please how to configure that?
                  • 6. Re: Error while running java code
                    Jasmin Charbonneau Level 4
                    You need to deploy LiveCycle ES successfully in order to use the PDF Generator service properly.

                    Jasmin
                    • 7. Re: Error while running java code
                      Level 1
                      Hi
                      Thanks. While deploying the adobe-livecycle-websphere.ear file iam getting the "java.lang.OutOfMemoryError.Error is null." Can you help in rectifying this error?
                      We are Thinking that this error is because of heap size, if we are correct please do let us know how to increase the heap size.
                      We kept Initial Heap Size box as 256 and the Maximum Heap Size box 1024.Also we tried with Maximum Heap Size box as 0(Zero) but we are getting the same error. Please Help us ....
                      • 8. Re: Error while running java code
                        Jasmin Charbonneau Level 4
                        The heap size that needs to be increased is for the ejbdeploy tool located in %WAS_HOME%\deploytool\itp\ejbdeploy.bat.

                        You can set it to 512m and that should resolve your problem.

                        Jasmin
                        • 9. Re: Error while running java code
                          Level 1
                          Hi
                          Thanks a lot... I changed the heap size as you told.It worked out. But Iam getting another error related to version.Actually while installing websphere jdk 1.4 was installed by default but i have jdk1.5 in my system.I am not aware about which jdk that the application server uses. whether the following error is related to this java version? If so what can i do to proceed furthur?

                          Error generating RMI code: RMIC command failed on project: um-adminui with message:

                          error: Invalid class file format in E:\IBM\WebSphere\profiles\wp_profile\wstemp\wstemp\app_11448d1eac7\dpl\f1413a65\um-adminu i\ejbModule\com\adobe\idp\um\ui\component\AdobeIDP2UI_UMUIComponent.class. The major.minor version '49.0' is too recent for this tool to understand.

                          error: Class com.adobe.idp.um.ui.component.AdobeIDP2UI_UMUIComponent not found in class com.adobe.idp.um.ui.component.EJSRemoteStatelessAdobeIDP2UI_UMUIComponent_1712f217.

                          error: Invalid class file format in E:\IBM\WebSphere\profiles\wp_profile\wstemp\wstemp\app_11448d1eac7\dpl\f1413a65\um-adminu i\ejbModule\com\adobe\idp\um\ui\component\AdobeIDP2UI_UMUIComponentHome.class. The major.minor version '49.0' is too recent for this tool to understand.

                          error: Class com.adobe.idp.um.ui.component.AdobeIDP2UI_UMUIComponentHome not found in class com.adobe.idp.um.ui.component.EJSRemoteStatelessAdobeIDP2UI_UMUIComponentHome_1712f217.

                          4 errors
                          • 10. Re: Error while running java code
                            Level 1
                            Hi
                            Also iam using Websphere 6. Is it necessary to use websphere 6.1 inorder to deploy Livecycvle ES successfully?
                            • 11. Re: Error while running java code
                              Jasmin Charbonneau Level 4
                              Yes you need WebSphere 6.1. Refer to the following post for WebSphere/JVM specification.

                              http://www.adobeforums.com/cgi-bin/webx/.3bc4ac74/2

                              Jasmin
                              • 12. Re: Error while running java code
                                Hi,
                                I am getting this error while typecasting the ObjectInputStream in to Templates can some one help me in rectifing this error

                                java.io.InvalidClassException: org.apache.xalan.templates.ElemTemplateElement; local class incompatible: stream classdesc serialVersionUID = -8853329923984807250, local class serialVersionUID = 6953876349812108696
                                • 13. Re: Error while running java code
                                  Jasmin Charbonneau Level 4
                                  Usually that means you are using the wrong version of the client jars.

                                  Jasmin
                                  • 14. Re: Error while running java code
                                    Level 1
                                    Hi I am using the createPDF service and I am getting the following error

                                    ALC-PDG-1000-000: com.adobe.livecycle.generatepdf.client.ConversionException: ALC-PDG-001-000-Conversion failed because of an exception.
                                    RemoteException occurred in server thread; nested exception is:
                                    java.rmi.RemoteException: ; nested exception is:
                                    java.lang.IllegalStateException: Connection to failed service.

                                    I dont know why this is happening since the service is running?
                                    can anyone help.
                                    Sushant
                                    • 15. Re: Error while running java code
                                      Jasmin Charbonneau Level 4
                                      Can you convert to PDF using PDFG from the adminui (Under Services)?
                                      • 16. Re: Error while running java code
                                        has any one figured out how to fix the above problem

                                        ALC-PDG-1000-000: com.adobe.livecycle.generatepdf.client.ConversionException: ALC-PDG-001-000-Conversion failed because of an exception.
                                        RemoteException occurred in server thread; nested exception is:
                                        java.rmi.RemoteException: ; nested exception is:
                                        java.lang.IllegalStateException: Connection to failed service.
                                        • 17. Re: Error while running java code
                                          XML reading program<br /><br />package com.parser;<br />import static org.w3c.dom.Node.ATTRIBUTE_NODE;<br />import static org.w3c.dom.Node.CDATA_SECTION_NODE;<br />import static org.w3c.dom.Node.COMMENT_NODE;<br />import static org.w3c.dom.Node.DOCUMENT_TYPE_NODE;<br />import static org.w3c.dom.Node.ELEMENT_NODE;<br />import static org.w3c.dom.Node.ENTITY_NODE;<br />import static org.w3c.dom.Node.ENTITY_REFERENCE_NODE;<br />import static org.w3c.dom.Node.NOTATION_NODE;<br />import static org.w3c.dom.Node.PROCESSING_INSTRUCTION_NODE;<br />import static org.w3c.dom.Node.TEXT_NODE;<br /><br />import java.io.IOException;<br />import java.io.StringReader;<br />import java.util.ArrayList;<br />import java.util.HashMap;<br /><br />import javax.xml.parsers.DocumentBuilder;<br />import javax.xml.parsers.DocumentBuilderFactory;<br />import javax.xml.parsers.ParserConfigurationException;<br /><br />import org.w3c.dom.Document;<br />import org.w3c.dom.DocumentType;<br />import org.w3c.dom.Node;<br />import org.w3c.dom.NodeList;<br />import org.w3c.dom.Text;<br />import org.xml.sax.InputSource;<br />import org.xml.sax.SAXException;<br /><br />public class MainClass {<br />     <br />     HashMap map = new HashMap();<br />     ArrayList a = new ArrayList(10);<br />  public static void main(String args[]) {<br />    DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();<br />    builderFactory.setNamespaceAware(true);       // Set namespace aware<br />    builderFactory.setValidating(true);           // and validating parser feaures<br />    builderFactory.setIgnoringElementContentWhitespace(true); <br />    <br />    DocumentBuilder builder = null;<br />    try {<br />      builder = builderFactory.newDocumentBuilder();  // Create the parser<br />    } catch(ParserConfigurationException e) {<br />      e.printStackTrace();<br />    }<br />    Document xmlDoc = null;<br /><br />    try {<br />      xmlDoc = builder.parse(new InputSource(new StringReader(xmlString1)));<br /><br />    } catch(SAXException e) {<br />      e.printStackTrace();<br /><br />    } catch(IOException e) {<br />      e.printStackTrace();<br />    }<br />    DocumentType doctype = xmlDoc.getDoctype();       <br />    if(doctype == null) {                             <br />      System.out.println("DOCTYPE is null");<br />    } else {                                          <br />      System.out.println("DOCTYPE node:\n" + doctype.getInternalSubset());<br />    }<br /><br />    System.out.println("\nDocument body contents are:");MainClass m = new MainClass();<br />    m.listNodes(xmlDoc.getDocumentElement(),"");         // Root element & children<br />    <br />    m.abc();<br />  }<br />   public  void abc(){<br />        System.out.println("++++"+a.size());<br />        <br />        for(int i=0; i<a.size();i+=2){<br />                 map.put(a.get(i), a.get(i+1));<br />                 <br />                 <br />                 //map.put(i, i+1);<br />                 <br />                 //map.put(a.get(i), a.get(i+1));<br />            }  <br />        <br />        System.out.println("Map"+map.toString());<br />           <br />        <br />        }<br />  <br />  private void listNodes(Node node, String indent) {<br />     try{<br />          <br />       String nodeName = node.getNodeName();<br />   //System.out.println(indent+" Node: " + nodeName);<br />   // if(nodeName == "id")<br />    short type = node.getNodeType();<br />    <br />   //System.out.println(indent+" Node Type: " + nodeType(type));<br />    if(type == TEXT_NODE){<br />         <br />         <br />//         System.out.println(indent+" Node is: "+(node).getParentNode().getNodeName());<br />         if((node).getParentNode().getNodeName()== "id"){<br />              //System.out.println(indent+" Node is: "+(node).getParentNode().getNodeName());<br />              System.out.println(indent+" key is: "+((Text)node).getWholeText());<br />              a.add(((Text)node).getWholeText());<br />         }<br />         if((node).getParentNode().getNodeName()== "val"){<br />              //System.out.println(indent+" Node is: "+(node).getParentNode().getNodeName());<br />              System.out.println(indent+" value is: "+((Text)node).getWholeText());<br />              a.add(((Text)node).getWholeText());<br />         }<br />         <br />         <br />    }<br />    <br />    NodeList list = node.getChildNodes();       <br />    if(list.getLength() > 0) {                  <br />     // System.out.println(indent+" Child Nodes of "+nodeName+" are:");<br />      for(int i = 0 ; i<list.getLength() ; i++) {<br />        listNodes(list.item(i),indent+"  ");     <br />      }<br />     <br />       <br />    }      <br />     } catch(Exception e){<br />          e.printStackTrace();<br />     }<br />  }<br /><br />  static String nodeType(short type) {<br />    switch(type) {<br />      case ELEMENT_NODE:                return "Element";<br />      case DOCUMENT_TYPE_NODE:          return "Document type";<br />      case ENTITY_NODE:                 return "Entity";<br />      case ENTITY_REFERENCE_NODE:       return "Entity reference";<br />      case NOTATION_NODE:               return "Notation";<br />      case TEXT_NODE:                   return "Text";<br />      case COMMENT_NODE:                return "Comment";<br />      case CDATA_SECTION_NODE:          return "CDATA Section";<br />      case ATTRIBUTE_NODE:              return "Attribute";<br />      case PROCESSING_INSTRUCTION_NODE: return "Attribute";<br />    }<br />    return "Unidentified";<br />  }<br /><br />  static String xmlString ="<?xml version=\"1.0\"?>" +<br />      "  <!DOCTYPE address" +<br />      "  [" +<br />      "     <!ELEMENT address (buildingnumber, street, city, state, zip)>" +<br />      <br />      "     <!ELEMENT buildingnumber (#PCDATA)>" +<br />      "     <!ELEMENT street (#PCDATA)>" +<br />      "     <!ELEMENT city (#PCDATA)>" +<br />      "     <!ELEMENT state (#PCDATA)>" +<br />      "     <!ELEMENT zip (#PCDATA)>" +<br />      "  ]>" +<br />      "" +<br />      "  <address>" +<br />      "    <buildingnumber> 29 </buildingnumber>" +<br />      "    <street> South Street</street>" +<br />      "    <city>Vancouver</city>" +<br />      "" +<br />      "    <state>BC</state>" +<br />      "    <zip>V6V 4U7</zip>" +<br />      "  </address>";<br />  <br />  static String xmlString1 ="<?xml version=\"1.0\"?>" +<br />  "  <!DOCTYPE retrCtx" +<br />  "  [" +<br />  <br />    <br />  "     <!ELEMENT retrCtx (id, val)>" +<br />  <br />  "     <!ELEMENT id (#PCDATA)>" +<br />  "     <!ELEMENT val (#PCDATA)>" +<br />  "       ]>" +<br />  "" +<br />  "<retrCtx ver = '1'>" +<br />  "  <item_map type='std'>" +<br />  "    <item>" +<br />  "    <id>rtrId</id>" +<br />  "    <val>00993236327</val>" +<br />  "    </item>" +<br />  "    <item>" +<br />  "    <id>rtrId2</id>" +<br />  "    <val>009932363278</val>" +<br />  "    </item>" +<br />  "  </item_map> " +<br />  "  <item_map type='std'>" +<br />  "    <item>" +<br />  "    <id>rtrId3</id>" +<br />  "    <val>00993236329</val>" +<br />  "    </item>" +<br />  "    <item>" +<br />  "    <id>rtrId4</id>" +<br />  "    <val>009932363210</val>" +<br />  "    </item>" +<br />  "  </item_map> " +<br />  "  </retrCtx>";<br />}
                                          • 18. Re: Error while running java code
                                            Level 1
                                            static String xmlString ="<?xml version=\"1.0\"?>" +<br />      "  <!DOCTYPE address" +<br />      "  [" +<br />      "     <!ELEMENT address (buildingnumber, street, city, state, zip)>" +<br />      <br />      "     <!ELEMENT buildingnumber (#PCDATA)>" +<br />      "     <!ELEMENT street (#PCDATA)>" +<br />      "     <!ELEMENT city (#PCDATA)>" +<br />      "     <!ELEMENT state (#PCDATA)>" +<br />      "     <!ELEMENT zip (#PCDATA)>" +<br />      "  ]>" +<br />      "" +<br />      "  <address>" +<br />      "    <buildingnumber> 29 </buildingnumber>" +<br />      "    <street> South Street</street>" +<br />      "    <city>Vancouver</city>" +<br />      "" +<br />      "    <state>BC</state>" +<br />      "    <zip>V6V 4U7</zip>" +<br />      "  </address>";<br />  <br />  static String xmlString1 ="<?xml version=\"1.0\"?>" +<br />  "  <!DOCTYPE retrCtx" +<br />  "  [" +<br />  <br />    <br />  "     <!ELEMENT retrCtx (id, val)>" +<br />  <br />  "     <!ELEMENT id (#PCDATA)>" +<br />  "     <!ELEMENT val (#PCDATA)>" +<br />  "       ]>" +<br />  "" +<br />  "<retrCtx ver = '1'>" +<br />  "  <item_map type='std'>" +<br />  "    <item>" +<br />  "    <id>rtrId</id>" +<br />  "    <val>00993236327</val>" +<br />  "    </item>" +<br />  "    <item>" +<br />  "    <id>rtrId2</id>" +<br />  "    <val>009932363278</val>" +<br />  "    </item>" +<br />  "  </item_map> " +<br />  "  <item_map type='std'>" +<br />  "    <item>" +<br />  "    <id>rtrId3</id>" +<br />  "    <val>00993236329</val>" +<br />  "    </item>" +<br />  "    <item>" +<br />  "    <id>rtrId4</id>" +<br />  "    <val>009932363210</val>" +<br />  "    </item>" +<br />  "  </item_map> " +<br />  "  </retrCtx>";<br />}
                                            • 19. Re: Error while running java code
                                              Level 1
                                              HashMap map1 = new HashMap();<br />     ArrayList b = new ArrayList(10);<br />   public  void abc(){<br />           <br />        for(int i=0; i<a.size();i+=2){<br />                 map.put(a.get(i), a.get(i+1));<br />                 <br />            }  <br />        <br />        System.out.println("Map"+map.toString());<br />        for(int i=0; i<b.size();i+=2){<br />                 map1.put(b.get(i), b.get(i+1));<br />                 <br />            }  <br />        <br />        System.out.println("Map1"+map1.toString());<br />           <br />        <br />        }<br />  <br />  private void listNodes(Node node, String indent) {<br />     try{<br />          <br />       String nodeName = node.getNodeName();<br />       short type = node.getNodeType();<br /><br />    if(type == TEXT_NODE){<br />         <br />         <br />         node.getParentNode().getNodeType();<br />         if((node).getParentNode().getNodeName()== "id"){<br />              String attributeNodeName = (node).getParentNode().getParentNode().getParentNode().getNodeName();<br />             Node attributeNodeType = ((node).getParentNode().getParentNode().getParentNode()).getAttributes().getNamedItem("ty pe");<br />             if((attributeNodeName.equals("item_map")) &&  (attributeNodeType.toString().equals("type=\"std\""))){<br />                  System.out.println(indent+" key is: "+((Text)node).getWholeText());<br />                  a.add(((Text)node).getWholeText());<br />             }<br />             if((attributeNodeName.equals("item_map")) &&  (attributeNodeType.toString().equals("type=\"edd_uid\""))){<br />                  System.out.println(indent+" key is: "+((Text)node).getWholeText());<br />                  b.add(((Text)node).getWholeText());<br />             }<br />              <br />              <br />         }<br />         if((node).getParentNode().getNodeName()== "val"){<br />              String attributeNodeName = (node).getParentNode().getParentNode().getParentNode().getNodeName();<br />             Node attributeNodeType = ((node).getParentNode().getParentNode().getParentNode()).getAttributes().getNamedItem("ty pe");<br />              if((attributeNodeName.equals("item_map")) &&  (attributeNodeType.toString().equals("type=\"std\""))){<br />                  System.out.println(indent+" value is: "+((Text)node).getWholeText());<br />                  a.add(((Text)node).getWholeText());<br />             }<br />             if((attributeNodeName.equals("item_map")) &&  (attributeNodeType.toString().equals("type=\"edd_uid\""))){<br />                  System.out.println(indent+" value is: "+((Text)node).getWholeText());<br />                  b.add(((Text)node).getWholeText());<br />                  <br />             }<br />              <br />         }<br />         <br />         <br />    }<br />    <br />    NodeList list = node.getChildNodes();