Saturday, December 25, 2010

Log4j wrapper

package daveutil;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;

public class Log4jWrapper {

/*
* TRACE, DEBUG, INFO, WARN, ERROR, FATAL
*/
Level level = Level.DEBUG;

public static Log4jWrapper LOG;

private Logger logger;

static {
synchronized(Log4jWrapper.class){
if(LOG == null){
LOG = new Log4jWrapper("daveapp");
}
}
}

private Log4jWrapper(String logger) {
this.logger = Logger.getLogger(logger);
}

public void log(Object o) {
logger.log(level, o);
}

public void log(Object o,Throwable e) {
logger.log(level, o, e);
}

public void log(String callerFCQN,Object o,Throwable e) {
logger.log(callerFCQN,level, o, e);
}

public void trace(Object o) {
logger.trace(o);
}

public void trace(Object o,Throwable e) {
logger.trace(o,e);
}

public void debug(Object o) {
logger.debug(o);
}

public void debug(Object o,Throwable e) {
logger.debug(o,e);
}

public void info(Object o) {
logger.info(o);
}

public void info(Object o,Throwable e) {
logger.info(o,e);
}

public void warn(Object o) {
logger.warn(o);
}

public void warn(Object o,Throwable e) {
logger.warn(o,e);
}

public void error(Object o) {
logger.error(o);
}

public void error(Object o,Throwable e) {
logger.error(o,e);
}

public void fatal(Object o) {
logger.fatal(o);
}

public void fatal(Object o,Throwable e) {
logger.fatal(o,e);
}

}





Using log4j wrapper
package daveapp;

import daveutil.Log4jWrapper;

public class TestDaveApp {

public void testDaveApp(){

System.out.println("Use Log4jWrapper");
Log4jWrapper.LOG.info("TestDaveApp info");

Log4jWrapper.LOG.info("TestDaveApp info",new Exception("TestDaveApp"));
}

}


log4j properties configuration
Pattern layout
http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PatternLayout.html


Property Configurator

http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PropertyConfigurator.html

All option values admit variable substitution. The syntax of variable substitution is similar to that of Unix shells. The string between an opening "${" and closing "}" is interpreted as a key. The value of the substituted variable can be defined as a system property or in the configuration file itself.

#log4j.rootLogger=debug, stdout, dave, daveutil

log4j.logger.dave=DEBUG,stdout, dave
log4j.logger.daveutil=DEBUG, stdout, daveutil
log4j.logger.daveapp=DEBUG, stdout, daveapp

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

# Pattern to output the caller's file name and line number.
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n

log4j.appender.dave=org.apache.log4j.RollingFileAppender
# do not send to other logs
log4j.additivity.dave=false
log4j.appender.dave.File=${weblogic.Name}.dave.log

log4j.appender.dave.MaxFileSize=10KB
# Keep one backup file
log4j.appender.dave.MaxBackupIndex=5

log4j.appender.dave.layout=org.apache.log4j.PatternLayout
log4j.appender.dave.layout.ConversionPattern=%p %t %c - %m%n

log4j.appender.daveutil=org.apache.log4j.RollingFileAppender
# do not send to other logs
log4j.additivity.daveutil=false
log4j.appender.daveutil.File=${weblogic.Name}.daveutil.log

log4j.appender.daveutil.MaxFileSize=10KB
# Keep one backup file
log4j.appender.daveutil.MaxBackupIndex=5

log4j.appender.daveutil.layout=org.apache.log4j.PatternLayout
log4j.appender.daveutil.layout.ConversionPattern=%p %t %c - %m%n

log4j.appender.daveapp=org.apache.log4j.RollingFileAppender
# do not send to other logs
log4j.additivity.daveapp=false
log4j.appender.daveapp.File=${weblogic.Name}.daveapp.log

log4j.appender.daveapp.MaxFileSize=10KB
# Keep one backup file
log4j.appender.daveapp.MaxBackupIndex=5

log4j.appender.daveapp.layout=org.apache.log4j.PatternLayout
log4j.appender.daveapp.layout.ConversionPattern=%p %t %c - %m%n



Using FCQN - fully qualified class name
Log4jWrapper.LOG.log(TestDaveApp.class.getName(),"TestDaveApp info",new Exception("TestDaveApp"));



INFO (Log4jWrapper.java:62) - TestDaveApp info


DEBUG (TestDave.java:22) - TestDaveApp info

Log into separate files according to package

log4j.properties

#log4j.rootLogger=debug, stdout, dave, daveutil

log4j.logger.dave=DEBUG, dave
log4j.logger.daveutil=DEBUG, daveutil

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

# Pattern to output the caller's file name and line number.
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n

log4j.appender.dave=org.apache.log4j.RollingFileAppender
# do not send to other logs
log4j.additivity.dave=false
log4j.appender.dave.File=dave.log

log4j.appender.dave.MaxFileSize=10KB
# Keep one backup file
log4j.appender.dave.MaxBackupIndex=5

log4j.appender.dave.layout=org.apache.log4j.PatternLayout
log4j.appender.dave.layout.ConversionPattern=%p %t %c - %m%n


log4j.appender.daveutil=org.apache.log4j.RollingFileAppender
# do not send to other logs
log4j.additivity.daveutil=false
log4j.appender.daveutil.File=daveutil.log

log4j.appender.daveutil.MaxFileSize=10KB
# Keep one backup file
log4j.appender.daveutil.MaxBackupIndex=5

log4j.appender.daveutil.layout=org.apache.log4j.PatternLayout
log4j.appender.daveutil.layout.ConversionPattern=%p %t %c - %m%n




configure log4j in application lifecycle listener

package start;


import java.net.URL;

import org.apache.log4j.PropertyConfigurator;
import org.apache.log4j.helpers.Loader;

import weblogic.application.ApplicationLifecycleEvent;
import weblogic.application.ApplicationLifecycleListener;

public class DaveStart extends ApplicationLifecycleListener {


public void preStart(ApplicationLifecycleEvent event){

System.out.println("DaveStart preStart");
}

public void postStart(ApplicationLifecycleEvent event){

System.out.println("DaveStart postStart");

// configure log4j
URL url = Loader.getResource("log4j.properties");
PropertyConfigurator.configure(url);

System.out.println("DaveStart log4j initialized");

}


}



using defined logger
package daveutil;

import org.apache.log4j.Logger;

public class TestDave {

static Logger logger = Logger.getLogger(TestDave.class.getName());

public String hello(String name) {

System.out.println("TestDave: START ");
logger.info("TestDave: START ");

System.out.println("Hello from TestDave to " + name);
logger.info("Hello from TestDave to " + name);

System.out.println("Using fast-swap");
logger.info("Using fast-swap");

return name;
}

}


created logs
[dave@dave base_domain]$ ls -lt
total 84
-rw-r-----. 1 dave vesedan 1112 Dec 25 15:37 dave.log
-rw-r-----. 1 dave vesedan 4888 Dec 25 15:37 daveutil.log
-rw-r-----. 1 dave vesedan 10830 Dec 25 15:37 dave.log.1



dave.log
[dave@dave base_domain]$ more dave.log
INFO [ACTIVE] ExecuteThread: '19' for queue: 'weblogic.kernel.Default (self-tuning)' dave.TestSesssionEJB - timeFromBegin2 timeToLive180000
0



daveutil.log
[dave@dave base_domain]$ more daveutil.log 
INFO [ACTIVE] ExecuteThread: '20' for queue: 'weblogic.kernel.Default (self-tuning)' daveutil.TestDave - TestDave: START
INFO [ACTIVE] ExecuteThread: '20' for queue: 'weblogic.kernel.Default (self-tuning)' daveutil.TestDave - Hello from TestDave to dave
INFO [ACTIVE] ExecuteThread: '20' for queue: 'weblogic.kernel.Default (self-tuning)' daveutil.TestDave - Using fast-swap
INFO [ACTIVE] ExecuteThread: '20' for queue: 'weblogic.kernel.Default (self-tuning)' daveutil.TestDave - TestDave: START
INFO [ACTIVE] ExecuteThread: '20' for queue: 'weblogic.kernel.Default (self-tuning)' daveutil.TestDave - Hello from TestDave to dave
INFO [ACTIVE] ExecuteThread: '20' for queue: 'weblogic.kernel.Default (self-tuning)' daveutil.TestDave - Using fast-swap

Friday, December 24, 2010

Using FastSwap

Using FastSwap Deployment to Minimize Redeployment

http://download.oracle.com/docs/cd/E12839_01/web.1111/e13702/deployunits.htm




Ant build script using FastSwap ant task

<project basedir="." default="deploy" name="deploy">
<property environment="env"/>

<property name="wl.home" value="/app/wlserver_10.3"/>
<property name="application.dir" value="/home/dave/workspace/wls1033/.metadata/.plugins/org.eclipse.core.resources/.projects/testEAR/beadep/base_domain/testEAR/" />

