Friday 23 December 2011
Preview of Oracle JDeveloper 11gR2 Cookbook, by Nick Haralabidis
The master chef who authored the recipes offers valuable advice and plenty of examples of source code, unlike other recently published ADF books who seem to target more to project managers; rather avoid exposing the reader to code. The step by step instructions are easy to follow and implement in your own project, saving you time and effort. Furthermore, the text contains quite advanced techniques about refactoring, debugging, profiling, testing and optimizing, fine-tuning and monitoring an ADF application. Such topics are not included even in ADF books written by Oracle stuff. Moreover ignorance of them has been in the past the cause of hiring external consultants and spending all project contingency funds. Nevertheless, the text only mentions using business components as the model technology and not EJBs, neither facelets. Further details about the book one can find here.
Friday 10 June 2011
Comments on EJB 3.0 Database Persistence with Oracle Fusion Middleware 11g, by Deepak Vohra
On the dark side the source code consists of orphan files, neither ears, nor whole JDeveloper workspaces; as it is usual in oracle university courses solutions. Moreover, the code seems to be what is printed in the text and has some errors. For example: in chapter 2, on page 33 the modified ejb-jar.xml deployment descriptor reads like this:
<ejb-ql>
<![CDATA[SELECT OBJECT(a) FROM CatalogBean AS a WHERE a.catalogId = ?1
</ejb-ql>
meaning that the <![CDATA[ tag is not closed properly, as it is easily understood when these lines are pasted to the editor window. In chapter 4,in CatalogTestSessionEJBBean the method is not persistEntity(catalog), but persistCatalog(catalog) and so on. After some investigation or debugging, one persistent reader will probably end up with a working application. A mistake which occurs numerous times is the number 2 missing from any sql statement with a VARCHAR2 datatype. Therefore, it seems that gathering the source code of the book was maybe only an afterthought. Furthermore, some screenshots and relevant text instructions, apply only to older versions of JDeveloper, other than the current 11.1.2. More advanced topics such as tuning, are beyond the scope of this book.
All in all, the text could be a valuable introduction to combining ejb 3 and fusion for JDeveloper funs. This is recommended for zealots of ADF business components, in order to compare both model tier technologies, especially performance. As it was written back in 2010, ejb technology has somehow superceded it. Thus, if you are a Netbeans fun, you will probably think that is an obsolete book. However, the current JDeveloper version does not seem to support ejb 3.01, so to loyal JDevepoper fanatics, it won't make any difference at all!
Monday 11 April 2011
JDeveloper 11g: Setting up the newest java development kit
First, you need first to setup the Sun 64bit jdk, then you need to edit the
C:\Oracle\Middleware\jdev_11114\jdeveloper\jdev\bin\jdev.conf file:
#
# Directive SetJavaHome is not required by default, except for the base
# install, since the launcher will determine the JAVA_HOME. On Windows
# it looks in ..\..\jdk, on UNIX it first looks in ../../jdk. If no JDK
# is found there, it looks in the PATH.
#
#SetJavaHome C:\Oracle\Middleware\jdev_11114\jdk160_21
SetJavaHome C:\Program Files\Java\jdk1.6.0_24
...
and you might get the following message the next time you start JDev
Do not overdo it! |
Finally the integrated weblogic server C:\Users\name\AppData\Roaming\JDeveloper\system11.1.1.4.37.59.23\DefaultDomain\bin\setDomainEnv.cmd script:
@ECHO OFF
@REM WARNING: This file is created by the Configuration Wizard.
@REM Any changes to this script may be lost when adding extensions to this configuration.
@REM *************************************************************************
@REM This script is used to setup the needed environment to be able to start Weblogic Server in this domain.
@REM
@REM This script initializes the following variables before calling commEnv to set other variables:
@REM
@REM WL_HOME - The BEA home directory of your WebLogic installation.
@REM JAVA_VM - The desired Java VM to use. You can set this environment variable before calling
@REM this script to switch between Sun or BEA or just have the default be set.
@REM JAVA_HOME - Location of the version of Java used to start WebLogic
@REM Server. Depends directly on which JAVA_VM value is set by default or by the environment.
@REM USER_MEM_ARGS - The variable to override the standard memory arguments
@REM passed to java.
@REM PRODUCTION_MODE - The variable that determines whether Weblogic Server is started in production mode.
@REM DOMAIN_PRODUCTION_MODE
@REM - The variable that determines whether the workshop related settings like the debugger,
@REM testconsole or iterativedev should be enabled. ONLY settable using the
@REM command-line parameter named production
@REM NOTE: Specifying the production command-line param will force
@REM the server to start in production mode.
@REM
@REM Other variables used in this script include:
@REM SERVER_NAME - Name of the weblogic server.
@REM JAVA_OPTIONS - Java command-line options for running the server. (These
@REM will be tagged on to the end of the JAVA_VM and
@REM MEM_ARGS)
@REM
@REM For additional information, refer to "Managing Server Startup and Shutdown for Oracle WebLogic Server"
@REM (http://download.oracle.com/docs/cd/E17904_01/web.1111/e13708/overview.htm).
@REM *************************************************************************
set COMMON_COMPONENTS_HOME=C:\Oracle\Middleware\jdev_11114\oracle_common
for %%i in ("%COMMON_COMPONENTS_HOME%") do set COMMON_COMPONENTS_HOME=%%~fsi
set WL_HOME=C:\Oracle\Middleware\jdev_11114\wlserver_10.3
for %%i in ("%WL_HOME%") do set WL_HOME=%%~fsi
set BEA_JAVA_HOME=
@REM On 16.3.2011 added C:\Program Files\Java\jdk1.6.0_24 instead of C:\Oracle\Middleware\jdev_11114\jdk160_21
set SUN_JAVA_HOME= C:\Program Files\Java\jdk1.6.0_24
if "%JAVA_VENDOR%"=="Oracle" (
set JAVA_HOME=%BEA_JAVA_HOME%
) else (
if "%JAVA_VENDOR%"=="Sun" (
set JAVA_HOME=%SUN_JAVA_HOME%
) else (
set JAVA_VENDOR=Sun
@REM On 16.3.2011 added C:\Program Files\Java\jdk1.6.0_24 instead of C:\Oracle\Middleware\jdev_11114\jdk160_21
set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_24
)
)
@REM We need to reset the value of JAVA_HOME to get it shortened AND
@REM we can not shorten it above because immediate variable expansion will blank it
set JAVA_HOME=%JAVA_HOME%
for %%i in ("%JAVA_HOME%") do set JAVA_HOME=%%~fsi
set SAMPLES_HOME=%WL_HOME%\samples
set DOMAIN_HOME=C:\Users\Nick\AppData\Roaming\JDeveloper\system11.1.1.4.37.59.23\DefaultDomain
for %%i in ("%DOMAIN_HOME%") do set DOMAIN_HOME=%%~fsi
set LONG_DOMAIN_HOME=C:\Users\Nick\AppData\Roaming\JDeveloper\system11.1.1.4.37.59.23\DefaultDomain
if "%DEBUG_PORT%"=="" (
set DEBUG_PORT=8453
)
if "%SERVER_NAME%"=="" (
set SERVER_NAME=DefaultServer
)
set DERBY_FLAG=false
set enableHotswapFlag=
set PRODUCTION_MODE=
set doExitFlag=false
set verboseLoggingFlag=false
for %%p in (%*) do call :SET_PARAM %%p
GOTO :CMD_LINE_DONE
:SET_PARAM
for %%q in (%1) do set noQuotesParam=%%~q
if /i "%noQuotesParam%" == "nodebug" (
set debugFlag=false
GOTO :EOF
)
if /i "%noQuotesParam%" == "production" (
set DOMAIN_PRODUCTION_MODE=true
GOTO :EOF
)
if /i "%noQuotesParam%" == "notestconsole" (
set testConsoleFlag=false
GOTO :EOF
)
if /i "%noQuotesParam%" == "noiterativedev" (
set iterativeDevFlag=false
GOTO :EOF
)
if /i "%noQuotesParam%" == "noLogErrorsToConsole" (
set logErrorsToConsoleFlag=false
GOTO :EOF
)
if /i "%noQuotesParam%" == "noderby" (
set DERBY_FLAG=false
GOTO :EOF
)
if /i "%noQuotesParam%" == "doExit" (
set doExitFlag=true
GOTO :EOF
)
if /i "%noQuotesParam%" == "noExit" (
set doExitFlag=false
GOTO :EOF
)
if /i "%noQuotesParam%" == "verbose" (
set verboseLoggingFlag=true
GOTO :EOF
)
if /i "%noQuotesParam%" == "enableHotswap" (
set enableHotswapFlag=-javaagent:%WL_HOME%\server\lib\diagnostics-agent.jar
GOTO :EOF
) else (
set PROXY_SETTINGS=%PROXY_SETTINGS% %1
)
GOTO :EOF
:CMD_LINE_DONE
set MEM_DEV_ARGS=
if "%DOMAIN_PRODUCTION_MODE%"=="true" (
set PRODUCTION_MODE=%DOMAIN_PRODUCTION_MODE%
)
if "%PRODUCTION_MODE%"=="true" (
set debugFlag=false
set testConsoleFlag=false
set iterativeDevFlag=false
set logErrorsToConsoleFlag=false
)
@REM If you want to override the default Patch Classpath, Library Path and Path for this domain,
@REM Please uncomment the following lines and add a valid value for the environment variables
@REM set PATCH_CLASSPATH=[myPatchClasspath] (windows)
@REM set PATCH_LIBPATH=[myPatchLibpath] (windows)
@REM set PATCH_PATH=[myPatchPath] (windows)
@REM PATCH_CLASSPATH=[myPatchClasspath] (unix)
@REM PATCH_LIBPATH=[myPatchLibpath] (unix)
@REM PATCH_PATH=[myPatchPath] (unix)
call "%WL_HOME%\common\bin\commEnv.cmd"
set WLS_HOME=%WL_HOME%\server
set XMS_SUN_64BIT=256
set XMS_SUN_32BIT=256
set XMX_SUN_64BIT=512
set XMX_SUN_32BIT=512
set XMS_JROCKIT_64BIT=256
set XMS_JROCKIT_32BIT=256
set XMX_JROCKIT_64BIT=512
set XMX_JROCKIT_32BIT=512
if "%JAVA_VENDOR%"=="Sun" (
set WLS_MEM_ARGS_64BIT=-Xms256m -Xmx512m
set WLS_MEM_ARGS_32BIT=-Xms256m -Xmx512m
) else (
set WLS_MEM_ARGS_64BIT=-Xms512m -Xmx512m
set WLS_MEM_ARGS_32BIT=-Xms512m -Xmx512m
)
if "%JAVA_VENDOR%"=="Oracle" (
set CUSTOM_MEM_ARGS_64BIT=-Xms%XMS_JROCKIT_64BIT%m -Xmx%XMX_JROCKIT_64BIT%m
set CUSTOM_MEM_ARGS_32BIT=-Xms%XMS_JROCKIT_32BIT%m -Xmx%XMX_JROCKIT_32BIT%m
) else (
set CUSTOM_MEM_ARGS_64BIT=-Xms%XMS_SUN_64BIT%m -Xmx%XMX_SUN_64BIT%m
set CUSTOM_MEM_ARGS_32BIT=-Xms%XMS_SUN_32BIT%m -Xmx%XMX_SUN_32BIT%m
)
set MEM_ARGS_64BIT=%CUSTOM_MEM_ARGS_64BIT%
set MEM_ARGS_32BIT=%CUSTOM_MEM_ARGS_32BIT%
if "%JAVA_USE_64BIT%"=="true" (
set MEM_ARGS=%MEM_ARGS_64BIT%
) else (
set MEM_ARGS=%MEM_ARGS_32BIT%
)
set MEM_PERM_SIZE_64BIT=-XX:PermSize=128m
set MEM_PERM_SIZE_32BIT=-XX:PermSize=128m
if "%JAVA_USE_64BIT%"=="true" (
set MEM_PERM_SIZE=%MEM_PERM_SIZE_64BIT%
) else (
set MEM_PERM_SIZE=%MEM_PERM_SIZE_32BIT%
)
set MEM_MAX_PERM_SIZE_64BIT=-XX:MaxPermSize=512m
set MEM_MAX_PERM_SIZE_32BIT=-XX:MaxPermSize=512m
if "%JAVA_USE_64BIT%"=="true" (
set MEM_MAX_PERM_SIZE=%MEM_MAX_PERM_SIZE_64BIT%
) else (
set MEM_MAX_PERM_SIZE=%MEM_MAX_PERM_SIZE_32BIT%
)
if "%JAVA_VENDOR%"=="Sun" (
if "%PRODUCTION_MODE%"=="" (
set MEM_DEV_ARGS=-XX:CompileThreshold=8000 %MEM_PERM_SIZE%
)
)
@REM Had to have a separate test here BECAUSE of immediate variable expansion on windows
if "%JAVA_VENDOR%"=="Sun" (
set MEM_ARGS=%MEM_ARGS% %MEM_DEV_ARGS% %MEM_MAX_PERM_SIZE%
)
if "%JAVA_VENDOR%"=="HP" (
set MEM_ARGS=%MEM_ARGS% %MEM_MAX_PERM_SIZE%
)
if "%JAVA_VENDOR%"=="Apple" (
set MEM_ARGS=%MEM_ARGS% %MEM_MAX_PERM_SIZE%
)
@REM IF USER_MEM_ARGS the environment variable is set, use it to override ALL MEM_ARGS values
if NOT "%USER_MEM_ARGS%"=="" (
set MEM_ARGS=%USER_MEM_ARGS%
)
set ORACLE_DOMAIN_CONFIG_DIR=%DOMAIN_HOME%\config\fmwconfig
for %%i in ("%ORACLE_DOMAIN_CONFIG_DIR%") do set ORACLE_DOMAIN_CONFIG_DIR=%%~fsi
set WLS_JDBC_REMOTE_ENABLED=-Dweblogic.jdbc.remoteEnabled=false
set JAVA_PROPERTIES=-Dplatform.home=%WL_HOME% -Dwls.home=%WLS_HOME% -Dweblogic.home=%WLS_HOME%
set ALT_TYPES_DIR=%COMMON_COMPONENTS_HOME%\modules\oracle.ossoiap_11.1.1,%COMMON_COMPONENTS_HOME%\modules\oracle.oamprovider_11.1.1
set PROTOCOL_HANDLERS=oracle.mds.net.protocol
set PROTOCOL_HANDLERS=%PROTOCOL_HANDLERS:;="|"%
@REM To use Java Authorization Contract for Containers (JACC) in this domain,
@REM please uncomment the following section. If there are multiple machines in
@REM your domain, be sure to edit the setDomainEnv in the associated domain on
@REM each machine.
@REM
@REM -Djava.security.manager
@REM -Djava.security.policy=location of weblogic.policy
@REM -Djavax.security.jacc.policy.provider=weblogic.security.jacc.simpleprovider.SimpleJACCPolicy
@REM -Djavax.security.jacc.PolicyConfigurationFactory.provider=weblogic.security.jacc.simpleprovider.PolicyConfigurationFactoryImpl
@REM -Dweblogic.security.jacc.RoleMapperFactory.provider=weblogic.security.jacc.simpleprovider.RoleMapperFactoryImpl
set EXTRA_JAVA_PROPERTIES=-Dwsm.repository.path=%DOMAIN_HOME%\oracle\store\gmds %EXTRA_JAVA_PROPERTIES%
set EXTRA_JAVA_PROPERTIES=-Dcommon.components.home=%COMMON_COMPONENTS_HOME% -Djrf.version=11.1.1 -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger -Ddomain.home=%DOMAIN_HOME% -Djrockit.optfile=%COMMON_COMPONENTS_HOME%\modules\oracle.jrf_11.1.1\jrocket_optfile.txt -Doracle.server.config.dir=%ORACLE_DOMAIN_CONFIG_DIR%\servers\%SERVER_NAME% -Doracle.domain.config.dir=%ORACLE_DOMAIN_CONFIG_DIR% -Digf.arisidbeans.carmlloc=%ORACLE_DOMAIN_CONFIG_DIR%\carml -Digf.arisidstack.home=%ORACLE_DOMAIN_CONFIG_DIR%\arisidprovider -Doracle.security.jps.config=%DOMAIN_HOME%\config\fmwconfig\jps-config.xml -Doracle.deployed.app.dir=%DOMAIN_HOME%\servers\%SERVER_NAME%\tmp\_WL_user -Doracle.deployed.app.ext=\- -Dweblogic.alternateTypesDirectory=%ALT_TYPES_DIR% -Djava.protocol.handler.pkgs=%PROTOCOL_HANDLERS% %WLS_JDBC_REMOTE_ENABLED% %EXTRA_JAVA_PROPERTIES%
set EXTRA_JAVA_PROPERTIES=-Djps.app.credential.overwrite.allowed=true %EXTRA_JAVA_PROPERTIES%
set JAVA_PROPERTIES=%JAVA_PROPERTIES% %EXTRA_JAVA_PROPERTIES%
set ARDIR=%WL_HOME%\server\lib
pushd %LONG_DOMAIN_HOME%
@REM Clustering support (edit for your cluster!)
if "%ADMIN_URL%"=="" (
@REM The then part of this block is telling us we are either starting an admin server OR we are non-clustered
set CLUSTER_PROPERTIES=-Dweblogic.management.discover=true
) else (
set CLUSTER_PROPERTIES=-Dweblogic.management.discover=false -Dweblogic.management.server=%ADMIN_URL%
)
if NOT "%LOG4J_CONFIG_FILE%"=="" (
set JAVA_PROPERTIES=%JAVA_PROPERTIES% -Dlog4j.configuration=file:%LOG4J_CONFIG_FILE%
)
set JAVA_PROPERTIES=%JAVA_PROPERTIES% %CLUSTER_PROPERTIES%
set JAVA_DEBUG=
if "%debugFlag%"=="true" (
set JAVA_DEBUG=-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=%DEBUG_PORT%,server=y,suspend=n -Djava.compiler=NONE
set JAVA_OPTIONS=%JAVA_OPTIONS% %enableHotswapFlag% -ea -da:com.bea... -da:javelin... -da:weblogic... -ea:com.bea.wli... -ea:com.bea.broker... -ea:com.bea.sbconsole...
) else (
set JAVA_OPTIONS=%JAVA_OPTIONS% %enableHotswapFlag% -da
)
if NOT exist %JAVA_HOME%\lib (
echo The JRE was not found in directory %JAVA_HOME%. ^(JAVA_HOME^)
echo Please edit your environment and set the JAVA_HOME
echo variable to point to the root directory of your Java installation.
popd
pause
GOTO :EOF
)
if "%DERBY_FLAG%"=="true" (
set DATABASE_CLASSPATH=%DERBY_CLASSPATH%
) else (
set DATABASE_CLASSPATH=%DERBY_CLIENT_CLASSPATH%
)
if NOT "%POST_CLASSPATH%"=="" (
set POST_CLASSPATH=%COMMON_COMPONENTS_HOME%\modules\oracle.jrf_11.1.1\jrf.jar;%POST_CLASSPATH%
) else (
set POST_CLASSPATH=%COMMON_COMPONENTS_HOME%\modules\oracle.jrf_11.1.1\jrf.jar
)
if NOT "%PRE_CLASSPATH%"=="" (
set PRE_CLASSPATH=%COMMON_COMPONENTS_HOME%\modules\oracle.jdbc_11.1.1\ojdbc6dms.jar;%PRE_CLASSPATH%
) else (
set PRE_CLASSPATH=%COMMON_COMPONENTS_HOME%\modules\oracle.jdbc_11.1.1\ojdbc6dms.jar
)
if NOT "%DATABASE_CLASSPATH%"=="" (
if NOT "%POST_CLASSPATH%"=="" (
set POST_CLASSPATH=%POST_CLASSPATH%;%DATABASE_CLASSPATH%
) else (
set POST_CLASSPATH=%DATABASE_CLASSPATH%
)
)
if NOT "%ARDIR%"=="" (
if NOT "%POST_CLASSPATH%"=="" (
set POST_CLASSPATH=%POST_CLASSPATH%;%ARDIR%\xqrl.jar
) else (
set POST_CLASSPATH=%ARDIR%\xqrl.jar
)
)
@REM PROFILING SUPPORT
set JAVA_PROFILE=
set SERVER_CLASS=weblogic.Server
set JAVA_PROPERTIES=%JAVA_PROPERTIES% %WLP_JAVA_PROPERTIES%
set JAVA_OPTIONS=%JAVA_OPTIONS% %JAVA_PROPERTIES% -Dwlw.iterativeDev=%iterativeDevFlag% -Dwlw.testConsole=%testConsoleFlag% -Dwlw.logErrorsToConsole=%logErrorsToConsoleFlag%
if "%PRODUCTION_MODE%"=="true" (
set JAVA_OPTIONS= -Dweblogic.ProductionModeEnabled=true %JAVA_OPTIONS%
)
@REM -- Setup properties so that we can save stdout and stderr to files
if NOT "%WLS_STDOUT_LOG%"=="" (
echo Logging WLS stdout to %WLS_STDOUT_LOG%
set JAVA_OPTIONS=%JAVA_OPTIONS% -Dweblogic.Stdout=%WLS_STDOUT_LOG%
)
if NOT "%WLS_STDERR_LOG%"=="" (
echo Logging WLS stderr to %WLS_STDERR_LOG%
set JAVA_OPTIONS=%JAVA_OPTIONS% -Dweblogic.Stderr=%WLS_STDERR_LOG%
)
@REM ADD EXTENSIONS TO CLASSPATHS
if NOT "%EXT_PRE_CLASSPATH%"=="" (
if NOT "%PRE_CLASSPATH%"=="" (
set PRE_CLASSPATH=%EXT_PRE_CLASSPATH%;%PRE_CLASSPATH%
) else (
set PRE_CLASSPATH=%EXT_PRE_CLASSPATH%
)
)
if NOT "%EXT_POST_CLASSPATH%"=="" (
if NOT "%POST_CLASSPATH%"=="" (
set POST_CLASSPATH=%POST_CLASSPATH%;%EXT_POST_CLASSPATH%
) else (
set POST_CLASSPATH=%EXT_POST_CLASSPATH%
)
)
if NOT "%WEBLOGIC_EXTENSION_DIRS%"=="" (
set JAVA_OPTIONS=%JAVA_OPTIONS% -Dweblogic.ext.dirs=%WEBLOGIC_EXTENSION_DIRS%
)
set JAVA_OPTIONS=%JAVA_OPTIONS%
@REM SET THE CLASSPATH
if NOT "%WLP_POST_CLASSPATH%"=="" (
if NOT "%CLASSPATH%"=="" (
set CLASSPATH=%WLP_POST_CLASSPATH%;%CLASSPATH%
) else (
set CLASSPATH=%WLP_POST_CLASSPATH%
)
)
if NOT "%POST_CLASSPATH%"=="" (
if NOT "%CLASSPATH%"=="" (
set CLASSPATH=%POST_CLASSPATH%;%CLASSPATH%
) else (
set CLASSPATH=%POST_CLASSPATH%
)
)
if NOT "%WEBLOGIC_CLASSPATH%"=="" (
if NOT "%CLASSPATH%"=="" (
set CLASSPATH=%WEBLOGIC_CLASSPATH%;%CLASSPATH%
) else (
set CLASSPATH=%WEBLOGIC_CLASSPATH%
)
)
if NOT "%PRE_CLASSPATH%"=="" (
set CLASSPATH=%PRE_CLASSPATH%;%CLASSPATH%
)
if NOT "%JAVA_VENDOR%"=="BEA" (
set JAVA_VM=%JAVA_VM% %JAVA_DEBUG% %JAVA_PROFILE%
) else (
set JAVA_VM=%JAVA_VM% %JAVA_DEBUG% %JAVA_PROFILE%
)
Although the paths are from a win7 machine, I think one can get the general idea in order to proceed. For unix or linux users, one can find help here. Thus, one can avoid the risk of losing one's application or database server connections imposed by setting up JDev from scratch and migrating.
Finally, I don't know, does Oracle support officially certify jdev to work right, after a user has altered the default jdev jdk? That's why keeping the old default jdk entries as comments, is safer; in case the built in 32 bit jdk needs to be used once more.
A recent finding would be my attempt to use the profiler of JDeveloper which only works with the built in 32 bit jdk, provided one installs the 32 bit visual studio 2010 C++ redistributable file .When I tried to use the Microsoft Visual C++ 2010 Redistributable Package (x64) I got:
Error occurred during initialization of VM
Could not find agent library C:\Oracle\Middleware\jdev_11115\jdeveloper\jdev\lib\profiler_x64.dll in absolute path, with error: Can't load IA 32-bit .dll on a AMD 64-bit platform
Process exited.
So remember before you start swearing at me, that you were warned!
Having problems connecting to Oracle 9i? Try tweaking once more the configuration files
Speaking of database connections, I recently noticed that when one attempts to connect to an Oracle 9i database with Greek regional settings, one receives:
Test failed: ORA-00604: error occurred at recursive SQL level 1
ORA-01882: timezone region not found
Having heard of a similar solution working for SQL Developer, a similar method crosses one's mind. One needs to edit:
C:\Oracle\Middleware\jdev_11114\jdeveloper\jdev\bin\jdev.conf
as shown below:
##############################################################################
#
# Oracle JDeveloper Launcher Configuration File
# Copyright 2000-2008 Oracle Corporation.
# All Rights Reserved.
#
##############################################################################
IncludeConfFile ../../ide/bin/ide.conf
#
# Directive SetJavaHome is not required by default, except for the base
# install, since the launcher will determine the JAVA_HOME. On Windows
# it looks in ..\..\jdk, on UNIX it first looks in ../../jdk. If no JDK
# is found there, it looks in the PATH.
#
#SetJavaHome C:\Oracle\Middleware\jdev_11114\jdk160_21
SetJavaHome C:\Program Files\Java\jdk1.6.0_24
#
# MaxPermSize is required to run JDeveloper with Sun Microsystems virtual
# machine (-client and -server). The default value is 64M, which isn't
# enough to run JDeveloper successfully. With the default value, JDeveloper
# will end up running out of memory at some point in time. For technical
# details, see: http://java.sun.com/docs/hotspot/gc5.0/gc_tuning_5.html
#
AddVMOption -XX:MaxPermSize=256M
#
#added on 10/04/2011 to connect to oracle 9 with Greek regional settings
AddVMOption -Duser.timezone=UTC+02:00
#
# Replace heavyweight AWT controls with lightweight implementations.
#
AddVMOption -Xbootclasspath/p:../lib/lwawt.jar
#
# Don't swap the entire JDev process out of memory when minimizing the main window.
#
AddVMOption -Dsun.awt.keepWorkingSetOnMinimize=true
#
# Prevent Swing painting issues and hangs on some graphics cards and/or
# multiple monitor setups and/or Windows 7.
#
AddVMOption -Dsun.java2d.noddraw=true
#
# Automatically dump heap on OutOfMemoryError.
# The heap dump is in HPROF binary format, and so it can be analyzed using
# any tools that can import this format. Examples are jhat, NetBeans and YourKit.
# By default the heap dump is created in a file called java_pid
# working directory of the VM.
#
AddVMOption -XX:+HeapDumpOnOutOfMemoryError
#
# Option to enable OWSM policy types RM and Management on the policy configuration
# dialog for a web service.
# The same option, if set to true, also shows the policy configuration dialog for
# web service client as well.
# This flag exists so that when OWSM support for RM and Management policy
# types for WLS becomes available in the server module, removing this flag or
# setting it to 'true' will bring those options in JDev WS policy configuration.
#
AddVMOption -Doracle.jdeveloper.webservice.showAllOwsmPolicyTypes=false
#
# Controls the acess to OWSM policy property override dialog from the client policy
# configuration dialog.
#
AddVMOption -Doracle.jdeveloper.webservice.hidePropertyOverride=false
#
# Prevents the desktop hanging when debugging JDev on Linux and hitting a breakpoint with a popup open.
# See Sun Bug: 6714678 (http://bugs.sun.com/view_bug.do?bug_id=6714678)
# Note: This only prevents the hang when debugging JDev itself. To prevent hanging with other
# projects add this flag to the java options for the process to be debugged.
#
AddVMOption -Dsun.awt.disablegrab=true
....
What worries me most, is when each newer version of the I.D.E. or Sun jdk becomes available, if one is forced to setup from scratch, might not remember all the necessary steps to edit properly the new configuration files and continue with the current project. So backing up the jdev configuration files sounds like a good, proactive idea!
Wednesday 6 October 2010
JDeveloper 11g: Using assert() for testing and debugging
protected void doDML(int operation, TransactionEvent e) {
if (operation == DML_UPDATE) {
...
histStartDate = row.getEndDate();
/*Check whether end date equals current date*/
/*if (histStartDate.equals(new Date(Date.getCurrentDate()))){
System.out.println("End date equals current date!");
}*/
assert(histStartDate.equals(new Date(Date.getCurrentDate() ) )) :
"End date equals current date! ";
Another trivial example from an ejb client follows:
public class PlaceBidClient {
public static void main(String [] args) {
...
Bid bid = placeBid.addBid("Lila", Long.valueOf(100), 2001.50);
System.out.println("Bid Successful, BidId Received is:" + bid.getBidId());
assert(bid.getBidId() == 502):"BidId Received is "+bid.getBidId();
}
}
Finally, when run, the log output reads:
-javaagent:C:\Oracle\Middleware\jdev_11gR1\jdeveloper\..\modules\org.eclipse.persistence_1.0.0.0_2-0.jar -Duser.language=en -Duser.country=US -ea actionbazaar.buslogic.client.PlaceBidClient
Exception in thread "main" java.lang.AssertionError: BidId Received is 393
at actionbazaar.buslogic.client.PlaceBidClient.main(PlaceBidClient.java:24)Bid Successful, BidId Received is:393
Saturday 25 September 2010
JDeveloper 11g: Using Log4j in ADF view object
C:\...\Model\src
similar to the following example:
# Set root logger level to INFO and its only appender to ConsoleOut.
log4j.rootLogger=INFO, ConsoleOut
# ConsoleOut is set to be a ConsoleAppender.
log4j.appender.ConsoleOut=org.apache.log4j.ConsoleAppender
# ConsoleOut uses PatternLayout.
log4j.appender.ConsoleOut.layout=org.apache.log4j.PatternLayout
log4j.appender.ConsoleOut.layout.ConversionPattern=%-5p: [%d] %c{1} - %m%n
log4j.logger.org.apache.jsp=DEBUG
#Addon for
com.sun.faces.level=FINE
Third, if you want to use logging in several view objects, you need to edit your view object super class code like that:
package tuhra.model.framework;
import oracle.jbo.server.ViewRowImpl;
import org.apache.log4j.Logger;
public class TuhraViewRowImpl extends ViewRowImpl {
protected Logger logger = Logger.getLogger(this.getClass());
}
and your view object code like that:
public class AllEmployeesRowImpl extends TuhraViewRowImpl implements AllEmployeesRow {...
public void defineDefaultImage(Number newDefaultImageId){
...
if (logger.isDebugEnabled())
logger.debug("Default Image has been defined!");
}
}
Next your diagnostic message appears in the log output window:
INFO : [2010-09-25 11:55:18,739] AllEmployeesRowImpl - DefaultImage has been defined!
Finally, if you need more tips about appenders:
http://www.mobilefish.com/developer/log4j/log4j_quickguide_appenders.html
The full source code is available on line:
http://code.google.com/p/nickaiva-blogspot/downloads/list
and is given without any guarantee of support whatsoever.
Thursday 16 September 2010
JDeveloper 11g:Using Log4j in an ADF application module
starting with adding the log4j library, as shown in the image on your left hand side.
Next, you need to create a log4j.properties file, within:
C:\...\Model\src
just like the following:
# Set root logger level to INFO and its only appender to ConsoleOut.
log4j.rootLogger=INFO, ConsoleOut
# ConsoleOut is set to be a ConsoleAppender.
log4j.appender.ConsoleOut=org.apache.log4j.ConsoleAppender
# ConsoleOut uses PatternLayout.
log4j.appender.ConsoleOut.layout=org.apache.log4j.PatternLayout
log4j.appender.ConsoleOut.layout.ConversionPattern=%-5p: [%d] %c{1} - %m%n
log4j.logger.org.apache.jsp=DEBUG
#Addon for
com.sun.faces.level=FINE
Third, you need to edit your code just like that:
...
import org.apache.log4j.Logger;
...
public class TuhraServiceImpl extends TuhraApplicationModuleImpl implements TuhraService {
private Logger logger = Logger.getLogger(this.getClass());
...
public void createNewImageForEmployee(Number employeeId, String imageName){
...
if (logger.isDebugEnabled())
logger.debug("New image has been created!");
}
}
Finally, you should see your logger message appear in the log output window;
INFO : [2010-09-16 10:26:16,517] TuhraServiceImpl - New image has been created!
Moreover, you could move the code line below:
private Logger logger = Logger.getLogger(this.getClass());
to the super class:
package tuhra.model.framework;
import oracle.jbo.server.ApplicationModuleImpl;
import org.apache.log4j.Logger;
public class TuhraApplicationModuleImpl extends ApplicationModuleImpl {
protected Logger logger = Logger.getLogger(this.getClass().getName());
}
Once more, your custom logger message should appear in the log output :
INFO : [2010-09-16 15:20:02,247] TuhraServiceImpl - New image has been created!
Finally, if you need more tips about appenders:
http://www.mobilefish.com/developer/log4j/log4j_quickguide_appenders.html
https://logging.apache.org/log4j/2.x/
Sunday 12 September 2010
JDeveloper 11g:Using Log4j in ADF business components projects
First, you need to add the library, by double clicking your Model project, as you can see on your left hand side.
Second, you need to create a log4j.properties file within:
C:\...\Model\src
just like the following:
# Set root logger level to INFO and its only appender to ConsoleOut.
log4j.rootLogger=INFO, ConsoleOut
# ConsoleOut is set to be a ConsoleAppender.
log4j.appender.ConsoleOut=org.apache.log4j.ConsoleAppender
# ConsoleOut uses PatternLayout.
log4j.appender.ConsoleOut.layout=org.apache.log4j.PatternLayout
log4j.appender.ConsoleOut.layout.ConversionPattern=%-5p: [%d] %c{1} - %m%n
log4j.logger.org.apache.jsp=DEBUG
#Addon for
com.sun.faces.level=FINE
Third, you edit your entity object code like that:
...
import org.apache.log4j.Logger;
public class ImagesImpl extends TuhraEntityImpl {
...
private Logger logger = Logger.getLogger(this.getClass());
...
private void adjustImageUsages(RowSet newImageUsagesBeforePost) {
...
if (logger.isDebugEnabled())
logger.debug("ImageUsages has been adjusted");
}
...
}
Finally the message you created appears in the log output window:
INFO : [2010-09-12 09:56:32,593] ImagesImpl - ImageUsages has been adjusted
Furthermore, if you use logging within multiple entity objects, you could move the declaration code line:
private Logger logger = Logger.getLogger(this.getClass());
to the super class:
package tuhra.model.framework;
import oracle.jbo.server.EntityImpl;
import org.apache.log4j.Logger;
public class TuhraEntityImpl extends EntityImpl {
protected Logger logger = Logger.getLogger(this.getClass());
}
Upon commit, the logger output appears once more:
INFO : [2010-09-16 10:28:07,288] ImagesImpl - ImageUsages has been adjusted
For dynamic changes of logging levels, one can consult for example:
dynamically-changing-log-level-with-weblogic-log4j-jmx-and-wlst/
Finally, if you need more tips about appenders:
http://www.mobilefish.com/developer/log4j/log4j_quickguide_appenders.html
https://logging.apache.org/log4j/2.x/
Saturday 11 September 2010
JDeveloper 11g:Using Log4j in a JSF backing bean
First, you need to add the Log4j.jar by double clicking the ViewController project. You can see the library window on your left handside, showind the jar already added. Note that you can use logging via log4j in combination with ADFLogger, that is if you are using ADF, or even without it.
Second, you need to create the log4j.properties file in ViewController/src. Another log4j.properties sample file is given here, for your convenience:
# Set root logger level to INFO and its only appender to ConsoleOut.
log4j.rootLogger=INFO, ConsoleOut
# ConsoleOut is set to be a ConsoleAppender.
log4j.appender.ConsoleOut=org.apache.log4j.ConsoleAppender
# ConsoleOut uses PatternLayout.
log4j.appender.ConsoleOut.layout=org.apache.log4j.PatternLayout
log4j.appender.ConsoleOut.layout.ConversionPattern=%-5p: [%d] %c{1} - %m%n
log4j.logger.org.apache.jsp=DEBUG
#Addon for
com.sun.faces.level=FINE
Third, you need to code! The example bean code follows:
...
import org.apache.log4j.Logger;
...
public class ImageUploadBean extends TuhraBackingBean implements Serializable {
private Logger logger = Logger.getLogger(this.getClass());
...
private void insertRows() {
...
if (logger.isDebugEnabled())
logger.debug("Succeeded in adding new image!");
}
}
Finally, your message appears in the log window:
INFO : [2010-09-11 21:47:52,005] ImageUploadBean - Succeeded in adding new image!
Furthermore, if you use logging in several beans, you could move the declaration code line:
private Logger logger = Logger.getLogger(this.getClass());
to the super class TuhraBackingBean:
package tuhra.view.framework;
import oracle.adf.model.BindingContext;
import oracle.binding.BindingContainer;
import org.apache.log4j.Logger;
/**the purpose of this framework class is to
access the commonly used properties.
*/
public abstract class TuhraBackingBean {
protected Logger logger = Logger.getLogger(this.getClass());
/**the purpose of this framework method is to
access the bindings programmatically.
*/
public BindingContainer getBindings() {
return BindingContext.getCurrent().getCurrentBindingsEntry();
}
}
Then the log outputs once more:
INFO : [2010-09-16 09:46:37,767] TuhraServiceImpl - New image has been created!
INFO : [2010-09-16 09:46:37,767] ImageUploadBean - Succeeded in adding new image!
where the first info message comes from the application module code (this could be another example I suppose!), while the second from the aforementioned backing bean. You could follow more or less the same steps for JDeveloper 10g too.
Finally, if you need more tips about appenders:
http://www.mobilefish.com/developer/log4j/log4j_quickguide_appenders.html
Monday 30 August 2010
Comments on Fusion Developer Guide. by F.Nimphius, Lynn Munsinger
On the dark side, the full source code of the book is not available for download, with only a few exceptions. The errata page has vanished for a while, so an older version perhaps incomplete, is available here. The book has not a tutorial step by step, practice on your own form, like the one by D. Mills. Sometimes, the paragraphs are so long and purely theoretical, that reading becomes tedious.
All in all, the book seems like a brief printed synopsis, of the official Oracle fusion Developer guide pdf file, available online for free in OTN. Whether you would like to have a printed version of it as well, is only up to you!
Further critical references concerning ADF:
Tales from the trenches by Dr. Dorsey. Coauthor of JDeveloper 10g handbook.
Performance and scalability criticism by several authors
ERRATA: "Oracle Fusion Developer Guide - Building Rich Internet Applications with Oracle ADF Business Components and ADF Faces" (ISBN - 978-0-07-162254-7)
Chapter 01:
Page 27 | Addition to using scope prefixes in EL when reading memory scope attributes |
The book has it correct. However, we want to make sure memory scope prefixes are understood correctly and that there is no question left open in regards to managed beans: Accessing a managed bean in a standard servlet scope like sessionScope or requestScope using the scope as a prefix fails if the bean instance does not exist. Thus, bean reference like #{sessionScope.myBean} may fail while #{myBean} always succeeds. The reason for this is that #{sessionScope….} and #{requestScope…} reference a Map in memory and not the JSF framework. Managed beans must be instantiated before they become available in the memory scope, which means they need to be accessed through JSF. Luckily, JSF does not allow to configure two managed beans with the same name in different scopes. So even without a scope prefix, there is no risk that application code accidentally accesses the wrong object.. Note that using ADFc specific scope, like viewScope and pageFlowScope, you always need to use the scope name as a prefix in the EL. |
Chapter 03:
Page 100 | Use Case; Using af:subform in ADF Forms - new sample provided |
A complimentary sample is posted on ADF Code Corner implementing this use case: See it here |
Chapter 05:
Page 168 | Creating and Registering a custom Exception Handler |
The custom exception handler example extends AdfcExceptionHandler, which is a class in an internal package. The risk associated with classes in internal packages is that changes may be made by Oracle without further notice. Oracle updated the upcoming version of the product documentation, "Oracle Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework 11g" with a sample that explains how to configure custom exception handlers, following our example in the book. They corrected the use of AdfcExceptionHandler by using ExceptionHandler, the class that is good to use with no strings attached. The sample thus would look like import javax.faces.context.ExternalContext; Note that using ExceptionHandler, the handleException method does not call super.handleException(...) but throws the exception so it is handled by the next registered exception handler, which most likely then is the internal AdfcExceptionhandler instance. The ExceptionHandler, class does not implement the handleException method itself and only acts as a template for defining ADF task Flow exception handlers.
|
Chapter 06:
Page 199 | Accessing the Task Flow Binding from Java |
The code example casts the Task Flow Binding to DCTaskFlowBinding, which is an internal class used by the ADF framework. To avoid using internally packaged classes, yu can cast the region binding to DCBindingContainer, which is the public framework class that DCTaskFlowBinding extends. BindingContext bctx = BindingContext.getCurrent(); The primary use of accessing the region binding is to get a hold of the referenced binding container and its defined bindings, which you can also do using the DCBindingContainer. There is some more infromation available using DCTaskFlowBinding, but these you can get from other APIs, like ControllerContext as well.
|
Chapter 09:
Page 309 | Note says: If the table is a child of the af:panelCollection component, then an implementation of the multiple column sort use case already exists using the PanelCollection View | Sort | Advanced menu option |
The book has it correct and the functionality exists. However, you need to set the table column selection to either single or multiple. This is not apparent because within the chapter, the column selection is enabled at the beginning to handle a different use case. The requirement to enable column selection has nothing to do with sorting but exists in the current JDeveloper 11g release. A bug has been filed to lift this requirement. | |
Page 309 | Selection Event |
The example shows you how to synchronize the table component row selection with the current row in ADF binding layer using Exression Language. If you prefer a pure Java solution, we released a generic Java handler example on ADF Code Corner: read more. | |
Page 296 | How to navigate in specific row in table. |
ADF Code Corner has an improved version of the sample in the book that is worth looking at. The sources are available for dwenload as well. See here. A related sample is here. | |
Page 281 | "invokeMethodBinding" should be "invokeMethodExpression" |
Chapter 9 uses a helper method to invoke method expression. The main method "invokeMethodExpression" has a overloaded method with a simplified signature. Unfortunately the name of this method in the book is "invokeMethodBinding". It should however look as shown below to work with the samples given in the book /** So please put a note on the first method name that the name has changed as shown above. | |
Page 311 | What You Should Know About the Data That Is Exported to Excel |
In this section of the book we provide a hint of how to add an Excel fomular to the exported table cell data so that it gets propery formatted when opened in Excel.This hint stopped working in the latest release of Oracle JDeveloper, which is Oracle JDeveloper 11g R1 PS2 (build number is Build JDEVADF_11.1.1.3.PS2_GENERIC_100408.2356.5660) because of a bug fix that prevents the export of hidden output text content. We assume that it requires a new enhancement request to properly implement the option to add excel formulars (adn some users unfortunately already started suffering from the side effect this bug fix has - including this book). |
Chapter 15:
Page 483 | Typo "exiting" instead of "existing" |
Luc Bors from Amis in the Netherlands found this interesting typo in the book: “A standard JSF component that is built from exiting ADF Faces Components …” . This of course should be "A standard JSF component that is built from existing ADF Faces Components ..." | |
Chapter 19:
Page 601 | Registering the adf-js-partition.xsd Schema |
The adf-js-partitions.xsd schema has been moved to <wls_jdev_install>\oracle_common\modules\oracle.adf.view_11.1.1\adf-richclient-api-11.jar | |
Page 601 | Creating te adf-js-partitions.xml file |
The custom adf-js-partitions.xml file structure has a typo and wrong xml tag. The correct XML is shown below
|
Monday 21 June 2010
Comments on Oracle JDeveloper 11g Handbook, by D.Mills, P.Koletzke, A, R. Faderman
On the bright side, the text is well written with few spelling errors and a whole new chapter about deployment to the new standalone Weblogic server. Such a chapter did not exist in the older book for JDeveloper 10g. In addition, there is more information about using version control in JDev11g.
Its tutorial form beginning at chapter 16, is easy to follow, in order to create a complete application for your practice. Its structure resembles the step by step, successful training methodology providing end of chapter source code solutions, as used in Oracle University classes. Such hands on practice is not present in the newer "Fusion Developer's guide" by F.Nimphius et al. Furthermore, the full source code was available for download, as well as a dedicated forum for discussions of issues.
On the dark side, the source code and application were developed with an older version of JDeveloper 11g, some text about tags, labels etc, especially in chapter 21 about security, were not present in the newer versions. Thus, if you attempt to build yourself the application from scratch in the newer JDeveloper version 11.1.1.2.0, as I tried, you shall need a great deal of patience, since there were incompatibilities and bugs found, as mentioned further in the link: http://www.tuhra.com/ where you are to sign in with OTN, and publicly at http://forums.oracle.com/forums/thread.jspa?threadID=1030502 .
Moreover, the text of chapters before 16 is tedious to read, as several chapters are rather theoretical. Taskflows surely deserved a more practical approach and a do it your self add on, such as the hands on work by S.Muench, provided with his articles in Oracle magazine. There is no mention for alternative model technologies, such as JPA, EJB or POJOS throughout the book.
All in all, the book was well written and the source code given complete, as of the date of the release of JDeveloper version 11.1.1.1.0. Since then, a lot seems to have changed, older code has gone stale and a book published in December 2009 has been deprecated in only a number of months! Nonetheless, it certainly remains still the best option for the beginners, for the time being. I am actually looking forward to a new edition, or even a reprint of the book, correcting all known errata and issues.
Tales from the trenches by Dr. Dorsey. Coauthor of JDeveloper 10g handbook.
Performance and scalability criticism by several authors