Wednesday, December 21, 2011

ADF: Timezone not found problem

I thought I was rid of this problem but it reared its ugly  head again.

Local deployments all worked and where fine but when we copyed all our stuff over to the clustered dev server we where getting the dreaded timezone error again.

The solution and last resort was to add the following tag to the adfc-config.xml (Application Resources - Descriptors - ADF META-INF)

<user-time-zone-config xmlns="">
  <user-timezone expression="GMT+2.00"/>

JDeveloper, Weblogic: Empty server reply; No available router to destination

When trying to call a remote ejb (java client) with weblogic on another box I get the following error: t3://SERVER:7001: Destination unreachable; nested exception is: Empty server reply; No available router to destination

The solution: I just unchecked use HTTP proxy checkbox in my jdev Tools > Preferences > Web Browser And Proxy and the code work - before you make yourself mad just make sure you call is not trying to go to your web proxy.

There are many other reasons for this but hopefully this will help someone ...

Linux: set ls and vim colors

echo "colorscheme " >> ~/.vimrc

to find the color schemes -
Color schemes scripts that live in the colors/ directory of the Vim runtime hierarchy (:help runtimepath)

Alternative: press the : button when in vim and type colorscheme
Alternative to the Alternative: echo "set background=dark" >> ~/.vimrc

For ls :
dircolors -p > ~/.dir_colors

Done on RHEL

JDeveloper: JEE Web Application

I had to throw together a quick demo of the JDeveloper JEE functionality and was pleasantly surprised what Jdeveloper give you for free. Will be posting some of what I have found.

Create a New JEE Web Application and press OK button

Fill in your info here  replacing ProjectName with your project
Name: App
Package prefix: eg:
Next * 5

Now on to creating an EJB Entity: Select Entities from Tables and click ok

As we are creating the first ejb in the app you can click next on the persistance unit screen.

I am going to select the  countries and regions tables from the HR schema by selecting them and clicking the blue arrow after querying all the tables. Next.

Next Select Discover foriegn keys dynamically.

Next * 3 but take note of the info in the screens. (You can change the class and package names etc)

Now take note of the java classes created complete with annotaions and relationships very nifty.
Also take a look at the persistence.xml file created in the META-INF dir.

You have created you first next on to a session bean to expose methods on these entities. Will post this soon.

Tuesday, December 20, 2011

Development Philosophy : The Framework approach

Warning: Long blurb about what is in my head right now
Ok so I have been pondering the role of architecture and its current relevance. In some organizations it is ignored in others it is a hindrance. It is very hard to measure its impact. This is a thought that came from that exercise.

Development should not be difficult; so keep it simple for the majority of things and hide the complexity. One of the key things business wants is to be more agile and get what will add business value as quick as possible. This allows them to have a completive edge over the competition. 

As for maintenance it is a hidden cost at time of development and will cost many times more than the cost of the initial development over time. This is kind of where my passion lies bringing down the cost of maintenance and upping the speed of development.

One of the tools I use to address the above is Framework based development where you don’t just provide a blueprint but a working fully functional framework for you development team to use that provides an increase in development speed and increased maintainability. 

The responsibility for the creation of the framework once tools have been decided falls to the team. You generally don’t have much choice when it comes to toolset (.Net, Java, Oracle blah) so it is best to accept it and create the best and most productive tools around the chosen technology to make everyone’s life easier. I have never come across a tool/ product which was so mature and such a good fit that no custom development / reporting etc was needed.  That custom development should take the guise of a framework for want of a better word. A set of tools, generators, standards and code that guide a developer into creating the 80% (of the 80/20 rule) of the application and that allow development to be a simple process.

Take note: The following points will take a decidedly Java flavor but you can replace these ideas in any technology.

Prototype – You start out with a prototype that proves your ideas and structure. This is a key element to any framework because it first provides the base for what will come and addresses any technical problems. Also it allows the team to understand and embrace any new technology.

Project structure – What does your application look like what code is common and how is it structured. Do you have separate teams that work on separate parts of the system? How will it be deployed? You need to address all of these kinds of questions to get the right fit for you team and how you work.

Standards – Naming standards and code usage patterns must all be documented on a wiki.