<echo message="${wl.home}/server/lib"/>

<path id="wlappc.classpath">
<fileset dir="${wl.home}/server/lib">
<include name="weblogic.jar"/>
</fileset>
</path>

<echo message="${toString:wlappc.classpath}"/>

<taskdef name="wlappc" classpathref="wlappc.classpath" classname="weblogic.ant.taskdefs.j2ee.Appc"/>
<taskdef name="wldeploy" classpathref="wlappc.classpath" classname="weblogic.ant.taskdefs.management.WLDeploy"/>
<taskdef name='fast-swap' classpathref="wlappc.classpath" classname='com.bea.wls.redef.ant.FastSwapTask'/>


<target name="deploy">
<wldeploy user="weblogic"
password="weblogic123"
verbose="true"
adminurl="t3://localhost:7001"
targets="AdminServer"
action="deploy"
source="${application.dir}"
name = "testEAR"
/>
</target>


<target name="fast-swap">
<fast-swap user="weblogic"
password="weblogic123"
adminurl="t3://localhost:7001"
server="AdminServer"
application = "testEAR"
/>
</target>

</project>





Ant build script output
Buildfile: /home/dave/workspace/wls1033/testEAR/build.xml
[echo] /app/wlserver_10.3/server/lib
[echo] /app/wlserver_10.3/server/lib/weblogic.jar
fast-swap:
[fast-swap] Performing FastSwap.
[fast-swap] adminUrl: t3://localhost:7001
[fast-swap] server: AdminServer
[fast-swap] application: testEAR
[fast-swap] module: null
[fast-swap] classes:
[fast-swap] Using JMX Connector to connect to service:jmx:t3://localhost:7001/jndi/weblogic.management.mbeanservers.runtime
[fast-swap] Processed 1 classes from 1 candidate classes.
[fast-swap] FastSwap operation completed successfully.
[fast-swap] ----------------------------------------------------
BUILD SUCCESSFUL


AdminServer log
####<Dec 24, 2010 8:33:14 AM CET> <Info> <FastSwap> <dave> <AdminServer> <[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1293175994484> <BEA-2154001> <Starting FastSwap operation on application "testEAR".> 
####<Dec 24, 2010 8:33:14 AM CET> <Info> <FastSwap> <dave> <AdminServer> <[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1293175994527> <BEA-2154002> <Finished FastSwap operation on application "testEAR" with status FINISHED.>



<!--
Redefine classes which have changed since they were last loaded.
Required parameters:
adminUrl: Connection url
user: User name
password: User password
server: Managed server name
application: Deployed application name
Optional parameters:
module: Name of the module within the application.
If not specified, all modules within the application
will be processed.
failonerror: Default=true. If true, task will fail if fast-swap failed.
Otherwise, a message will be displayed and the task will
return success.
timeout: Default=300. Timeout in seconds.
classnames: Comma separated list of classnames to process. If not
specified, all classes within specified modules (if any)
in the application will be considered.
-->

Thursday, December 23, 2010

Weblogic tool appc for EJB pre-compilation

<project basedir="." default="appc-ejb" name="appc-ejb">
<property environment="env"/>

<property name="wl.home" value="/app/wlserver_10.3"/>
<property name="application.dir" value="/home/dave/workspace/wls1033/testEJBGen/build/classes" />

<echo message="${wl.home}/server/lib"/>

<path id="wlappc.classpath">
<fileset dir="${wl.home}/server/lib">
<include name="*.jar"/>
</fileset>
</path>

<echo message="${toString:wlappc.classpath}"/>

<taskdef name="wlappc" classpathref="wlappc.classpath" classname="weblogic.ant.taskdefs.j2ee.Appc"/>

<target name="appc-ejb">
<wlappc source="${application.dir}"
keepgenerated="true"
verbose="true"
classpathref="wlappc.classpath"/>
</target>
</project>


Buildfile: /home/dave/workspace/wls1033/testEJBGen/build.xml
[echo] /app/wlserver_10.3/server/lib
[echo] /app/wlserver_10.3/server/lib/weblogic.jar
appc-ejb:
[wlappc] <Dec 23, 2010 9:28:28 PM CET> <Warning> <EJB> <BEA-010212> <The EJB 'TestSessionEJBGen(Jar: /home/dave/workspace/wls1033/testEJBGen/build/classes)' contains at least one method without an explicit transaction attribute setting. The default transaction attribute of Supports will be used for the following methods: remote[helloEJBGen(java.lang.String)] >
[wlappc] <Dec 23, 2010 9:28:31 PM CET> <Info> <J2EE> <BEA-160220> <Compilation completed successfully>
BUILD SUCCESSFUL


[dave@dave dave]$ pwd
/home/dave/workspace/wls1033/testEJBGen/build/classes/dave
[dave@dave dave]$ ls -lt
total 196
-rw-r--r--. 1 dave vesedan 3834 Dec 23 21:28 TestSessionEJBGen_pq6ajk_EOImpl_1033_WLStub.class
-rw-r--r--. 1 dave vesedan 1003 Dec 23 21:28 TestSessionEJBGen_pq6ajk_EOImplRTD.xml
-rw-r--r--. 1 dave vesedan 3387 Dec 23 21:28 TestSessionEJBGen_pq6ajk_EOImpl_WLSkel.class
-rw-r--r--. 1 dave vesedan 4957 Dec 23 21:28 TestSessionEJBGen_pq6ajk_HomeImpl_1033_WLStub.class
-rw-r--r--. 1 dave vesedan 4172 Dec 23 21:28 TestSessionEJBGen_pq6ajk_HomeImpl_WLSkel.class
-rw-r--r--. 1 dave vesedan 2635 Dec 23 21:28 TestSessionEJBGen_pq6ajk_ELOImpl.class
-rw-r--r--. 1 dave vesedan 4447 Dec 23 21:28 TestSessionEJBGen_pq6ajk_EOImpl.class
-rw-r--r--. 1 dave vesedan 3152 Dec 23 21:28 TestSessionEJBGen_pq6ajk_HomeImpl.class
-rw-r--r--. 1 dave vesedan 1087 Dec 23 21:28 TestSessionEJBGen_pq6ajk_HomeImplRTD.xml
-rw-r--r--. 1 dave vesedan 3763 Dec 23 21:28 TestSessionEJBGen_pq6ajk_Impl.class
-rw-r--r--. 1 dave vesedan 416 Dec 23 21:28 TestSessionEJBGen_pq6ajk_Intf.class
-rw-r--r--. 1 dave vesedan 2732 Dec 23 21:28 TestSessionEJBGen_pq6ajk_LocalHomeImpl.class
-rw-r--r--. 1 dave vesedan 2594 Dec 23 21:28 TestSessionEJBGen_pq6ajk_ELOImpl.java
-rw-r--r--. 1 dave vesedan 4006 Dec 23 21:28 TestSessionEJBGen_pq6ajk_EOImpl.java
-rw-r--r--. 1 dave vesedan 2999 Dec 23 21:28 TestSessionEJBGen_pq6ajk_HomeImpl.java
-rw-r--r--. 1 dave vesedan 4083 Dec 23 21:28 TestSessionEJBGen_pq6ajk_Impl.java
-rw-r--r--. 1 dave vesedan 626 Dec 23 21:28 TestSessionEJBGen_pq6ajk_Intf.java
-rw-r--r--. 1 dave vesedan 2540 Dec 23 21:28 TestSessionEJBGen_pq6ajk_LocalHomeImpl.java
-rw-r--r--. 1 dave vesedan 1447 Dec 23 20:53 TestSessionEJBGen.class
-rw-r--r--. 1 dave vesedan 162 Dec 23 20:53 TestSessionEJBGenLocal.class
-rw-r--r--. 1 dave vesedan 275 Dec 23 20:53 TestSessionEJBGenLocalHome.class
-rw-r--r--. 1 dave vesedan 275 Dec 23 20:53 TestSessionEJBGenRemote.class
-rw-r--r--. 1 dave vesedan 305 Dec 23 20:53 TestSessionEJBGenRemoteHome.class

Wednesday, December 15, 2010

Get Weblogic Transaction details - timeout, time to live

weblogic.transaction.TransactionHelper
http://download.oracle.com/docs/cd/E14571_01/apirefs.1111/e13941/weblogic/transaction/TransactionHelper.html

weblogic.transaction.Transaction - extends javax.transaction.Transaction
http://download.oracle.com/docs/cd/E14571_01/apirefs.1111/e13941/weblogic/transaction/Transaction.html


EJB 3.0 Metadata Annotations Reference
http://download.oracle.com/docs/cd/E12840_01/wls/docs103/ejb30/annotations.html#wp1438355

package dave;

import java.sql.Connection;
import weblogic.javaee.TransactionTimeoutSeconds;
import java.sql.SQLException;

