Friday, November 13, 2015

Edit web.xml in Webcenter Portal 11g



We can edit web.xml for ADF application and Portal framework application directly in the JDeveloper. But, if we want to make any configuration changes for webcenter Portal (Ealry known as : Webcenter Spaces), we can edit in the webcenter.ear file.

We might require to edit web.xml for below usecases.

1.       Configure Session timeout
2.       Change the check file modification to true for reflecting the adf changes.
3.      Disabling the content compression to reflect the skinning changes

<session-config>
<session-timeout>10</session-timeout>
</session-config>

<context-param>
<description>If this parameter is true, there will be an automatic check of the modification date of your JSPs, and saved state will be discarded when JSP's change. It will also automatically check if your skinning css files have changed without you having to restart the server. This makes development easier, but adds overhead. For this reason this parameter should be set to false when your application is deployed.</description>
<param-name>org.apache.myfaces.trinidad.CHECK_FILE_MODIFICATION</param-name>
<param-value>true</param-value>
</context-param>

<context-param>
<param-name>oracle.adfinternal.view.faces.DISABLE_CONTENT_COMPRESSION</param-name>
<param-value>true</param-value>
</context-param>

Webcenter.ear file path

<WEBCENTER_HOME>\archives\applications\webcenter.ear

Example :

Windows
C:\Oracle\Middlewar_Home\Oracle_WC1\archives\applications
Linux
/u01/app/oracle/product/fmw11g/Oracle_WC1/archives/applications

Steps

1.       Copy the webcenter.war as backup. Sometimes, while restarting the server it will redirect to the error page due to the webcenter 11.1.1.4.0 in prepared stage.
2.       Open webcenter.ear file.
3.      Edit web.xml and update the entries.
4.      Repack the webcenter.ear file.
5.      Restart the webcenter Portal server (WC_Spaces)

We can extract the ear file unpack the file in two ways.

Option 1:- Linux

1.       Create the temporary folder in the linux machine and extract it.
a.      #mkdir /tmp/webcenterear
b.      #cd /tmp/webcenterear
c.       #cd /u01/app/oracle/product/fmw11g/Oracle_WC1/archives/applications/
d.      #cp webcenter.ear /tmp/webcenterear
e.      #cd /tmp/webcenterear
f.        #jar –xvf webcenter.ear
g.      #mkdir war
h.      #jar –xvf ../spaces.war
2.       Edit web.xml file
3.      Unpack the webcenter.ear after editing the files
a.      #cd /tmp/webcenterear
b.      #jar -cvf ../spaces.war *
c.       #cd ..
d.      #rm -rf war
e.      #jar -cvf ../webcenter.ear *
4.       Copy paste the the webcenter.ear file to the Webcenter Path.
a.      #cp webcenter.ear /u01/app/oracle/product/fmw11g/Oracle_WC1/archives/applications/
5.      Restart the WC_Spaces managed server

Option 2 : Windows

1.       Copy paste the webcenter.ear file
2.       Open webcenter.ear with 7 zip tool
3.      Open the spaces.war
4.      Edit web.xml and add the entries in 7 zip explorer
5.      Save the web.xml file, spaces.war and webcenter.ear file without repacking the file
6.      Copy paste the file in the respective folder
7.      Restart the webcenter space

Thursday, November 5, 2015

Error while opening JDBC connection.: Unexpected exception while enlisting XAConnection java.sql.SQLException: XA error: XAResource.XAER_RMFAIL start() failed

When we are keeping two Data Sources in Weblogic server and if both the data sources are pointing to one database, we gets this error. 

In order to resolve this issue, keep only one data source for one database so that weblogic server's multithreading system will handle the Database connection pool. If both the datasource points to same database, weblogic server works on parallel system and multiple thread will point to the dame database and connection will not be established due to the existing connection.

Friday, October 30, 2015

Webcenter Portal Language Translation using Resource Bundle

Webcenter Portal supports Resource Bundle with xlf file for specific portal. We can upload the resource bundle for entire portal and for specific portal also.


In the below section, I am following the Resource Bundle update for specific portal. Login to the webcenter portal and go to the administration for the specific portal.




Initially we can export the Portal resource bundle to local machine.

