Sunday, November 20, 2011

Oracle apps R12 - Compiling JSP with custom classpath

We all know that to compile JSP manually on the Oracle Application R12 instance, we need to run the file $FND_TOP/patch/115/bin/ojspCompile.pl.

Its help is as follows:

syntax: ./ojspCompile.pl COMMAND {ARGS}
COMMAND --compile               update dependency, compile delta
        --create                rebuild entire dependency file
        -delta.out       update dependency, list delta to file
        -dep.out      update dependency, output heirarchy to file

ARGS    -s      matching condition for JSPs filenames
        -p      number of parallel compilations
        -log     to override logfile from ojspCompile.conf
You are
recommended to set the log file location
 outside of any network file system shared (NFS) area/drive.
        -conf    to override ojspCompile.conf
        --retry         retry previously failed compilation attempts
        --flush         forces recompilation of all parent JSPs
        --quiet         do not provide an actively running progress meter
        --fast          instantly fail jsps that are *possibly* invalid

example1: ojspCompile.pl --compile -s 'jtf%' -p 20 --retry
example2: ojspCompile.pl --compile -s 'jtflogin.jsp,jtfavald.jsp' --flush
example3: ojspCompile.pl --compile --fast --quiet

If your JSP uses custom classes, then compiling jsp manually can fail if proper classpath is not set. Yes, even though if you have setup the classpath correctly in orion-application.xml, it will fail because this jsp compile utility does not read orion-application.xml classpath.

So, the problem is to identify where to set the classpath so that above utility can pick it up. After several search and looking into code, I found following:

By default, the jsp compiler script uses following configuration file
$INST_TOP/appl/admin/ojspCompile.conf
This conf file has a classpath field in it which is usually pointed to file
$INST_TOP/appl/admin/ojspCompile.properties
This property file lists the classpath used for JSP compilation.

So if your classes are not listed in this file, your jsps will not compile by ojspCompile.

Ofcourse, you can always set the "main_mode" to "recompile" in orion-web.xml, but that for production you do not want to change it and compile the JSP on file deployment.

References:

  1. 458338.1  How to Enable Automatic Compilation of JSP pages in R12 Environment
  2. 433386.1  JSP Pages Hanging in R12 After Removing Cached Class Files in _pages
  3. 783094.1  Compile jsp files at Application R12 at Windows

Wednesday, November 2, 2011

OC4j Configuration


Oracle application R12 release uses OC4J and during implementation, many would need to modify oc4j configuration for easier/faster development.

I found following links to be useful while changing OC4J configuration for development mode.

OC4J Web Application Redeployment and Class Reloading Features

Element Descriptions for global-web-application.xml and orion-web.xml

Key OC4J Flags for Development

Friday, October 21, 2011

Work-Offline Firefox plugin

As I was going on vacation where there is a limited internet connectivity, I thought it would be great if I could get read some of the webpages offline. But I did not want to save the pages on local manually. I found a good Firefox plugin for it - work offline.

https://addons.mozilla.org/en-US/firefox/addon/work-offline/

Its really useful - when in offline mode, it serves the page if its available in its cache - similar to what is offered by IE's Work Offline feature.
So good for the Firefox lovers.

Friday, October 14, 2011

Compressing and Decompressing String in Java using GZIP streams

Following code can be used to compress or decompress any data in Java using the GZIP streams - java's built in zip streams.
    public static String compress(String str) throws IOException {
        if (str == null || str.length() == 0) {
            return str;
        }
        System.out.println("String length : " + str.length());
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        GZIPOutputStream gzip = new GZIPOutputStream(out);
        gzip.write(str.getBytes());
        gzip.close();
        String outStr = out.toString("ISO-8859-1");
        System.out.println("Output String lenght : " + outStr.length());
        return outStr;
     }
    
    public static String decompress(String str) throws IOException {
        if (str == null || str.length() == 0) {
            return str;
        }
        System.out.println("Input String length : " + str.length());
        GZIPInputStream gis = new GZIPInputStream(new ByteArrayInputStream(str.getBytes("ISO-8859-1")));
        BufferedReader bf = new BufferedReader(new InputStreamReader(gis, "ISO-8859-1"));
        String outStr = "";
        String line;
        while ((line=bf.readLine())!=null) {
          outStr += line;
        }
        System.out.println("Output String lenght : " + outStr.length());
        return outStr;
     }
  
     public static void main(String[] args) throws IOException {
        String filePath = ".\response.txt";
        
        String string = getFileData(filePath);
        System.out.println("after compress:");
        String compressed = compress(string);
        System.out.println(compressed);
        System.out.println("after decompress:");
        String decomp = decompress(compressed);
        System.out.println(decomp);
 
      }
     
     public static String getFileData(String filepath) throws FileNotFoundException,
                                                           IOException {
       BufferedReader bf = new BufferedReader(new FileReader(filepath));
       String data="";
       String line;
       while ((line=bf.readLine())!=null) {
         data += line;
       }
       return data;
     }