import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
import javax.transaction.SystemException;

import weblogic.transaction.Transaction;
import weblogic.transaction.TransactionHelper;

/**
* Session Bean implementation class TestSesssionEJB
*/
@Stateless(mappedName = "TestSesssionEJB")
@TransactionAttribute(TransactionAttributeType.REQUIRED)
@TransactionTimeoutSeconds(1800)
public class TestSesssionEJB implements TestSesssionEJBRemote, TestSesssionEJBLocal {

/**
* Default constructor.
*/
public TestSesssionEJB() {
}


public int testTransactionTimeout(int timeout) {

int out = 0;

TransactionHelper th = weblogic.transaction.TransactionHelper.getTransactionHelper();

weblogic.transaction.Transaction transaction = (Transaction) th.getTransaction();

System.out.println("Transaction: "+ transaction);

try {
System.out.println("Transaction status: "+ transaction.getStatus());
} catch (SystemException e) {
e.printStackTrace();
}

long timeFromBegin = transaction.getMillisSinceBegin();
long timeToLive = transaction.getTimeToLiveMillis();

System.out.println("timeFromBegin" + timeFromBegin + " timeToLive" + timeToLive);

return out;

}

}




Default 900s set in JTA
Transaction:  Name=[EJB dave.TestSesssionEJB.testTransactionTimeout(int)],Xid=BEA1-000002B089C73057A4BD(11628244),Status=Active,
numRepliesOwedMe=0,numRepliesOwedOthers=0,seconds since begin=0,seconds left=899,activeThread=Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads],SCInfo[base_domain+AdminServer]=(state=active),properties=({weblogic.transaction.name=[EJB dave.TestSesssionEJB.testTransactionTimeout(int)]}),OwnerTransactionManager=ServerTM[ServerCoordinatorDescriptor=(CoordinatorURL=AdminServer+localhost:7001+base_domain+t3+,
XAResources={WSATGatewayRM_AdminServer_base_domain},NonXAResources={})],
CoordinatorURL=AdminServer+localhost:7001+base_domain+t3+)
Transaction status: 0
timeFromBegin934 timeToLive899000



Changed on EJB to 1800s
Transaction:  Name=[EJB dave.TestSesssionEJB.testTransactionTimeout(int)],Xid=BEA1-000302B089C73057A4BD(11110649),Status=Active,
numRepliesOwedMe=0,numRepliesOwedOthers=0,seconds since begin=0,seconds left=1800,
activeThread=Thread[[ACTIVE] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads],SCInfo[base_domain+AdminServer]=(state=active),properties=({weblogic.transaction.name=[EJB dave.TestSesssionEJB.testTransactionTimeout(int)]}),OwnerTransactionManager=ServerTM[ServerCoordinatorDescriptor=(CoordinatorURL=AdminServer+localhost:7001+base_domain+t3+, XAResources={WSATGatewayRM_AdminServer_base_domain},NonXAResources={})],
CoordinatorURL=AdminServer+localhost:7001+base_domain+t3+)
Transaction status: 0
timeFromBegin12 timeToLive1800000

Sunday, December 5, 2010

Upgrading Deployment Descriptors From Previous Releases of J2EE and WebLogic Server

XML Deployment Descriptors
http://download.oracle.com/docs/cd/E14571_01/web.1111/e13706/overview.htm#i1074199


java weblogic.DDConverter -verbose -d /tmp/ddconv/  testWeb/WebContent/
[DDConverter] inputFile /home/dave/workspace/wls1033/testWeb/WebContent
[DDConverter] outputDir /tmp/ddconv
[DDConverter] Using exploded dir /home/dave/workspace/wls1033/testWeb/WebContent
[DDConverter] Trying factory weblogic.application.ddconvert.EJBConverterFactory
[DDConverter] Called Factory weblogic.application.ddconvert.EJBConverterFactory recognized application: false
[DDConverter] Trying factory weblogic.application.ddconvert.WarConverterFactory
[DDConverter] Called Factory weblogic.application.ddconvert.WarConverterFactory recognized application: true
[DDConverter] START Converting WAR WebContent
[DDConverter] Converting WEB-INF/web.xml
[DDConverter] Converting WEB-INF/weblogic.xml
[DDConverter] END Converting WAR WebContent

Saturday, December 4, 2010

Weblogic build time compilation tool appc and wlappc ant task

http://download.oracle.com/docs/cd/E14571_01/web.1111/e13706/splitbuild.htm#i1113891

http://download.oracle.com/docs/cd/E14571_01/web.1111/e13719/appc_ejbc.htm#EJBPG1088
appc

The appc compiler generates and compiles the classes needed to deploy EJBs and JSPs to WebLogic Server. It also validates the deployment descriptors for compliance with the current specifications at both the individual module level and the application level. The application-level checks include checks between the application-level deployment descriptors and the individual modules as well as validation checks across the modules.

java weblogic.appc [options]

ant task weblogic.ant.taskdefs.j2ee.Appc
<project basedir="." default="appc" name="appc">
<property environment="env"/>

<property name="wl.home" value="/app/wlserver_10.3"/>
<property name="application.dir" value="/home/dave/workspace/wls1033/testWeb/WebContent" />

<echo message="${wl.home}/server/lib"/>

<path id="wlappc.classpath">
<fileset dir="${wl.home}/server/lib">
<include name="*.jar"/>
</fileset>
</path>

<echo message="${toString:wlappc.classpath}"/>


<taskdef name="wlappc" classpathref="wlappc.classpath" classname="weblogic.ant.taskdefs.j2ee.Appc"/>

<target name="appc">
<wlappc source="${application.dir}"
keepgenerated="true"
verbose="true"/>
</target>
</project>