$cd Oracle_Fusion_Middleware_Home/ oracle_common/common/bin/

Example:-

$cd /oracle/fmw/oracle_common/common/bin/


wls:/offline> connect('weblogic','weblogic password','t3://hostname:7001')
exportMetadata(application='webcenter',server='WC_Spaces',toLocation='/u01',docs='/xliffBundles/SpacesSeedDataOverrideBundle.xlf,/oracle/webcenter/translations/scopedMD/<SCOPE_ID>/scope-resource-bundle.xlf')

Example

[oracle@webcenter /oracle/fmw/oracle_common/common/bin]$ ./wlst.sh
wls:/offline> connect('weblogic','welcome1','t3://webcenter.oracle.local:7001')

wls:/webcenter/serverConfig> exportMetadata(application='webcenter',server='WC_Spaces',toLocation='/u01',docs='/xliffBundles/SpacesSeedDataOverrideBundle.xlf,/oracle/webcenter/translations/scopedMD/ seed5002f_ac77_4d9a_be61_fe3369d004d1/scope-resource-bundle.xlf')
Location changed to domainRuntime tree. This is a read-only tree with DomainMBean as the root.
For more help, use help(domainRuntime)
Executing operation: exportMetadata.
Operation "exportMetadata" completed. Summary of "exportMetadata" operation is:
List of documents successfully transferred:
/oracle/webcenter/translations/scopedMD/seed5002f_ac77_4d9a_be61_fe3369d004d1/scope-resource-bundle.xlf
/xliffBundles/SpacesSeedDataOverrideBundle.xlf

2 documents successfully transferred.
wls:/webcenter/serverConfig>

Once the files are downloaded, we receives “scope-resource-bundle.xlf” file. Make a copy of the files and change the name to scope-resource-bundle_en.xlf and scope-resource-bundle_ar.xlf files.

scope-resource-bundle_en.xlf
<trans-unit id="SCOPEGUID: seed5002f_ac77_4d9a_be61_fe3369d004d1:p_attach">
<source>Attachments</source>
</trans-unit>

scope-resource-bundle_ar.xlf
<source>المرفقات</source>
</trans-unit>

Once files are updated, please copy the files in to the server file for importing it into the Webcenter Portal. 

importMetadata(application='webcenter',server='WC_Spaces',fromLocation='/u01',docs='/oracle/webcenter/translations/scopedMD/ seed5002f_ac77_4d9a_be61_fe3369d004d1/scope-resource-bundle.xlf')

importMetadata(application='webcenter',server='WC_Spaces',fromLocation='/u01',docs='/oracle/webcenter/translations/scopedMD/ seed5002f_ac77_4d9a_be61_fe3369d004d1/scope-resource-bundle_en.xlf')

importMetadata(application='webcenter',server='WC_Spaces',fromLocation='/u01',docs='/oracle/webcenter/translations/scopedMD/ seed5002f_ac77_4d9a_be61_fe3369d004d1/scope-resource-bundle_ar.xlf')

Once the scripts are loaded successfully, we gets the message that document transferred successfully. It is advisable to restart the Webcenter spaces managed server. After that , we can open the portal and can use the below expression for translation.


#{o_w_f_t_TranslationsRBBean[' SCOPEGUID: seed5002f_ac77_4d9a_be61_fe3369d004d1:p_attach ']}

Saturday, September 19, 2015

Change Oracle Database System Schema Password

We might forget the Oracle database system schema password and thus we cannot proceed to any Fusion middleware Installation. But, when we try the sys connection and it is working fine. 

Please follow the below steps to change the db schema password on such situations.

Open command prompt or sql command line.

Sqlplsus “/as sysdba”

Execute the below commands in the sql prompt.

Sql > alter user sys identified by <new_password>;
Sql > alter user system identified by <new_password>;
Sql > alter user <schema_name> identified by <new_password>;

After changing the sys and system schema passwords, we can continue the remaining tasks.

Friday, September 4, 2015

ADF Application for Consuming REST JSON Service

ADF does not support to consume the JSON response from REST service and creating the Data Control from it. Bit, we can write java code and consume the REST service in it. Once we have the response, assign it to POJO class and create data control on top of java class.