Tools – What can you create to make the developers life easier?

Build, CI, Unit tests – Imperative to set this up as part of your framework. This will allow you to test any changes to your framework with confidence.  

Persistence, Visualization etc developer tools – Object structure to abstract the complex repetitive code. Templates to allow uniformity in UI, Custom tags. This is where the meat of any framework lies the patterns an abstractions that allow for speedy development. Things like how can you have a standard interface into your model layer. How can you ensure that Bean code is generilaized enough that a developer has to do the least amount of work.

Data store – Do you check in packages and procedures and sql stuff into version control and how is this managed.

Team structure and process – Everyone should understand the framework and why documented in wiki and how the moving parts fit together. Code reviews are helpfully keeping everything on the right track.

Monday, December 19, 2011

Development Philosophy : Development and Teams

Warning: Rant about what is in my head and random opinions to follow.

I have seen a few posts on sites disparaging developers from various nations but from my perspective I understand this but don’t agree with it. First off if you pay peanuts you get monkeys (do monkeys really like peanuts who comes up with these sayings) if you pay top dollar generally besides the charlatans you can get the best people no matter what country you are in. I have worked with awesome developers from a lot of countries but as a general rule developers tend to be crap and under-trained (by my standards) because the pervading philosophy of the day is cheap is better. I think every nation produces a small set of highly skilled developers and then the average ones. Most of those great developers have been hit by the peter principal and are no longer developers. I don’t know many great developer who are not non coding architects, development mangers etc. (Let’s start creating hero’s in every role please)

I have had the privilege of working with what I consider an uber team – well paid developers who have a passion and love developing where the company spares no expense(Nerdvana). This is an awesome experience that I suggest all developer have once in their lives because the experience is rare but fulfilling. That being said the general rule here is one or two experienced developers and a team of younger developers. This works well and I suppose is the most cost effective option but you hit a snag if one of your superstars leaves. (all great developers have their own style and you are likely to get a rewrite proposal with any new one).

I am beginning to think about the throw away system approach as an effective tool – a system with a 5 year life cycle (or when the maintenance becomes too costly). After the life cycle you redo the system in a parallel stream the downfalls of this is as you rewrite the current system changes and you have a moving target.

There must be a fair way to make sure you are getting a developer who can perform but I can’t think of something besides bad ideas [Rating system, Developer clubs, Linked in recommendations] (remember that developers all have different strengths and weaknesses so a mix of these can go a long way to a well rounded team)

Uber team – A small team of ultra experienced developers
Pros – You will have a great system, built quickly by people who know what they are doing.
Cons – There will be blood, clash of opinions and egos will be rife. Hard to focus, some developers find it hard not to create the perfect system instead of delivering. Hard to get the right balance and people.
To make this work you will need to put one person in charge and give them the power of veto or will have to lay down a framework for them to work within.

Few good men team – One or two very good developers and a team of average/ cheap/ young  
Pros – Cost effective, great hand over, growing the next generation.
Cons – Key man risk, experienced developers don’t like to share or work with idiots. Also you could end up with one or two people doing all the work.
To make this work you will need to get the key men and have a plan for when the things change. You will also have to look after your developers as the key man will have a burden of work.

Outsource developer team – Highly skilled outsource manager (technically brilliant and good with reviews and management a rare find indeed may need to split this into two people) and a team of outsource developers.
Pros – Perceived cheap, company gets to focus on their core business, no lack of resources and hr issues.
Cons – Language, process heavy, requirements need to be exacting.
To make this work – Get the right outsource partner and manager, VERY rigid process.

How to hire the best – to do this you need the best and need to not be shy about cost. In South Africa the best of developers are generally contractors. I think it is quite near to impossible to hire a developer without a highly skilled person to interview or word of mouth. Things to look for are passion, experience, track record, interests. Someone with passion will go out of the bounds of what they are currently doing to find out what the world is doing. Also generally there are a strong set of opinions that come with strong developers. But with what I have said there are just generalizations so you will have corner cases.

Whatever road you choose you will have to get the pattern right and the correct people. Good luck.

Development Philosophy : Travelling Technologist