Setting project property: wl.home -> /app/wlserver_10.3
Setting project property: application.dir -> /home/dave/workspace/wls1033/testWeb/WebContent
[echo] /app/wlserver_10.3/server/lib
Adding reference: wlappc.classpath
fileset: Setup scanner in dir /app/wlserver_10.3/server/lib with patternSet{ includes: [**/*.jar] excludes: [] }
[echo] /app/wlserver_10.3/server/lib/EccpressoAsn1.jar:/app/wlserver_10.3/server/lib/EccpressoCore.jar:/app/wlserver_10.3/server/lib/EccpressoJcae.jar:/app/wlserver_10.3/server/lib/api.jar:/app/wlserver_10.3/server/lib/aqapi.jar:/app/wlserver_10.3/server/lib/bea_wls_async_response.jar:/app/wlserver_10.3/server/lib/bea_wls_remote_deployer.jar:/app/wlserver_10.3/server/lib/app/wlserver_10.3/server/lib/consoleapp/consolehelp/WEB-INF/lib/beehive-netui-core.jar:/app/wlserver_10.3/server/lib/consoleapp/consolehelp/WEB-INF/lib/beehive-netui-tags.jar:/app/wlserver_10.3/server/lib/consoleapp/consolehelp/WEB-INF/lib/console.jar:/app/wlserver_10.3/server/lib/consoleapp/consolehelp/WEB-INF/lib/jh.jar:/app/wlserver_10.3/server/lib/consoleapp/consolehelp/WEB-INF/lib/l10n_taglib.jar:/app/wlserver_10.3/server/lib/consoleapp/consolehelp/WEB-INF/lib/netuix_common_web.jar:/app/wlserver_10.3/server/lib/consoleapp/consolehelp/WEB-INF/lib/netuix_servlet.jar:/app/wlserver_10.3/server/lib/consoleapp/consolehelp/WEB-INF/lib/prefs-spi.jar:/app/wlserver_10.3/server/lib/consoleapp/consolehelp/WEB-INF/lib/render_taglib.jar:/app/wlserver_10.3/server/lib/consoleapp/consolehelp/WEB-INF/lib/skeleton_taglib.jar:/app/wlserver_10.3/server/lib/consoleapp/consolehelp/WEB-INF/lib/standard.jar:/app/wlserver_10.3/server/lib/consoleapp/consolehelp/WEB-INF/lib/struts-adapter.jar:/app/wlserver_10.3/server/lib/consoleapp/consolehelp/WEB-INF/lib/struts.jar:/app/wlserver_10.3/server/lib/consoleapp/webapp/WEB-INF/lib/beehive-controls.jar:/app/wlserver_10.3/server/lib/consoleapp/webapp/WEB-INF/lib/beehive-netui-core.jar:/app/wlserver_10.3/server/lib/consoleapp/webapp/WEB-INF/lib/beehive-netui-tags.jar:/app/wlserver_10.3/server/lib/consoleapp/webapp/WEB-INF/lib/client_taglib.jar:/app/wlserver_10.3/server/lib/consoleapp/webapp/WEB-INF/lib/console-de.jar:/app/wlserver_10.3/server/lib/consoleapp/webapp/WEB-INF/lib/console-es.jar:/app/wlserver_10.3/server/lib/consoleapp/webapp/WEB-INF/lib/console-fr.jar:/app/wlserver_10.3/server/lib/consoleapp/webapp/WEB-INF/lib/console-it.jar:/app/wlserver_10.3/server/lib/consoleapp/webapp/WEB-INF/lib/console-ja.jar:/app/wlserver_10.3/server/lib/consoleapp/webapp/WEB-INF/lib/console-ko.jar:/app/wlserver_10.3/server/lib/consoleapp/webapp/WEB-INF/lib/console-page-spec.jar:/app/wlserver_10.3/server/lib/consoleapp/webapp/WEB-INF/lib/console-pt_BR.jar:/app/wlserver_10.3/server/lib/consoleapp/webapp/WEB-INF/lib/console-zh_CN.jar:/app/wlserver_10.3/server/lib/consoleapp/webapp/WEB-INF/lib/console-zh_TW.jar:/app/wlserver_10.3/server/lib/consoleapp/webapp/WEB-INF/lib/console.jar:/app/wlserver_10.3/server/lib/consoleapp/webapp/WEB-INF/lib/faces-adapter.jar:/app/wlserver_10.3/server/lib/consoleapp/webapp/WEB-INF/lib/jsf-api.jar:/app/wlserver_10.3/server/lib/consoleapp/webapp/WEB-INF/lib/jsf-impl.jar:/app/wlserver_10.3/server/lib/consoleapp/webapp/WEB-INF/lib/l10n_taglib.jar:/app/wlserver_10.3/server/lib/consoleapp/webapp/WEB-INF/lib/netui-adapter.jar:/app/wlserver_10.3/server/lib/consoleapp/webapp/WEB-INF/lib/netuix_common_web.jar:/app/wlserver_10.3/server/lib/consoleapp/webapp/WEB-INF/lib/netuix_servlet.jar:/app/wlserver_10.3/server/lib/consoleapp/webapp/WEB-INF/lib/prefs-spi.jar:/app/wlserver_10.3/server/lib/consoleapp/webapp/WEB-INF/lib/render_taglib.jar:/app/wlserver_10.3/server/lib/consoleapp/webapp/WEB-INF/lib/skeleton_taglib.jar:/app/wlserver_10.3/server/lib/consoleapp/webapp/WEB-INF/lib/standard.jar:/app/wlserver_10.3/server/lib/consoleapp/webapp/WEB-INF/lib/struts-adapter.jar:/app/wlserver_10.3/server/lib/consoleapp/webapp/WEB-INF/lib/struts.jar:/app/wlserver_10.3/server/lib/consoleapp/webapp/WEB-INF/lib/wldfclient-min.jar:/app/wlserver_10.3/server/lib/diagnostics-agent.jar:/app/wlserver_10.3/server/lib/jcom.jar:/app/wlserver_10.3/server/lib/jms-local-adp/jmsadapter.jar:/app/wlserver_10.3/server/lib/jms-notran-adp/jmsadapter.jar:/app/wlserver_10.3/server/lib/jms-notran-adp51/jmsadapter.jar:/app/wlserver_10.3/server/lib/jms-xa-adp/jmsadapter.jar:/app/wlserver_10.3/server/lib/jms51-interop.jar:/app/wlserver_10.3/server/lib/jrmp.jar:/app/wlserver_10.3/server/lib/jrmpclient.jar:/app/wlserver_10.3/server/lib/jsafeFIPS.jar:/app/wlserver_10.3/server/lib/mbeantypes/WLSSSecurityProviders.jar:/app/wlserver_10.3/server/lib/mbeantypes/cssWlSecurityProviders.jar:/app/wlserver_10.3/server/lib/mbeantypes/saml2CredentialMapper.jar:/app/wlserver_10.3/server/lib/mbeantypes/saml2IdentityAsserter.jar:/app/wlserver_10.3/server/lib/mbeantypes/systemPasswordValidatorProvider.jar:/app/wlserver_10.3/server/lib/mbeantypes/wlManagementImplSource.jar:/app/wlserver_10.3/server/lib/mbeantypes/wlManagementMBean.jar:/app/wlserver_10.3/server/lib/mbeantypes/xacmlSecurityProviders.jar:/app/wlserver_10.3/server/lib/mejb.jar:/app/wlserver_10.3/server/lib/mysql-connector-java-commercial-5.0.3-bin.jar:/app/wlserver_10.3/server/lib/ojdbc6.jar:/app/wlserver_10.3/server/lib/pcl2.jar:/app/wlserver_10.3/server/lib/schema/diagnostics-binding.jar:/app/wlserver_10.3/server/lib/schema/diagnostics-image-binding.jar:/app/wlserver_10.3/server/lib/schema/weblogic-domain-binding-compatibility.jar:/app/wlserver_10.3/server/lib/schema/weblogic-domain-binding.jar:/app/wlserver_10.3/server/lib/weblogic-L10N.jar:/app/wlserver_10.3/server/lib/weblogic-de.jar:/app/wlserver_10.3/server/lib/weblogic-es.jar:/app/wlserver_10.3/server/lib/weblogic-fr.jar:/app/wlserver_10.3/server/lib/weblogic-it.jar:/app/wlserver_10.3/server/lib/weblogic-ja.jar:/app/wlserver_10.3/server/lib/weblogic-ko.jar:/app/wlserver_10.3/server/lib/weblogic-pt_BR.jar:/app/wlserver_10.3/server/lib/weblogic-spring.jar:/app/wlserver_10.3/server/lib/weblogic-zh_CN.jar:/app/wlserver_10.3/server/lib/weblogic-zh_TW.jar:/app/wlserver_10.3/server/lib/weblogic.jar:/app/wlserver_10.3/server/lib/webserviceclient+ssl.jar:/app/wlserver_10.3/server/lib/webserviceclient.jar:/app/wlserver_10.3/server/lib/webservices.jar:/app/wlserver_10.3/server/lib/wl-j2ee-client.jar:/app/wlserver_10.3/server/lib/wlcipher.jar:/app/wlserver_10.3/server/lib/wlclient.jar:/app/wlserver_10.3/server/lib/wlcommons-logging.jar:/app/wlserver_10.3/server/lib/wlconnector.jar:/app/wlserver_10.3/server/lib/wldb2.jar:/app/wlserver_10.3/server/lib/wldeploy.jar:/app/wlserver_10.3/server/lib/wlfullclient.jar:/app/wlserver_10.3/server/lib/wlinformix.jar:/app/wlserver_10.3/server/lib/wljarbuilder.jar:/app/wlserver_10.3/server/lib/wljmsclient.jar:/app/wlserver_10.3/server/lib/wljmxclient.jar:/app/wlserver_10.3/server/lib/wllog4j.jar:/app/wlserver_10.3/server/lib/wlnmclient.jar:/app/wlserver_10.3/server/lib/wls-api.jar:/app/wlserver_10.3/server/lib/wlsafclient.jar:/app/wlserver_10.3/server/lib/wlsqlserver.jar:/app/wlserver_10.3/server/lib/wlsybase.jar:/app/wlserver_10.3/server/lib/wlthint3client.jar:/app/wlserver_10.3/server/lib/wlw-langx-ja.jar:/app/wlserver_10.3/server/lib/wlw-langx-ko.jar:/app/wlserver_10.3/server/lib/wlw-langx-zh_CN.jar:/app/wlserver_10.3/server/lib/wlw-langx-zh_TW.jar:/app/wlserver_10.3/server/lib/wlw-langx.jar:/app/wlserver_10.3/server/lib/wlw-wsee-soapfault.jar:/app/wlserver_10.3/server/lib/wsee_scj/wseejb.jar:/app/wlserver_10.3/server/lib/wseeclient.jar:/app/wlserver_10.3/server/lib/wsse.jar:/app/wlserver_10.3/server/lib/xmlx.jar:/app/wlserver_10.3/server/lib/xqrl.jar
Class weblogic.ant.taskdefs.j2ee.Appc loaded from parent loader (parentFirst)
+Datatype wlappc weblogic.ant.taskdefs.j2ee.Appc
Adding reference: eclipse.ant.targetVector
Build sequence for target(s) `appc' is [appc]
Complete build sequence is [appc, ]
appc:
[wlappc] [JspcInvoker]Checking web app for compliance.
[wlappc] [jspc] Overriding descriptor option 'keepgenerated' with value specified on command-line 'true'
[wlappc] [jspc] -webapp specified, searching . for JSPs
[wlappc] [jspc] Compiling /index.jsp
[wlappc] <Dec 5, 2010 12:08:52 PM CET> <Info> <J2EE> <BEA-160220> <Compilation completed successfully>
BUILD SUCCESSFUL




java weblogic.appc -help
Usage: java weblogic.appc [options] <ear, jar, war or rar file or directory>

where options include:
-help Print the standard usage message.
-version Print version information.
-output <file> Specifies an alternate output archive or
directory. If not set, output will be
placed in the source archive or directory.
-plan <file> Specifies an optional deployment plan.
-forceGeneration Force generation of EJB and JSP classes.
Without this flag the classes may not be
regenerated if it is determined to be
unnecessary.
-quiet Turns off output except for errors
-lineNumbers Add JSP line numbers to generated class
files to aid in debugging.
-library <file> Comma-separated list of libraries. Each
library may optionally set its name and
versions, if not already set in its
manifest, using the following syntax: <file>
[@name=<string>@libspecver=<version>
@libimplver=<version|string>]
-librarydir <dir> Registers all files in specified directory
as libraries.
-writeInferredDescriptors Write out the descriptors with inferred
information including annotations.
-manifest <file> Include manifest information from specified
manifest file.
-clientJarOutputDir <dir> Specifies a directory to put generated
client jars.
-keepgenerated Keep the generated .java files.
-verbose Compile with verbose output.
-classpath <path> Classpath to use.
-source <source> Source version.
-target <target> Target version.
-advanced Print advanced usage options.



 java weblogic.appc -verbose -keepgenerated .
[JspcInvoker]Checking web app for compliance.
[jspc] Overriding descriptor option 'keepgenerated' with value specified on command-line 'true'
[jspc] -webapp specified, searching . for JSPs
[jspc] Compiling /index.jsp
<Dec 4, 2010 4:38:03 PM CET> <Info> <J2EE> <BEA-160220> <Compilation completed successfully>


ls -lR
.:
total 24
-rw-r--r--. 1 dave vesedan 353 Dec 4 15:42 index.jsp
drwxr-xr-x. 2 dave vesedan 4096 Dec 4 15:40 META-INF
drwxr-xr-x. 4 dave vesedan 4096 Dec 4 16:22 WEB-INF

./META-INF:
total 8
-rw-r--r--. 1 dave vesedan 39 Dec 4 15:40 MANIFEST.MF

./WEB-INF:
total 32
drwxr-xr-x. 3 dave vesedan 4096 Dec 4 16:22 classes
drwxr-xr-x. 2 dave vesedan 4096 Dec 4 15:40 lib
-rw-r--r--. 1 dave vesedan 536 Dec 4 15:40 weblogic.xml
-rw-r--r--. 1 dave vesedan 701 Dec 4 15:40 web.xml

./WEB-INF/classes:
total 8
drwxr-xr-x. 2 dave vesedan 4096 Dec 4 16:22 jsp_servlet

./WEB-INF/classes/jsp_servlet:
total 20
-rw-r--r--. 1 dave vesedan 4888 Dec 4 16:22 __index.class
-rw-r--r--. 1 dave vesedan 3814 Dec 4 16:22 __index.java

./WEB-INF/lib:
total 0



Compile JSF web project
JSF library needed
<wls:weblogic-web-app xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.1/weblogic-web-app.xsd">
<wls:weblogic-version>10.3.3</wls:weblogic-version>
<wls:context-root>testJSF</wls:context-root>
<wls:library-ref>
<wls:library-name>jsf</wls:library-name>
<wls:specification-version>1.2</wls:specification-version>
<wls:exact-match>true</wls:exact-match>
</wls:library-ref>
</wls:weblogic-web-app>


Eclipse Shared libraries


JSF shared library




java weblogic.appc -verbose -keepgenerated testJSF/WebContent/
Unresolved WebApp library references defined in weblogic.xml, of module 'WebContent' [Extension-Name: jsf, Specification-Version: 1.2, exact-match: true]
[dave@dave wls1033]$ java weblogic.appc -verbose -keepgenerated -library /usr/app/wlserver_10.3/common/deployable-libraries/jsf-1.2.war testJSF/WebContent/
<Dec 5, 2010 1:45:33 PM CET> <Info> <J2EE> <BEA-160151> <Registered library Extension-Name: jsf, Specification-Version: 1.2, Implementation-Version: 1.2.9.0 (WAR).>
[JspcInvoker]Checking web app for compliance.
<Dec 5, 2010 1:45:37 PM CET> <Info> <HTTP> <BEA-101047> <[ComplianceChecker] Validating the servlet element with servlet-name named "Faces Servlet".>
<Dec 5, 2010 1:45:38 PM CET> <Info> <HTTP> <BEA-101047> <[ComplianceChecker] Checking servlet-mapping for servlet name : "Faces Servlet".>
[jspc] Overriding descriptor option 'keepgenerated' with value specified on command-line 'true'
[jspc] -webapp specified, searching . for JSPs
[jspc] Compiling /index.jsp
<Dec 5, 2010 1:45:50 PM CET> <Info> <J2EE> <BEA-160220> <Compilation completed successfully>


Use separate classpath for compilation if there are libraries in WEB-INF/lib
<project name="Appc" default="appc" basedir="./">

<target name="appc" description="Packages the WAR file">
<!-- Precompile JSP pages using appc -->
<echo message="Precompile JSP pages using appc in ${assemble.war}" />
<path id="wlappc.classpath">
<fileset dir="${env.WL_HOME}/server/lib">
<include name="weblogic.jar" />
</fileset>
</path>
<path id="compile.classpath">
<fileset dir="${assemble.war}/WEB-INF/lib">
<include name="*.jar" />
</fileset>
</path>

<echo message="${toString:wlappc.classpath}" />
<taskdef name="wlappc" classname="weblogic.ant.taskdefs.j2ee.Appc"
classpathref="wlappc.classpath" />
<wlappc verbose="true" forcegeneration="true" source="${assemble.war}"
classpathref="compile.classpath">

</wlappc>

</target>


</project>

Sunday, November 28, 2010

Securing Resources Using Roles and Policies for Oracle WebLogic Server

Securing Resources Using Roles and Policies for Oracle WebLogic Server
http://download.oracle.com/docs/cd/E14571_01/web.1111/e13747/toc.htm

Securing Enterprise JavaBeans (EJBs)

http://download.oracle.com/docs/cd/E14571_01/web.1111/e13711/ejb_client.htm#SCPRG286


externally-defined

The externally-defined element lets you explicitly indicate that you want the security roles defined by the role-name element in the weblogic-ejb-jar.xml deployment descriptors to use the mappings specified in the Administration Console. The element gives you the flexibility of not having to specify a specific security role mapping for each security role defined in the deployment descriptors for a particular Web application. Therefore, within the same security realm, deployment descriptors can be used to specify and modify security for some applications while the Administration Console can be used to specify and modify security for others.

Defined in descriptor
ejb-jar.xml entries:
...
<assembly-descriptor>
<security-role>
<role-name>manger</role-name>
</security-role>
<security-role>
<role-name>east</role-name>
</security-role>
<method-permission>
<role-name>manager</role-name>
<role-name>east</role-name>
<method>
<ejb-name>accountsPayable</ejb-name>
<method-name>getReceipts</method-name>
</method>
</method-permission>
...
</assembly-descriptor>
...
weblogic-ejb-jar.xml entries:
<security-role-assignment>
<role-name>manager</role-name>
<principal-name>joe</principal-name>
<principal-name>Bill</principal-name>
<principal-name>Mary</principal-name>

...
</security-role-assignment>



Externally defined in Admin Console
ejb-jar.xml entries:
...
<assembly-descriptor>
<security-role>
<role-name>manger</role-name>
</security-role>
<security-role>
<role-name>east</role-name>
</security-role>
<method-permission>
<role-name>manager</role-name>
<role-name>east</role-name>
<method>
<ejb-name>accountsPayable</ejb-name>
<method-name>getReceipts</method-name>
</method>
</method-permission>
...
</assembly-descriptor>
...
weblogic-ejb-jar.xml entries:
<security-role-assignment>
<role-name>manager</role-name>
<externally-defined/>

...
</security-role-assignment>




Using run-as-role in case anonymous access is forbidden
In the ejb-jar.xml file:
// Beans "A_EJB_with_runAs_role_X" and "B_EJB_with_runAs_role_X"
// specify a security-identity run-as role-name "runAs_role_X".
// Bean "C_EJB_with_runAs_role_Y" specifies a security-identity
// run-as role-name "runAs_role_Y".
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>SecurityEJB</ejb-name>
<home>weblogic.ejb20.SecuritySLHome</home>
<remote>weblogic.ejb20.SecuritySL</remote>
<local-home>
weblogic.ejb20.SecurityLocalSLHome
</local-home>
<local>weblogic.ejb20.SecurityLocalSL</local>
<ejb-class>weblogic.ejb20.SecuritySLBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
<message-driven>
<ejb-name>SecurityEJB</ejb-name>
<ejb-class>weblogic.ejb20.SecuritySLBean</ejb-class>
<transaction-type>Container</transaction-type>
<security-identity>
<run-as>
<role-name>runAs_role_X</role-name>
</run-as>
</security-identity>
<security-identity>
<run-as>
<role-name>runAs_role_Y</role-name>
</run-as>
</security-identity>
</message-driven>
</enterprise-beans>
</ejb-jar>

weblogic-ejb-jar file:

<weblogic-ejb-jar>
<weblogic-enterprise-bean>
<ejb-name>A_EJB_with_runAs_role_X</ejb-name>
</weblogic-enterprise-bean>
<weblogic-enterprise-bean>
<ejb-name>B_EJB_with_runAs_role_X</ejb-name>
<run-as-principal-name>Joe</run-as-principal-name>
</weblogic-enterprise-bean>
<weblogic-enterprise-bean>
<ejb-name>C_EJB_with_runAs_role_Y</ejb-name>
</weblogic-enterprise-bean>
<security-role-assignment>
<role-name>runAs_role_Y</role-name>
<principal-name>Harry</principal-name>
<principal-name>John</principal-name>
</security-role-assignment>
<run-as-role-assignment>
<role-name>runAs_role_X</role-name>
<run-as-principal-name>Fred</run-as-principal-name>
</run-as-role-assignment>
</weblogic-ejb-jar>




If you see this error in logs/DefaultAuditRecorder.log when anonymous access to WLS JNDI tree is disabled

#### Audit Record Begin Nov 30, 2010 1:42:14 PM Severity =FAILURE Event Type = Authorization Audit Event V2 Subject: 0
ONCEjndi type= jndi , application=, path={weblogic}, action=lookup Audit Record End ####


you can disable internal WLS application
Async web service support is not fully configured. The async response web service /AsyncResponseServiceSoap12Https for this server was not fully deployed because the JMS reliability queue was not defined/deployed: weblogic.wsee.DefaultQueue. The server will periodically retry completing the deploy for the service. This message can usually be ignored unless there are async web service applications. To completely disable async web service support, thus avoiding this message, set -Dweblogic.wsee.skip.async.response=true

Internal WLS applications deployed on each server
./servers/ServerA1/tmp/_WL_internal/bea_wls_deployment_internal/voxsyv/war/WEB-INF/web.xml
./servers/ServerA1/tmp/_WL_internal/bea_wls9_async_response/39a4jn/war/WEB-INF/webservices.xml
./servers/ServerA1/tmp/_WL_internal/bea_wls9_async_response/39a4jn/war/WEB-INF/weblogic-webservices-policy.xml
./servers/ServerA1/tmp/_WL_internal/bea_wls9_async_response/39a4jn/war/WEB-INF/AsyncResponseService.xml
./servers/ServerA1/tmp/_WL_internal/bea_wls9_async_response/39a4jn/war/WEB-INF/web.xml
./servers/ServerA1/tmp/_WL_internal/bea_wls9_async_response/39a4jn/war/WEB-INF/AsyncResponseService-annotation.xml
./servers/ServerA1/tmp/_WL_internal/bea_wls9_async_response/39a4jn/war/WEB-INF/AsyncResponseServiceSoap12.xml
./servers/ServerA1/tmp/_WL_internal/bea_wls9_async_response/39a4jn/war/WEB-INF/weblogic.xml
./servers/ServerA1/tmp/_WL_internal/bea_wls9_async_response/39a4jn/war/WEB-INF/AsyncResponseServiceSoap12-annotation.xml
./servers/ServerA1/tmp/_WL_internal/bea_wls9_async_response/39a4jn/war/WEB-INF/weblogic-webservices.xml
./servers/ServerA1/tmp/_WL_internal/bea_wls_internal/hta2i5/war/WEB-INF/web.xml
./servers/ServerA1/tmp/_WL_internal/bea_wls_internal/hta2i5/war/WEB-INF/weblogic.xml
./servers/ServerA1/tmp/_WL_internal/bea_wls_cluster_internal/px8ma5/war/WEB-INF/web.xml
./servers/ServerA1/tmp/_WL_internal/bea_wls_cluster_internal/px8ma5/war/WEB-INF/weblogic.xml

Saturday, November 27, 2010

Weblogic server diagnostic image

Take diagnostic image


 unzip -l diagnostic_image_AdminServer_2010_11_27_12_44_12.zip 
Archive: diagnostic_image_AdminServer_2010_11_27_12_44_12.zip
Length Date Time Name
--------- ---------- ----- ----
4440 11-27-2010 12:44 JTA.img
161 11-27-2010 12:44 WatchSource.img
6298 11-27-2010 12:44 configuration.img
3369 11-27-2010 12:44 WORK_MANAGER.img
11619 11-27-2010 12:44 JNDI_IMAGE_SOURCE.img
215601 11-27-2010 12:44 APPLICATION.img
181 11-27-2010 12:44 InstrumentationImageSource.img
586 11-27-2010 12:44 SAF.img
368637 11-27-2010 12:44 Logging.img
12372 11-27-2010 12:44 PERSISTENT_STORE.img
27011 11-27-2010 12:44 JDBC.img
66 11-27-2010 12:44 PathService.img
429 11-27-2010 12:44 JMS.img
6154 11-27-2010 12:44 Deployment.img
34792 11-27-2010 12:44 JVM.img
223 11-27-2010 12:44 CONNECTOR.img
29455 11-27-2010 12:44 image.summary
--------- -------
721394 17 files



JDBC.img
more JDBC.img 
Dumping Resource Pool:XE
Resource Pool:XE:dumpPool Current Capacity = 15
Resource Pool:XE:dumpPool dumping available resources, #entries = 0
Resource Pool:XE:dumpPool dumping reserved resources, #entries = 15
Resource Pool:XE:dumpPool reserved[0] = autoCommit=true,enabled=true,isXA=true,isJTS=false,vendorID=0,connUsed=true,doInit=false,'null',destroyed=false,poolname=XE,appname=null,moduleName=null,connectTi
me=126,dirtyIsolationLevel=false,initialIsolationLevel=2,infected=false,lastSuccessfulConnectionUse=1290858199133,secondsToTrustAnIdlePoolConnection=10,currentUser=java.lang.Exception
at weblogic.jdbc.common.internal.ConnectionEnv.setup(ConnectionEnv.java:318)
at weblogic.common.resourcepool.ResourcePoolImpl.reserveResource(ResourcePoolImpl.java:344)
at weblogic.common.resourcepool.ResourcePoolImpl.reserveResource(ResourcePoolImpl.java:322)
at weblogic.jdbc.common.internal.ConnectionPool.reserve(ConnectionPool.java:438)
at weblogic.jdbc.common.internal.ConnectionPool.reserve(ConnectionPool.java:317)
at weblogic.jdbc.common.internal.ConnectionPoolManager.reserve(ConnectionPoolManager.java:93)
at weblogic.jdbc.common.internal.ConnectionPoolManager.reserve(ConnectionPoolManager.java:61)
at weblogic.jdbc.jta.DataSource.getXAConnectionFromPool(DataSource.java:1670)
at weblogic.jdbc.jta.DataSource.refreshXAConnAndEnlist(DataSource.java:1468)
at weblogic.jdbc.wrapper.JTAConnection.getXAConn(JTAConnection.java:199)
at weblogic.jdbc.wrapper.JTAConnection.checkConnection(JTAConnection.java:68)
at weblogic.jdbc.wrapper.Connection.preInvocationHandler(Connection.java:93)
at weblogic.jdbc.wrapper.Connection.prepareStatement(Connection.java:480)
at dave.DbExecutor.run(DbExecutor.java:24)
at java.lang.Thread.run(Thread.java:619)
,currentThread=Thread[Thread-131,5,Pooled Threads],lastUser=null,currentError=null,currentErrorTimestamp=null,JDBC4Runtime=true,supportStatementPoolable=true,needRestoreClientInfo=false,defaultClientInf
o={},supportIsValid=true
Resource Pool:XE:dumpPool reserved[1] = autoCommit=true,enabled=true,isXA=true,isJTS=false,vendorID=0,connUsed=true,doInit=false,'null',destroyed=false,poolname=XE,appname=null,moduleName=null,connectTi
me=219,dirtyIsolationLevel=false,initialIsolationLevel=2,infected=false,lastSuccessfulConnectionUse=1290858199286,secondsToTrustAnIdlePoolConnection=10,currentUser=java.lang.Exception
at weblogic.jdbc.common.internal.ConnectionEnv.setup(ConnectionEnv.java:318)
at weblogic.common.resourcepool.ResourcePoolImpl.reserveResource(ResourcePoolImpl.java:344)
at weblogic.common.resourcepool.ResourcePoolImpl.reserveResource(ResourcePoolImpl.java:322)
at weblogic.jdbc.common.internal.ConnectionPool.reserve(ConnectionPool.java:438)
at weblogic.jdbc.common.internal.ConnectionPool.reserve(ConnectionPool.java:317)
at weblogic.jdbc.common.internal.ConnectionPoolManager.reserve(ConnectionPoolManager.java:93)
at weblogic.jdbc.common.internal.ConnectionPoolManager.reserve(ConnectionPoolManager.java:61)
at weblogic.jdbc.jta.DataSource.getXAConnectionFromPool(DataSource.java:1670)
at weblogic.jdbc.jta.DataSource.refreshXAConnAndEnlist(DataSource.java:1468)
at weblogic.jdbc.wrapper.JTAConnection.getXAConn(JTAConnection.java:199)
at weblogic.jdbc.wrapper.JTAConnection.checkConnection(JTAConnection.java:68)
at weblogic.jdbc.wrapper.Connection.preInvocationHandler(Connection.java:93)
at weblogic.jdbc.wrapper.Connection.prepareStatement(Connection.java:480)
at dave.DbExecutor.run(DbExecutor.java:24)
at java.lang.Thread.run(Thread.java:619)
,currentThread=Thread[Thread-128,5,Pooled Threads],lastUser=null,currentError=null,currentErrorTimestamp=null,JDBC4Runtime=true,supportStatementPoolable=true,needRestoreClientInfo=false,defaultClientInf
o={},supportIsValid=true
Resource Pool:XE:dumpPool reserved[2] = autoCommit=true,enabled=true,isXA=true,isJTS=false,vendorID=0,connUsed=true,doInit=false,'null',destroyed=false,poolname=XE,appname=null,moduleName=null,connectTi
me=232,dirtyIsolationLevel=false,initialIsolationLevel=2,infected=false,lastSuccessfulConnectionUse=1290858199279,secondsToTrustAnIdlePoolConnection=10,currentUser=java.lang.Exception
at weblogic.jdbc.common.internal.ConnectionEnv.setup(ConnectionEnv.java:318)
at weblogic.common.resourcepool.ResourcePoolImpl.reserveResource(ResourcePoolImpl.java:344)
at weblogic.common.resourcepool.ResourcePoolImpl.reserveResource(ResourcePoolImpl.java:322)
at weblogic.jdbc.common.internal.ConnectionPool.reserve(ConnectionPool.java:438)
at weblogic.jdbc.common.internal.ConnectionPool.reserve(ConnectionPool.java:317)
at weblogic.jdbc.common.internal.ConnectionPoolManager.reserve(ConnectionPoolManager.java:93)
at weblogic.jdbc.common.internal.ConnectionPoolManager.reserve(ConnectionPoolManager.java:61)
at weblogic.jdbc.jta.DataSource.getXAConnectionFromPool(DataSource.java:1670)
at weblogic.jdbc.jta.DataSource.refreshXAConnAndEnlist(DataSource.java:1468)
at weblogic.jdbc.wrapper.JTAConnection.getXAConn(JTAConnection.java:199)
at weblogic.jdbc.wrapper.JTAConnection.checkConnection(JTAConnection.java:68)
at weblogic.jdbc.wrapper.Connection.preInvocationHandler(Connection.java:93)
at weblogic.jdbc.wrapper.Connection.prepareStatement(Connection.java:480)
at dave.DbExecutor.run(DbExecutor.java:24)
at java.lang.Thread.run(Thread.java:619)
,currentThread=Thread[Thread-126,5,Pooled Threads],lastUser=null,currentError=null,currentErrorTimestamp=null,JDBC4Runtime=true,supportStatementPoolable=true,needRestoreClientInfo=false,defaultClientInf
o={},supportIsValid=true
Resource Pool:XE:dumpPool reserved[3] = autoCommit=true,enabled=true,isXA=true,isJTS=false,vendorID=0,connUsed=true,doInit=false,'null',destroyed=false,poolname=XE,appname=null,moduleName=null,connectTi
me=206,dirtyIsolationLevel=false,initialIsolationLevel=2,infected=false,lastSuccessfulConnectionUse=1290858199262,secondsToTrustAnIdlePoolConnection=10,currentUser=java.lang.Exception
at weblogic.jdbc.common.internal.ConnectionEnv.setup(ConnectionEnv.java:318)
at weblogic.common.resourcepool.ResourcePoolImpl.reserveResource(ResourcePoolImpl.java:344)
at weblogic.common.resourcepool.ResourcePoolImpl.reserveResource(ResourcePoolImpl.java:322)
at weblogic.jdbc.common.internal.ConnectionPool.reserve(ConnectionPool.java:438)
at weblogic.jdbc.common.internal.ConnectionPool.reserve(ConnectionPool.java:317)
at weblogic.jdbc.common.internal.ConnectionPoolManager.reserve(ConnectionPoolManager.java:93)
at weblogic.jdbc.common.internal.ConnectionPoolManager.reserve(ConnectionPoolManager.java:61)
at weblogic.jdbc.jta.DataSource.getXAConnectionFromPool(DataSource.java:1670)
at weblogic.jdbc.jta.DataSource.refreshXAConnAndEnlist(DataSource.java:1468)
at weblogic.jdbc.wrapper.JTAConnection.getXAConn(JTAConnection.java:199)
at weblogic.jdbc.wrapper.JTAConnection.checkConnection(JTAConnection.java:68)
at weblogic.jdbc.wrapper.Connection.preInvocationHandler(Connection.java:93)
at weblogic.jdbc.wrapper.Connection.prepareStatement(Connection.java:480)
at dave.DbExecutor.run(DbExecutor.java:24)
at java.lang.Thread.run(Thread.java:619)

Connection pool overload on Weblogic server - forcibly release inactive connection

The number of inactive seconds on a reserved connection before WebLogic Server reclaims the connection and releases it back into the connection pool.

You can use the Inactive Connection Timeout feature to reclaim leaked connections - connections that were not explicitly closed by the application. Note that this feature is not intended to be used in place of properly closing connections.

When set to 0, the feature is disabled.

MBean Attribute (Does not apply to application modules) :
JDBCConnectionPoolParamsBean.InactiveConnectionTimeoutSeconds



Test classes which overload connection pool by holding connections
package dave;

import java.sql.Connection;
import java.sql.SQLException;

import javax.ejb.Stateless;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;

/**
* Session Bean implementation class TestSesssionEJB
*/
@Stateless(mappedName = "TestSesssionEJB")

public class TestSesssionEJB implements TestSesssionEJBRemote, TestSesssionEJBLocal {

/**
* Default constructor.
*/
public TestSesssionEJB() {


}

//@Resource (name="jdbc/XE")
//javax.sql.DataSource ds;

public String hello(String name){

System.out.println("Hello" + name);

InitialContext ic;
DataSource dsLookup = null;
try {
ic = new InitialContext();

dsLookup = (DataSource) ic
.lookup("jdbc/XE");
} catch (NamingException e) {
e.printStackTrace();
}


for(int i=0; i<15;i++){
Connection conn = null;
try {
conn = dsLookup.getConnection();
DbExecutor de = new DbExecutor(conn);
new Thread(de).start();
} catch (SQLException e) {
e.printStackTrace();
}

}

System.out.println("Main: started all");

return name;

}



}



package dave;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class DbExecutor implements Runnable {

Connection conn;

public DbExecutor(Connection conn) {
this.conn = conn;
}

@Override
public void run() {
try {
Thread thread = Thread.currentThread();

System.out.println("Start thread.id=" + thread.getId());

PreparedStatement stmt = conn
.prepareStatement("select * from dave");



System.out.println("Thread id=" + thread.getId() +
" Query dave db using container injected ds thread.id=");

stmt.execute();

ResultSet rs = stmt.getResultSet();

try {
System.out.println("Thread id=" + thread.getId() +
" gor result, going to sleep for 60 s");
Thread.sleep(60000);
} catch (InterruptedException e) {
e.printStackTrace();
}

while (rs.next()) {
System.out.println("Thread id=" +"dave=" + rs.getString("DSTR") + " id="
+ rs.getInt("ID"));
}

} catch (SQLException e) {
e.printStackTrace();
}

}





}


Overloaded JDBC connection pool statistics in Admin console



Admin server log for connection forcibly taken back by Weblogic
<Nov 27, 2010 12:22:25 PM CET> <Warning> <Common> <BEA-000620> <Forcibly releasing inactive resource "autoCommit=true,enabled=true,isXA=true,isJTS=false,vendorID=0,connUsed=false,doInit=false,'null',destroyed=false,poolname=XE,appname=null,moduleName=null,connectTime=100,dirtyIsolationLevel=false,initialIsolationLevel=2,infected=false,lastSuccessfulConnectionUse=1290856766085,secondsToTrustAnIdlePoolConnection=10,currentUser=java.lang.Exception
at weblogic.jdbc.common.internal.ConnectionEnv.setup(ConnectionEnv.java:318)
at weblogic.common.resourcepool.ResourcePoolImpl.reserveResource(ResourcePoolImpl.java:344)
at weblogic.common.resourcepool.ResourcePoolImpl.reserveResource(ResourcePoolImpl.java:322)
at weblogic.jdbc.common.internal.ConnectionPool.reserve(ConnectionPool.java:438)
at weblogic.jdbc.common.internal.ConnectionPool.reserve(ConnectionPool.java:317)
at weblogic.jdbc.common.internal.ConnectionPoolManager.reserve(ConnectionPoolManager.java:93)
at weblogic.jdbc.common.internal.ConnectionPoolManager.reserve(ConnectionPoolManager.java:61)
at weblogic.jdbc.jta.DataSource.getXAConnectionFromPool(DataSource.java:1670)
at weblogic.jdbc.jta.DataSource.refreshXAConnAndEnlist(DataSource.java:1468)
at weblogic.jdbc.wrapper.JTAConnection.getXAConn(JTAConnection.java:199)
at weblogic.jdbc.wrapper.JTAConnection.checkConnection(JTAConnection.java:68)
at weblogic.jdbc.wrapper.Connection.preInvocationHandler(Connection.java:93)
at weblogic.jdbc.wrapper.Connection.prepareStatement(Connection.java:480)
at dave.DbExecutor.run(DbExecutor.java:24)
at java.lang.Thread.run(Thread.java:619)
,currentThread=Thread[Thread-70,5,Pooled Threads],lastUser=null,currentError=null,currentErrorTimestamp=null,JDBC4Runtime=true,supportStatementPoolable=true,needRestoreClientInfo=false,defaultClientInfo={},supportIsValid=true" back into the pool "XE".>
<Nov 27, 2010 12:22:25 PM CET> <Warning> <Common> <BEA-000620> <Forcibly releasing inactive resource "autoCommit=true,enabled=true,isXA=true,isJTS=false,vendorID=0,connUsed=false,doInit=false,'null',destroyed=false,poolname=XE,appname=null,moduleName=null,connectTime=337,dirtyIsolationLevel=false,initialIsolationLevel=2,infected=false,lastSuccessfulConnectionUse=1290856766082,secondsToTrustAnIdlePoolConnection=10,currentUser=java.lang.Exception
at weblogic.jdbc.common.internal.ConnectionEnv.setup(ConnectionEnv.java:318)
at weblogic.common.resourcepool.ResourcePoolImpl.reserveResource(ResourcePoolImpl.java:344)
at weblogic.common.resourcepool.ResourcePoolImpl.reserveResource(ResourcePoolImpl.java:322)
at weblogic.jdbc.common.internal.ConnectionPool.reserve(ConnectionPool.java:438)
at weblogic.jdbc.common.internal.ConnectionPool.reserve(ConnectionPool.java:317)
at weblogic.jdbc.common.internal.ConnectionPoolManager.reserve(ConnectionPoolManager.java:93)
at weblogic.jdbc.common.internal.ConnectionPoolManager.reserve(ConnectionPoolManager.java:61)
at weblogic.jdbc.jta.DataSource.getXAConnectionFromPool(DataSource.java:1670)
at weblogic.jdbc.jta.DataSource.refreshXAConnAndEnlist(DataSource.java:1468)
at weblogic.jdbc.wrapper.JTAConnection.getXAConn(JTAConnection.java:199)
at weblogic.jdbc.wrapper.JTAConnection.checkConnection(JTAConnection.java:68)
at weblogic.jdbc.wrapper.Connection.preInvocationHandler(Connection.java:93)
at weblogic.jdbc.wrapper.Connection.prepareStatement(Connection.java:480)
at dave.DbExecutor.run(DbExecutor.java:24)
at java.lang.Thread.run(Thread.java:619)
,currentThread=Thread[Thread-116,5,Pooled Threads],lastUser=java.lang.Throwable,currentError=null,currentErrorTimestamp=null,JDBC4Runtime=true,supportStatementPoolable=true,needRestoreClientInfo=false,defaultClientInfo={},supportIsValid=true" back into the pool "XE".>



Connection Pool Diagnostics

Inactive Connection Timeout

Create Java EE project using Eclipse Helios 3.6. and Weblogic 10.3.3

Add Weblogic 10.3.3 runtime in Servers tab

Create EAR project


Create EJB project

Create session EJB





Add Session EJB method implementation
package dave;

import javax.ejb.Stateless;

/**
* Session Bean implementation class TestSesssionEJB
*/
@Stateless(mappedName = "TestSesssionEJB")
public class TestSesssionEJB implements TestSesssionEJBRemote, TestSesssionEJBLocal {

/**
* Default constructor.
*/
public TestSesssionEJB() {


}

public String hello(String name){

System.out.println("Hello" + name);

return name;

}

}





Add EJB project into EAR


Run on Server - deployment




Create wlfullclient.jar by running in $WLS_HOME/server/lib
java -jar wljarbuilder.jar

Add wlfullclient.jar and testEJB project to client classpath


Create client class


Get EJB name from JNDI tree


Create client implementation
package dave;

import java.util.Hashtable;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class TestClient {

private static String INITIAL_CONTEXT_NAME = "weblogic.jndi.WLInitialContextFactory";
private static String PROVIDER_URL = "t3://localhost:7001";
private static String JNDI_NAME = "TestSesssionEJB#dave.TestSesssionEJBRemote";

public static void main(String[] args) throws Exception {

Context ctx = getInitialContext();

TestSesssionEJBRemote testEJB = (TestSesssionEJBRemote) ctx
.lookup(JNDI_NAME);

System.out.println("Say hello: " + testEJB.hello("dave"));

}

private static Context getInitialContext() throws NamingException {
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_NAME);
env.put(Context.PROVIDER_URL, PROVIDER_URL);
return new InitialContext(env);
}

}




Check server log
<Nov 27, 2010 8:44:32 AM CET> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to RUNNING> 
<Nov 27, 2010 8:44:32 AM CET> <Notice> <WebLogicServer> <BEA-000360> <Server started in RUNNING mode>
Nov 27, 2010 8:44:42 AM com.sun.faces.config.ConfigureListener contextInitialized
INFO: Initializing Sun's JavaServer Faces implementation (1.2_03-b04-FCS) for context '/console'
Nov 27, 2010 8:44:42 AM com.sun.faces.config.ConfigureListener contextInitialized
INFO: Completed initializing Sun's JavaServer Faces implementation (1.2_03-b04-FCS) for context '/console'

Hellodave

Thursday, November 18, 2010

Set JVM default property with _JAVA_OPTIONS

export _JAVA_OPTIONS=-Djava.awt.headless=true

java |more
Picked up _JAVA_OPTIONS: -Djava.awt.headless=true


Setting JVM -Djava.awt.headless=true is necessary if X server is not available.
Without this property following error is thrown:

Exception in thread "main" java.lang.InternalError: Can't connect to X11 window server using '' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.access$100(X11GraphicsEnvironment.java:52)
at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:155)
at java.security.AccessController.doPrivileged(Native Method)
at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:131)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:68)
at sun.font.FontManager.initSGEnv(FontManager.java:1307)
at sun.font.FontManager.findFont2D(FontManager.java:1984)
at java.awt.Font.getFont2D(Font.java:455)
at java.awt.Font.canDisplay(Font.java:1904)
at java.awt.Font.canDisplayUpTo(Font.java:1970)
at java.awt.font.TextLayout.singleFont(TextLayout.java:451)
at java.awt.font.TextLayout.<init>(TextLayout.java:509)
at org.apache.poi.hssf.usermodel.HSSFSheet.autoSizeColumn(HSSFSheet.java:1675)