Response:-
{
    "postalcodes": [
        {
            "adminName2": "Pathanamthitta",
            "adminName3": "Adoor",
            "postalcode": "689694",
            "adminCode1": "13",
            "countryCode": "IN",
            "lng": 76.8981,
            "placeName": "Kalanjoor",
            "lat": 9.06969,
            "adminName1": "Kerala"
        },
        {
            "adminName2": "Pathanamthitta",
            "adminName3": "Adoor",
            "postalcode": "689694",
            "adminCode1": "13",
            "countryCode": "IN",
            "lng": 76.8981,
            "placeName": "Mancode",
            "lat": 9.06969,
            "adminName1": "Kerala"
        },
        {
            "adminName2": "Pathanamthitta",
            "adminName3": "Adoor",
            "postalcode": "689694",
            "adminCode1": "13",
            "countryCode": "IN",
            "lng": 76.8981,
            "placeName": "Padam",
            "lat": 9.06969,
            "adminName1": "Kerala"
        }
    ]
}

Create an ADF Application and create a Java class in Model project.

Example :-

package com.rest.service.model;

public class RestCallService {
    public RestCallService() {
        super();
    }
}

Next create a POJO class for ‘PostCodes’ in the JSON response.

Example:-

package com.rest.service.model;

public class PostalCode {
    private String adminCode3;
    private String adminName2;
    private String adminName3;
    private String adminCode2;
    private String adminName1;
    private String postalcode;
    private String adminCode1;
    private String countryCode;
    private String lng;
    private String lat;   
    private String placeName;
   
    public PostalCode() {
        super();
    }
    public void setAdminCode3(String adminCode3) {
        this.adminCode3 = adminCode3;
    }
    public String getAdminCode3() {
        return adminCode3;
    }
    public void setAdminName2(String adminName2) {
        this.adminName2 = adminName2;
    }
    public String getAdminName2() {
        return adminName2;
    }

    public void setAdminName3(String adminName3) {
        this.adminName3 = adminName3;
    }
    public String getAdminName3() {
        return adminName3;
    }
    public void setAdminCode2(String adminCode2) {
        this.adminCode2 = adminCode2;
    }
    public String getAdminCode2() {
        return adminCode2;
    }
    public void setAdminName1(String adminName1) {
        this.adminName1 = adminName1;
    }
    public String getAdminName1() {
        return adminName1;
    }
    public void setPostalcode(String postalcode) {
        this.postalcode = postalcode;
    }
    public String getPostalcode() {
        return postalcode;
    }
    public void setAdminCode1(String adminCode1) {
        this.adminCode1 = adminCode1;
    }
    public String getAdminCode1() {
        return adminCode1;
    }
    public void setCountryCode(String countryCode) {
        this.countryCode = countryCode;
    }
    public String getCountryCode() {
        return countryCode;
    }
    public void setLng(String lng) {
        this.lng = lng;
    }
    public String getLng() {
        return lng;
    }
    public void setLat(String lat) {
        this.lat = lat;
    }
    public String getLat() {
        return lat;
    }
    public void setPlaceName(String placeName) {
        this.placeName = placeName;
    }
    public String getPlaceName() {
        return placeName;
    }
}

Now, please add the code for consuming JSON Response with below code.

package com.rest.service.model;

import com.google.gson.Gson;

import com.google.gson.internal.LinkedTreeMap;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.net.HttpURLConnection;
import java.net.URL;

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

public class RestCallService {
    public RestCallService() {
        super();
    }
   
