2 Replies Latest reply: Nov 12, 2012 9:09 AM by Stuart Fleming RSS

    Package a Template in a jar

    Stuart Fleming
      Hello, I am on Jdeveloper 11.1.2.2. I am creating adf applications with model and view controller projects. My question is about packaging files into jars for future use in other applications.

      I created a template that has a login popup and java files that support the login. I packaged it and used the jar file in another project, but here is the issue: When I added the jar from the resource palette, a good portion of the packaged view controller was added to my new application.

      In the first application I created, there was already a view controller, I added the jar using the resource palette with no problem. However, when I added a new jsf to the new application, I got an error about duplicate cpx page.

      Duplicate cpx file
      jar: file: c:/jdev/libraries/adflibSSFTemplate.jar!
      /view/Databindings.cpx found in project classpath.

      (as I debugged this, I moved the file into a uniquely named directory (I cannot refractor the databindings.cpx) , and renamed ALL of the files and other directories associated with the template files).

      To fix this, I removed the entire view controller project and created a custom project, then used the resource palette to add the jar file. It added the following folders and files:

      Application Sources
      META-INF
      adf-settings.xml
      Web Content
      WEB-INF
      adfc-config.xml
      faces-config.xml
      trinadad-config.xml
      web.xml
      Page Flows
      adfc-config

      I added a jsf page to the project, and when creating the jsf, the template was listed. The jsf also was created with the template properly. After configuring security for the new application, I was able to log on successfully.

      HOWEVER:  Is this the best way to do it?

      The documentation says to
      1. Use unique names
      2. Remove any artifacts that I don't need to use in a new project.

      Before creating the jar file I removed the model project, and then packaged the entire view controller.

      So here is what I am wondering about creating projects that I will eventually package:
      1. Should I remove any directories and files that aren't part of my template and the login functionality? This would include files like the ones listed above (adfc-config.xml etc).
      2. Should I rename the Project and all the files and directories, so I will be able to import the jar into a standard View Controller project in a new application?

      3. Should I delete the template references from the databindings.cpx? So it won't conflict?
      I deleted the databindings.cpx, and deployed, and it gave me an error in the deployment that there was a duplicate file, which would cause problems (first time I saw this error). From the file system I found two databindings.cpx files in the project and deleted it out. FINALLY when I deployed and added this to a new application, I no longer received the duplicate cpx file. However, did I do this correctly?_


      Or is using the files that are imported when I add the jar file perfectly acceptable? In which case, I should just create custom projects for any new applications so I don't get errors about duplicate files when I import the jar.

      Is there another way? I am worried about having more than one jar to import in a project, and then referencing multiple duplicate files.

      Thank you!
      Stuart

      Edited by: Stuart Fleming on Nov 11, 2012 7:28 AM (I keep finding new lessons from various debugs)
        • 1. Re: Package a Template in a jar
          Frank Nimphius-Oracle
          Stuart,

          your problem seems to come down to a bad or missing naming convention and the use of ADF bound pages in the template project. Best practices IMO is to create a template in its own project to ensure only the objects are created that are really used by the template. In ADF a template is more than a blueprint for a layout but (see dynamic tab shell template) can also have its own behavior and binding. If you don't have a naming convention that ensures a unique packaging structure to be used with the template then the problem you face occurs as the DataBindings.cpx file is found twice and both time in the same package.

          Frank
          • 2. Re: Package a Template in a jar
            Stuart Fleming
            frank,
            thank you for the reply.

            actually, I had made it in its own project, and tried my best to place everything in unique package and name everything uniquely.

            when I right-clicked the databindings.cpx I did not see refractor on the menu, so I had to keep that the same name and location.

            I will try again.

            thank you

            stuart

            Edited by: Stuart Fleming on Nov 12, 2012 7:08 AM