Thursday, November 4, 2010

Parse connection string using Java RegEx

http://download.oracle.com/javase/tutorial/essential/regex/index.html

http://download.oracle.com/javase/6/docs/api/java/util/regex/package-summary.html

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class TestRegEx {

/**
* @param args
*/
public static void main(String[] args) {

String input = "dbuser:passwd@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(Host=dbhost)(PORT=1520)))(CONNECT_DATA=(SID=MY_DB)))";

getParam(input, "Host");
getParam(input, "HOST");
// getParam(input,"xHOST");

Pattern pattern = Pattern.compile("(\\w+)@(\\w+)/(\\S+)");
Matcher matcher = pattern.matcher("username@hostname//dir1/dir2");

if (matcher.matches()) {
System.out.println("User " + matcher.group(1));
System.out.println("Host " + matcher.group(2));
System.out.println("Dir " + matcher.group(3));
}

}

public static String getParam(String input, String paramName) {

Pattern pattern = Pattern.compile(paramName + "=(\\w+)",
Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(input);

System.out.println("Matching " + pattern.pattern());

if (matcher.find()) {
System.out.println("Matched " + matcher.group(1) + " in "
+ matcher.group(0));
return matcher.group(1);
} else {
throw new RuntimeException("Cannot find db connection parameter "
+ paramName + " in " + input);
}

}

}