    public List<PostalCode> getPostalCodes() {
        List<PostalCode> postalCodes=new ArrayList<PostalCode>();
        try {
            URL url =
                new URL("http://api.geonames.org/postalCodeLookupJSON?postalcode=689694&country=IN&username=demo");
            HttpURLConnection conn = (HttpURLConnection)url.openConnection();
            conn.setDoOutput(true);
            conn.setRequestMethod("GET");
            conn.setRequestProperty("Content-Type", "application/json");
            BufferedReader in =
                new BufferedReader(new InputStreamReader(conn.getInputStream()));
            Gson g1 = new Gson();
            LinkedTreeMap fromJson = g1.fromJson(in, LinkedTreeMap.class);
            List<LinkedTreeMap> o =
                (ArrayList<LinkedTreeMap>)fromJson.get("postalcodes");
           System.out.println(fromJson);
            if (fromJson != null && o != null) {
                for (LinkedTreeMap node : o) {
                    PostalCode post=new PostalCode();
                    if (node != null && node.get("adminCode1") != null) {
                        post.setAdminCode1(node.get("adminCode1").toString());
                    }
                    if (node != null && node.get("adminName1") != null) {
                        post.setAdminName1(node.get("adminName1").toString());
                    }
                    if (node != null && node.get("adminCode2") != null) {
                        post.setAdminCode2(node.get("adminCode2").toString());
                    }
                    if (node != null && node.get("adminName2") != null) {
                        post.setAdminName2(node.get("adminName2").toString());
                    }
                    if (node != null && node.get("adminCode3") != null) {
                        post.setAdminCode3(node.get("adminCode3").toString());
                    }
                    if (node != null && node.get("adminName3") != null) {
                        post.setAdminName3(node.get("adminName3").toString());
                    }
                    if (node != null && node.get("postalcode") != null) {
                        post.setPostalcode(node.get("postalcode").toString());
                    }
                    if (node != null && node.get("countryCode") != null) {
                        post.setCountryCode(node.get("countryCode").toString());
                    }
                    if (node != null && node.get("lng") != null) {
                        post.setLng(node.get("lng").toString());
                    }
                    if (node != null && node.get("lat") != null) {
                        post.setLat(node.get("lat").toString());
                    }
                    if (node != null && node.get("placeName") != null) {
                        post.setPlaceName(node.get("placeName").toString());
                    }
                    postalCodes.add(post);
                }
                in.close();
            }
        }
        catch(Exception e) {
            e.printStackTrace();
        }
        return postalCodes;
    }
    public static void main(String[] args) {
        RestCallService service=new RestCallService();
        service.getPostalCodes();
    }
}

Now, right click on the Java class – “RestCallService.java” and select “Create Data Control”

Go to ViewController project and create a jspx page. Go to Data Controls sections and refresh the section. Drag and drop postalCodes from Data Control and select the option Table à ADF Read Only Table.

Add the below properties to the table to make it pagination.

autoHeightRows="0" scrollPolicy="page"

Go to the Binding section of the jspx page and select “postalCodesIterator” and select RangeSize = 5 or whatever desired size.

Example :-