Warning: Rant about what is in my head and how to solve the problem.

I have noticed a trend in small companies to overspend on IT items. Examples of this are buying vendor product when they are way more than they need (and open source can do). Hiring the wrong kind of people to create small systems and wasting money. Also the only options for small companies (who can afford the cost of enterprise development) is to get shoddy work from whoever they can find or to buy product.

They do not have the cash to hire someone to advise them in a permanent capacity on the technology side.

What are they looking for: Someone that is trusted with a passion for delivering the correct solution for the job. Someone with knowledge across multiple disciplines of IT who can be called on when needed to give advice and also when things go wrong.

What they are not looking for: Salesman, time and money wasters and high cost projects.

My solution to this would be to create a role for a “travelling” technologist. Someone who know what they are doing and has been vetted by some organization or council or by word of mouth(still thinking of how you could trust your technologist) . Maybe someone in the industry that operates after hours in this capacity would be ideal.

Thursday, December 15, 2011

ANT, ADF: Adding version info to my build and help about screen


I added two steps to my build (after everything was built) one to create the properties file and the other to package it:
<antcall target="create-version-property" inheritAll="true" inheritRefs="true"/>
<antcall target="inject-version-file" inheritAll="true" inheritRefs="true"/>

Creating the file.
  <target name="create-version-property">
   <-- check that the jar file is available -->
    <available file="${build.file.location}/lib/svnant.jar" property="SVN_ANT_AVAILABLE" />
        <fail unless="SVN_ANT_AVAILABLE" message="Run jar target to generate the required task"/>
       <-- load the svn ant plugin classpath -->
        <taskdef resource="org/tigris/subversion/svnant/svnantlib.xml">
                <pathelement location="${build.file.location}/lib/svnant.jar"/>
                <pathelement location="${build.file.location}/lib/svnClientAdapter.jar"/>
                <pathelement location="${build.file.location}/lib/svnjavahl.jar"/>
                <pathelement location="${build.file.location}/lib/svnkit.jar"/>
       <-- add all svn settings -->
          password="build_user_password" failonerror="true"
        <-- Get all the svn info into ant properties-->
        <svn refid="svn.settings">
          <info target="${basedir}"/>
    <-- Record deploy time in a property -->
      <format property="deploy.time" pattern="dd MMM yyyy hh:mm aa"/>
    <mkdir dir="deploy/META-INF"/>
    <-- Add all the info into a properties file -->
      comment="Version properties">
      <entry key="minor.release" value="${minor.version}" operation="+"/>
      <entry key="major.release" value="${major.version}" operation="+"/>
      <entry key="patch.release" value="${revision.version}" operation="+"/>
      <entry key="" value="${}" operation="+"/>
      <entry key="" value="${build.number}" operation="+"/>
      <entry key="deploy.time" value="${deploy.time}" operation="+"/>

Adding the file to the end artifact:
<target name="inject-version-file">
  <jar destfile="${the.jar.filename.and.location}" update="true">
      <zipfileset file="deploy/META-INF/" prefix="META-INF/"/>


I wrote a simple popup screen with all this info in with a link in our template (so it will be available on all screens).

The info is gleened from the file the following code is in the backing bean for the about screen. (This code was taken from code written by a collegue - thanks Hannes)

FacesContext fc = FacesContext.getCurrentInstance();
HttpServletRequest request = (HttpServletRequest) fc.getExternalContext().getRequest();
ServletContext servletContext = request.getSession().getServletContext();

