Tuesday, February 9, 2010

How to package a project to be a shared library in WebLogic Server

How to package a project to be a shared library in WebLogic Server


If you are packaging a project and want to deploy it as a shared library in a WebLogic Server, you must wrap the ADF Library JAR with a WAR or EAR file and then install the WAR or EAR as a shared library into the Oracle WebLogic Server.



For design time usage, producers of the ADF library JAR can create a .library file that contains the paths to the ADF Library JAR files. The consuming project can add this Library file to the project's libraries and classpath. When the Library file is created, the Deploy by Default option must be deselected, otherwise the JAR paths in the Library file will be included in the user's deployment, thereby creating a runtime conflict with the same JARs in the shared library.



When the consuming application is being deployed, the dependent ADF Library JAR wrapped inside a WAR or EAR must already have been deployed to the Oracle WebLogic Server as as shared library.



Create an ADF Library JAR file.

Right-click the project and select Project Properties > Libraries and Classpath and add the ADF Library JAR file created in step 1.

Create a WAR deployment profile for the project.

Create the WAR or EAR file. If you do not have ADF Faces components in your project, add the ADF Faces technology scope to your project before you create the WAR or EAR file.

Deploy the WAR or EAR file to the WebLogic Server as a shared library using tools such as the Oracle Fusion Middleware Configuration Wizard, Enterprise Manager, or WLST scripts.

From the main menu, choose Tools > Manage Libraries.

In the Manage Libraries dialog, click Load Dir.

In the Load Directory dialog, select the directory where you want to place the Library files. This folder should be in a location next to the corresponding folder of ADF Library JAR files to simplify the process of locating files. It can even be the same folder.

In the Manage Libraries dialog, click New.

In the Create Library dialog, enter a library name and click Add Entry.

In the Select Path Entry dialog, select the libraries you want to add and click Select.

In the Create Library dialog, be sure that Deployed by Default is not selected, click OK and click OK again.

Open the Library file you created in Step 10 in a text editor and set the locked property to true and save the file.

At design time, any consuming project can reference this shared library by adding the Library file to the project using the Project Properties window.

In the Application Navigator of the consuming project, from the main menu, choose Tools > Manage Libraries.

In the Manage Libraries dialog, click Load Dir.

In the Load Directory dialog, select the directory where the Library files were created in Step 7.

In the Application Navigator of the consuming project, right-click a project and select Project Properties.

In the Project Properties window, select Libraries and Classpath and click Add Library.

In the Add Library dialog, select the Library file and click OK.

click OK.

You must edit either the WEB-INF/weblogic.xml for a WAR or the META-INF/weblogic-application.xml for an EAR to include a library-ref entry that specifies the name and version of the shared library that was produced in Step 4.

Post-deployment application configuration using ADF MBeans

If you plan to configure ADF connection information or adf-config.xml using ADF MBeans after the application has been deployed, make sure that the application is configured with MDS. The adf-config.xml file must include MDS entries, as shown in the following example. If it does not, edit the file to include them.



<adf-mds-config xmlns="http://xmlns.oracle.com/adf/mds/config">

<mds-config xmlns="http://xmlns.oracle.com/mds/config"

version="11.1.1.000">

<persistence-config>

<metadata-store-usages>

<metadata-store-usage default-cust-store="true"

deploy-target="true" id="myRepos">

</metadata-store-usage>

</metadata-store-usages>

</persistence-config>

</mds-config>

</adf-mds-config>



The web.xml file must also contain entries for each ADF MBean. The following example shows entries for three ADF MBeans.



<listener>

<listener-class>oracle.adf.mbean.share.connection.ADFConnectionLifeCycleCallBack

</listener-class>

</listener>

<listener>

<listener-class>oracle.adf.mbean.share.config.ADFConfigRuntimeLifeCycleCallBack

</listener-class>

</listener>

<listener>

<listener-class>oracle.bc4j.mbean.BC4JConfigLifeCycleCallBack

</listener-class>

</listener>



3 comments:

  1. Hi Ram,
    Nice article. I need some help in similar case.

    In my case, jars which make a library are not known in advance. But the location where they will be dropped is known.

    I would like to know, if in wls there is a way to specify a directory as a lib extension for an application.
    I know how to do it for server, using -Dweblogic.ext.dirs=/app/wls-server-lib-ext

    ReplyDelete
  2. I did not read it because it is not written in proper manner,It would be great if this article can be written in much organized manner with screenshot.

    ReplyDelete
  3. Please format it. Article is usefull but unreadable

    ReplyDelete