<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
  <jsp:directive.page contentType="text/html;charset=UTF-8"/>
  <f:view>
    <af:document id="d1">
      <af:messages id="m1"/>
      <af:form id="f1">
        <af:panelGroupLayout id="pgl1" layout="vertical">
          <af:table value="#{bindings.postalCodes.collectionModel}" var="row"
                    rows="#{bindings.postalCodes.rangeSize}"
                    emptyText="#{bindings.postalCodes.viewable ? 'No data to display.' : 'Access Denied.'}"
                    fetchSize="#{bindings.postalCodes.rangeSize}"
                    rowBandingInterval="0"
                    selectedRowKeys="#{bindings.postalCodes.collectionModel.selectedRow}"
                    selectionListener="#{bindings.postalCodes.collectionModel.makeCurrent}"
                    rowSelection="single" id="t1" autoHeightRows="0"
                    scrollPolicy="page">
            <af:column sortProperty="#{bindings.postalCodes.hints.adminCode3.name}"
                       sortable="false"
                       headerText="#{bindings.postalCodes.hints.adminCode3.label}"
                       id="c1">
              <af:inputText value="#{row.bindings.adminCode3.inputValue}"
                            label="#{bindings.postalCodes.hints.adminCode3.label}"
                            required="#{bindings.postalCodes.hints.adminCode3.mandatory}"
                            columns="#{bindings.postalCodes.hints.adminCode3.displayWidth}"
                            maximumLength="#{bindings.postalCodes.hints.adminCode3.precision}"
                            shortDesc="#{bindings.postalCodes.hints.adminCode3.tooltip}"
                            id="it9">
                <f:validator binding="#{row.bindings.adminCode3.validator}"/>
              </af:inputText>
            </af:column>
            <af:column sortProperty="#{bindings.postalCodes.hints.adminName2.name}"
                       sortable="false"
                       headerText="#{bindings.postalCodes.hints.adminName2.label}"
                       id="c3">
              <af:inputText value="#{row.bindings.adminName2.inputValue}"
                            label="#{bindings.postalCodes.hints.adminName2.label}"
                            required="#{bindings.postalCodes.hints.adminName2.mandatory}"
                            columns="#{bindings.postalCodes.hints.adminName2.displayWidth}"
                            maximumLength="#{bindings.postalCodes.hints.adminName2.precision}"
                            shortDesc="#{bindings.postalCodes.hints.adminName2.tooltip}"
                            id="it10">
                <f:validator binding="#{row.bindings.adminName2.validator}"/>
              </af:inputText>
            </af:column>
            <af:column sortProperty="#{bindings.postalCodes.hints.adminName3.name}"
                       sortable="false"
                       headerText="#{bindings.postalCodes.hints.adminName3.label}"
                       id="c4">
              <af:inputText value="#{row.bindings.adminName3.inputValue}"
                            label="#{bindings.postalCodes.hints.adminName3.label}"
                            required="#{bindings.postalCodes.hints.adminName3.mandatory}"
                            columns="#{bindings.postalCodes.hints.adminName3.displayWidth}"
                            maximumLength="#{bindings.postalCodes.hints.adminName3.precision}"
                            shortDesc="#{bindings.postalCodes.hints.adminName3.tooltip}"
                            id="it4">
                <f:validator binding="#{row.bindings.adminName3.validator}"/>
              </af:inputText>
            </af:column>
            <af:column sortProperty="#{bindings.postalCodes.hints.adminCode2.name}"
                       sortable="false"
                       headerText="#{bindings.postalCodes.hints.adminCode2.label}"
                       id="c2">
              <af:inputText value="#{row.bindings.adminCode2.inputValue}"
                            label="#{bindings.postalCodes.hints.adminCode2.label}"
                            required="#{bindings.postalCodes.hints.adminCode2.mandatory}"
                            columns="#{bindings.postalCodes.hints.adminCode2.displayWidth}"
                            maximumLength="#{bindings.postalCodes.hints.adminCode2.precision}"
                            shortDesc="#{bindings.postalCodes.hints.adminCode2.tooltip}"
                            id="it1">
                <f:validator binding="#{row.bindings.adminCode2.validator}"/>
              </af:inputText>
            </af:column>
            <af:column sortProperty="#{bindings.postalCodes.hints.adminName1.name}"
                       sortable="false"
                       headerText="#{bindings.postalCodes.hints.adminName1.label}"
                       id="c8">
              <af:inputText value="#{row.bindings.adminName1.inputValue}"
                            label="#{bindings.postalCodes.hints.adminName1.label}"
                            required="#{bindings.postalCodes.hints.adminName1.mandatory}"
                            columns="#{bindings.postalCodes.hints.adminName1.displayWidth}"
                            maximumLength="#{bindings.postalCodes.hints.adminName1.precision}"
                            shortDesc="#{bindings.postalCodes.hints.adminName1.tooltip}"
                            id="it6">
                <f:validator binding="#{row.bindings.adminName1.validator}"/>
              </af:inputText>
            </af:column>
            <af:column sortProperty="#{bindings.postalCodes.hints.postalcode.name}"
                       sortable="false"
                       headerText="#{bindings.postalCodes.hints.postalcode.label}"
                       id="c7">
              <af:inputText value="#{row.bindings.postalcode.inputValue}"
                            label="#{bindings.postalCodes.hints.postalcode.label}"
                            required="#{bindings.postalCodes.hints.postalcode.mandatory}"
                            columns="#{bindings.postalCodes.hints.postalcode.displayWidth}"
                            maximumLength="#{bindings.postalCodes.hints.postalcode.precision}"
                            shortDesc="#{bindings.postalCodes.hints.postalcode.tooltip}"
                            id="it2">
                <f:validator binding="#{row.bindings.postalcode.validator}"/>
              </af:inputText>
            </af:column>
            <af:column sortProperty="#{bindings.postalCodes.hints.adminCode1.name}"
                       sortable="false"
                       headerText="#{bindings.postalCodes.hints.adminCode1.label}"
                       id="c11">
              <af:inputText value="#{row.bindings.adminCode1.inputValue}"
                            label="#{bindings.postalCodes.hints.adminCode1.label}"
                            required="#{bindings.postalCodes.hints.adminCode1.mandatory}"
                            columns="#{bindings.postalCodes.hints.adminCode1.displayWidth}"
                            maximumLength="#{bindings.postalCodes.hints.adminCode1.precision}"
                            shortDesc="#{bindings.postalCodes.hints.adminCode1.tooltip}"
                            id="it8">
                <f:validator binding="#{row.bindings.adminCode1.validator}"/>
              </af:inputText>
            </af:column>
            <af:column sortProperty="#{bindings.postalCodes.hints.countryCode.name}"
                       sortable="false"
                       headerText="#{bindings.postalCodes.hints.countryCode.label}"
                       id="c9">
              <af:inputText value="#{row.bindings.countryCode.inputValue}"
                            label="#{bindings.postalCodes.hints.countryCode.label}"
                            required="#{bindings.postalCodes.hints.countryCode.mandatory}"
                            columns="#{bindings.postalCodes.hints.countryCode.displayWidth}"
                            maximumLength="#{bindings.postalCodes.hints.countryCode.precision}"
                            shortDesc="#{bindings.postalCodes.hints.countryCode.tooltip}"
                            id="it3">
                <f:validator binding="#{row.bindings.countryCode.validator}"/>
              </af:inputText>
            </af:column>
            <af:column sortProperty="#{bindings.postalCodes.hints.lng.name}"
                       sortable="false"
                       headerText="#{bindings.postalCodes.hints.lng.label}"
                       id="c6">
              <af:inputText value="#{row.bindings.lng.inputValue}"
                            label="#{bindings.postalCodes.hints.lng.label}"
                            required="#{bindings.postalCodes.hints.lng.mandatory}"
                            columns="#{bindings.postalCodes.hints.lng.displayWidth}"
                            maximumLength="#{bindings.postalCodes.hints.lng.precision}"
                            shortDesc="#{bindings.postalCodes.hints.lng.tooltip}"
                            id="it11">
                <f:validator binding="#{row.bindings.lng.validator}"/>
              </af:inputText>
            </af:column>
            <af:column sortProperty="#{bindings.postalCodes.hints.lat.name}"
                       sortable="false"
                       headerText="#{bindings.postalCodes.hints.lat.label}"
                       id="c10">
              <af:inputText value="#{row.bindings.lat.inputValue}"
                            label="#{bindings.postalCodes.hints.lat.label}"
                            required="#{bindings.postalCodes.hints.lat.mandatory}"
                            columns="#{bindings.postalCodes.hints.lat.displayWidth}"
                            maximumLength="#{bindings.postalCodes.hints.lat.precision}"
                            shortDesc="#{bindings.postalCodes.hints.lat.tooltip}"
                            id="it7">
                <f:validator binding="#{row.bindings.lat.validator}"/>
              </af:inputText>
            </af:column>
            <af:column sortProperty="#{bindings.postalCodes.hints.placeName.name}"
                       sortable="false"
                       headerText="#{bindings.postalCodes.hints.placeName.label}"
                       id="c5">
              <af:inputText value="#{row.bindings.placeName.inputValue}"
                            label="#{bindings.postalCodes.hints.placeName.label}"
                            required="#{bindings.postalCodes.hints.placeName.mandatory}"
                            columns="#{bindings.postalCodes.hints.placeName.displayWidth}"
                            maximumLength="#{bindings.postalCodes.hints.placeName.precision}"
                            shortDesc="#{bindings.postalCodes.hints.placeName.tooltip}"
                            id="it5">
                <f:validator binding="#{row.bindings.placeName.validator}"/>
              </af:inputText>
            </af:column>
          </af:table>
        </af:panelGroupLayout>
      </af:form>
    </af:document>
  </f:view>
</jsp:root>


Run the application and can see the response is showing in the table with pagination.