// extract the application name from the ADFContext
String appName = ADFContext.getCurrent().getApplicationName();
if((appName != null) && (!"".equals(appName))) {
  applicationName = appName;
} else {
 applicationName = "|WesbankADF|";

String clientMachine = request.getRemoteHost();
String clientIP = request.getRemoteAddr();

InputStream is = getClass().getResourceAsStream("/META-INF/");
try {
  Properties props = new Properties();
  version =
      String.format("%s.%s.%s", props.getProperty("major.release"),
  build =
  String.format("%s (%s) @ %s", props.getProperty(""),
      props.getProperty(""), props.getProperty("deploy.time"));
} finally {

for team city users

ANT: Appending a file to a jar/war/zip

Just use the update="true" attribute
Example :
<jar destfile="${project.deploy.location}/${}.${project.type}" update="true">
  <zipfileset file="deploy/META-INF/" prefix="META-INF/"/>

  destfile - the jar file you want to add to
    project.type - this can be war/zip/ear etc the name of your artifact
    project.deploy.location the location of your artifact

  file- the file you want to add to your jar
  prefix - the prefix/location for this file inside the jar

Wednesday, December 14, 2011

ADF ADFC-12001 ControllerException pop last entry from page flow scope stack

I was getting the following error in my logs when closing a popup (everything worked though) :

Caused by: oracle.adf.controller.ControllerException: ADFC-12001: The ADF Controller is attempting to pop last entry from page flow scope stack.

I had to call my popup page directley instead of using a task flow to a resolve this.

Launch popup button:

<af:commandLink text="#{viewBundle.ABOUT_HELPABOUT_TITLE}"
  id="pt_cl21" inlineStyle="color: white; white-space: nowrap; "
  action="dialog:helpAbout" useWindow="true" windowWidth="480" windowHeight="340"
  clientComponent="true" immediate="true" windowEmbedStyle="inlineDocument"

Entry in adfc config:

  <view id="helpAbout">
  <control-flow-rule id="__8">
    <control-flow-case id="__9">     

In my popup the clode button just calls this method :

  public String doClose() throws IOException {
    AdfFacesContext.getCurrentInstance().returnFromDialog(null, null);
    return null;

Tuesday, December 13, 2011

ADF Encountered deferred syntax #{ in template text.

OracleJSP error:
Error: Encountered deferred syntax #{ in template text. 
If intended as a literal, escape it or set directive 

This normally happens when you have some tag lib dependancy problems but this was 
not the case for me...

My problem: For some reason my model project had web stuff in it(public html etc) 
so I had to remove the public html stuff from my project and manually edit the
Model.jpr project file and remove the tag lib entries at the bottom o the file.
Go figure. 


ADF flashing login page

You login page may not have the annonymous role

Monday, December 12, 2011

ADF: the oci driver

Ok so we had a requirement to check if the oci driver would work with ADF. So here are the steps I followed to get it working quite simple I think. Will post here if there are any problems with using the driver but with a quick scan test everything looks ok.

1) Installed the oracle client on our weblogic box.
2) Replaced the ojdbcdms.jar reference in the weblogic classpath with the exact version that comes with the client (VERY important)
3) changed my connection string to jdbc:oracle:oci:@

Things that will be investigated : Client side caching, speed tests, amount of connections

Notes: UnsatisfiedLinkError - ocijdbc11.dll not found
Change your path on your system to have your client library location as the first in the list - ie for me I installed my client to C:\Oracle\11.2.0\client64 so that dir must be the first entry in my path.

java.lang.UnsatisfiedLinkError: oracle.jdbc.driver.T2CConnection.getLibraryVersionNumber()IYou are using the incorrect version of the ojdbc driver make sure you are using the one that came with the client and it is the first driver weblogic loads.

Shortcut to test :
Rename this file to  ojdbc6dms.back
[your middleware install location]oracle_common\modules\oracle.jdbc_11.1.1\ojdbc6dms.jar

Copy your ojdbc6dms.jar from your client (or download from Oracle)  to the above location. Restart weblogic.

Thursday, December 8, 2011

ADF 403 Forbidden - invoke method

If you have a method call as your default activity in a task flow and you get 403 Forbidden http status code is returned (given you have set all the correct permissions in the jazn-data file to your task flow).

Just add the following tag to your taskflow (add the tag in the near the bottom of the enclosing task-flow-definition tag)


Or you can  click on the task flow overview, visibility, URL Invoke section for the same result

Monday, December 5, 2011

OJDeploy: Documentation for the tool

Real DOCS:
OJDeploy Documentation if you run it from the command line - I keep looking for this so I though I would post it here so I remeber.

Oracle JDeveloper Deploy
Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.

  ojdeploy -profile <name> -workspace <jws> [ -project <name> ] [ <options> ]
  ojdeploy -buildfile <ojbuild.xml> [ <options> ]
  ojdeploy -buildfileschema

  -profile               the name of the Profile to deploy
  -workspace      full path to the JDeveloper Workspace file(.jws)
  -project              name of the JDeveloper Project within the .jws where the Profile can be found. If omitted, the Profile is assumed to be in the Workspace.
  -buildfile            full path to a build file for batch deploy
  -buildfileschema  print XML Schema for the build file

  -basedir          interpret path for workspace relative to a base directory
  -outputfile       substitute for the output file specified in the Profile.
  -nocompile        skip compilation of Project or Workspace
  -nodependents     do not deploy dependent profiles
  -clean            clean output directories before compiling
  -nodatasources    do not include datasources from IDE
  -forcerewrite     rewrite output file even if it is identical to existing file

  -updatewebxmlejbrefs                               update EJB references in web.xml
  -define                               define variables as comma separated name=value pairs
  -statuslogfile                    full path to an output file for status summary. No macros allowed.
  -failonwarning    stop deployment on warnings
  -timeout          time in seconds allowed for each deployment task
  -stdout           redirect stdout to file
  -stderr           redirect stderr to file
  -ojserver         run deployment using ojserver
  -address          listen address for ojserver

Built-in macros:    name of the workspace (without the .jws extension)
  workspace.dir     directory of the workspace.jws file      name of the project ( without the .jpr extension).
  project.dir       directory of the project.jpr file
  Note: and project.dir are only available when project-level
  profile is being deployed.      name of the profile being deployed
  deploy.dir        default deploy directory for the profile
  base.dir          current ojdeploy directory unless overridden by the –basedir  parameter  or by the "basedir" attribute in the build script

Deploy a Project-level profile
ojdeploy -profile webapp1 -workspace /usr/jdoe/Application1/Application1.jws -pr
oject Project1
ojdeploy -profile webapp1 -workspace Application1/Application1.jws -basedir /usr
/jdoe -project Project1

Deploy a Workspace-level profile
ojdeploy -profile earprofile1 -workspace /usr/jdoe/Application1/Application1.jws

Deploy all Profiles from all Projects of a Workspace
ojdeploy -workspace /usr/jdoe/Application1/Application1.jws -project \* -profile*/

Build in batch mode from a ojbuild file
ojdeploy -buildfile /usr/jdoe/ojbuild.xml

Build using ojbuild file, pass into, or override default variables in, the build
ojdeploy -buildfile /usr/jdoe/ojbuild.xml -define myhome=/usr/jdoe,mytmp=/tmp
ojdeploy -buildfile /usr/jdoe/ojbuild.xml -basedir /usr/jdoe

Build using ojbuild file, set or override parameters in the default section
ojdeploy -buildfile /usr/jdoe/ojbuild.xml -nocompile

ojdeploy -buildfile /usr/jdoe/ojbuild.xml -outputfile '${workspace.dir}/${}.jar'
ojdeploy -buildfile /usr/jdoe/ojbuild.xml -define mydir=/tmp -outputfile  '${mydir}/${}-${}'

More examples:
ojdeploy -workspace Application1/Application1.jws,Application2/Application2.jws -basedir /home/jdoe -profile app*
ojdeploy -buildfile /usr/jdoe/ojbuild.xml -define outdir=/tmp,rel=11.1.1 -outputfile ‘${outdir}/built/${}/${rel}/${}
ojdeploy -workspace Application1/Application1.jws -basedir /home/jdoe -nocompile
-outputfile '${base.dir}/${}-${}'
ojdeploy -workspace /usr/jdoe/Application1.jws -project \* -profile \* -stdout home/jdoe/stdout/${}.log

Oracle JDeveloper Audit (6081)
Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
Audit source files.

  ojaudit option... file...

  file                 Workspace, project, or source file to audit (required).

  -classpath           Set class path for files to audit (if no project).
  -encoding            Set character encoding for report.
  -disable rule*       Disable rule in profile.
  -enable rule*        Enable rule in profile.
  -fail severity       Set issue severity to regard as failure.
  -fix                 Apply default fixes (changes source code!).            -f

  -help                Print command help (this message) and exit.            -h

  -listall             List files with no issues in report.
  -maxfilesize size    Maximum file size, in Mb, to audit.
  -notitle             Set empty report title.
  -output file         Set report file name.                                  -o

  -profile name        Set profile to use (required).                         -p

  -profilehelp         Print defined profile names and exit.
  -project file        Set project for files to audit.
  -quiet               Suppress copyright message.                            -q

  -sourcepath          Set source path for files to audit (if no project).
  -rulehelp            Print available rules and exit.
  -role name           Set active JDeveloper customization role.
  -style file          Set XSLT style sheet to apply to report.               -s

  -stylehelp           Print defined style sheet names and exit.
  -title text          Set report title.
  -verbose             Print all messages.                                    -v

  -version             Print version and exit.
  -workspace file      Set workspace context for files to audit.              -w

  -workingset name     Set working set for files to audit within workspace(s).
  -workingsethelp      Print available working sets for a workspace and exit.
* Repeat option to supply multiple values.

  Output directed to standard output unless -output specified.
  -project/-sourcepath/-classpath required unless file is workspace or project.
  -workspace required if project depends on other projects in workspace.
  -profile/-style accept name or URL, ignore case, whitespace of name.
  -enable/-disable accept rule id or label, ignore case, whitespace of label.
  Default exit status does not reflect issues detected unless -fail specified.

  ojaudit -profile auditrules test.jpr
    Audits test.jpr using (predefined) Audit Rules profile.
  ojaudit -profile auditrules -project test.jpr src\mypackage\
    Audits in project test.jpr using Audit Rules profile.
  ojaudit -profile checkinrules.xml test.jpr
    Audits test.jpr using exported profile file checkinrules.xml.
  ojaudit -profile auditrules test.jpr -style audit-text
    Audits test.jpr and applies (predefined) audit-text stylesheet to output.
  ojaudit -profile auditrules test.jpr -output test.xml
    Audits test.jpr and directs output to test.xml.

ADF : Performance Tuning

I am going through a set of performance tuning exercises and so here is my plan and set of items I will address. I hope to post results for each of these steps once I have completed them. 
1)     Build
a.     Ant (Auditing only run for CI builds)
Ojdeploy64 - 45,41,42,42 seconds
Ojdeploy - 41,40,40,39 seconds
Negligible difference but non 64 bit seems a little bit faster (non scientific one project test)
b.    Maven - my maven build tests where about 10 seconds quicker than the ojdeploy builds but this is exculding the generation of some of the custom adf files.
2)     Jdeveloper
a.     Memory
AddVMOption  -Xmx1536M
AddVMOption  -Xms512M
b.    Garbage collection
AddVMOption -XX:+AggressiveOpts
AddVMOption -XX:+UseStringCache
AddVMOption -XX:+OptimizeStringConcat
AddVMOption -XX:+UseCompressedStrings
AddVMOption -XX:+ScavengeBeforeFullGC
AddVMOption -XX:+UseConcMarkSweepGC
AddVMOption -XX:+UseGCOverheadLimit
AddVMOption -XX:+UseCompressedOops
c.     64 bit
Install jdev with 64 bit VM.
The results for this are a bit subjective but jdev runs out of memory less and feels a bit more snappy.
3)     Weblogic
b.    Memory, JVM (jrockit)
c.     Cache
d.    Data Source
e.     Production Mode
4)     OraformsFaces performance
a.     Disable logging
b.    com.commit_consulting.oraformsfaces.UNIQUE_APPLET_PER_SESSION
c.     Forms server
5)     AM
a.     Pooling and settings
b.    Nested and shared AM’s
6)     VO
a.     Tuning parameters
b.    Read/Insert only VO’s
c.     Bind variables
d.    In memory filtering
7)     EO
a.     Batch processing
b.    Associations
8)     Logging
9)     OCI Drivers
10)  JSF
a.     Caching static stuff
b.    Templates
c.     Web.xml, Trinidad-config etc settings
d.    Compression
e.     Page Load times
I have purposefully left off any performance tuning of the DB that we have done (indexes, partitioning, etc) because there is a huge body of knowledge for this stuff and I am mainly interested in the ADF side.