Rumblings from a Technologist and Book author
Tuesday, January 12, 2010
SOA Management - Sample Chapter from Middleware Management Book
You can access the chapter at http://www.oracle.com/technology/books/pdfs/sample-soa-management.pdf
This book covers management of both Oracle Fusion Middleware (WebLogic/OC4J, SOA Suite, IDM, Coherence, Forms/Reports, etc. and non-Oracle Midddleware such as JBoss, Tomcat, Apache Http Server IBM WebSphere and Microsoft .Net/IIS, etc
You can purchase the book at Amazon at http://www.amazon.com/Middleware-Management-Enterprise-Manager-Control/dp/1847198341.
Also see details at http://www.packtpub.com/middleware-management-with-oracle-enterprise-manager-grid-control-10g-r5/book
Tuesday, November 17, 2009
Should Java be free from Sun/Oracle?
They are suggesting that Java/JCP should be freed from Sun/Oracle and controlled by some independent consortium (Java foundation) and have volunteered to throw money, time and energy behind Java. I don’t think SAP has contributed much to Java community in the past 15 years, besides furthering its own NetWeaver platform to attract developers to their proprietary application platform.
Interestingly enough they claim to have Java EE 5 certification for past two years. Note that Java EE 5 was finalized about two and half years back. I think they still do not have a production version of application server that supports Java EE 5. I could not find in their website about their production support even for J2EE 1.4. Their website still claims support for J2EE 1.3 as shown below:
http://www.sap.com/platform/netweaver/standardssupport/java.epx

They still have a developer preview for Java EE 5 at http://www.sdn.sap.com/irj/scn/downloads?rid=/library/uuid/00846edd-355b-2b10-f38c-df94ec96eb74

How can we believe that SAP will pump millions of dollars to an open consortium to support Java’s future growth when they have not invested money to build an application server that supports latest Java standards? I think they are just playing a devil’s role here to complicate matters with Oracle’s pending acquisition of Sun.
Without strong leadership, Java will perish. If we leave it to open source then it may fork and we will end up with several Java flavors and that will be a death blow to Java. Sun has invested billions of dollars on research, development and building the community around Java and should control it. If Oracle’s acquisition of Sun succeeds then Oracle should control Java/JCP, if it fails for some reasons then who should take over Sun (if SAP does!) should own Java!
That’s my 2 cents!
Tuesday, October 06, 2009
Book: Middleware Management with Enterprise Manager Grid Control
Tuesday, June 02, 2009
My JavaOne Presentation:
Here are details for the talk:
TS-3977 -Keeping a Relational Perspective for Optimizing the Java™ Persistence API
Thursday June 04 4:10 PM - 5:10 PM Hall E 134
If you are attending JavaOne this year, please attend the presentation. Also we have a book signing scheduled tomorrow (Wednesday June 3, 2pm at Java Book Store) so stop by if you want your book to be signed
-Debu
Friday, January 09, 2009
Using Quartz Scheduler on WebLogic Server
I'm not a Quartz expert but I keep on getting emails with Quartz questions as one of my blog was published as a featured article at TheServerSide.com 4-5 years back. I got some questions on using Quartz on WebLogic Server recently. I modified the original example to run on WebLogic Server.
You can download this sample from here.
1. This sample uses TestEJB which is a stateless bean that has yourMethod that need to be scheduled as a job/service.
2. This method execution is scheduled as a Job from from QuartzManagerBean which is EJB 3.0 Session bean.
3. A Generic Servlet QuartzServlet uses dependency injection to invoke the QuartzManager from its init() method.
4. The QuartzServlet is automatically loaded using load-on-start mechanism. Hence as soon as the application is deployed - the job will be submitted .
How to Run the Example
1. You can download the code example from here.
2. This is designed to be deployed in the exampleServer. If you want to deploy in a different domain/server you have to make appropriate changes to common.xml
3. Start your WebLogic Server. Unlike OC4J that requires –userThreads, no special parameter or flag is required for WebLogic to run the example.
4. Set your environment variables. If you are using examplesServer, you can use %BEA_HOME%\wlserver_10.3\samples\domains\wl_server\setExamplesEnv.bat script to set environment variables required to compile and deploy the application
5. To compile and deploy, just run
ant
You will see the application to be deployed in console where WebLogic Server was started.
Jan 9, 2009 10:45:54 AM org.quartz.plugins.management.ShutdownHookPlugin initial
INFO: Registering Quartz shutdown hook.
Jan 9, 2009 10:45:54 AM org.quartz.simpl.RAMJobStore initialize
INFO: RAMJobStore initialized.
Jan 9, 2009 10:45:54 AM org.quartz.impl.StdSchedulerFactory instantiate
INFO: Quartz scheduler 'WebLogicQuartzScheduler' initialized from default resour
ce file in Quartz package: 'quartz.properties'
Jan 9, 2009 10:45:54 AM org.quartz.impl.StdSchedulerFactory instantiate
INFO: Quartz scheduler version: 1.3.0
Jan 9, 2009 10:45:54 AM org.quartz.core.QuartzScheduler start
INFO: Scheduler WebLogicQuartzScheduler_$_one started.
Invoking EJB to schedule Job ..
0 0/5 * * * ?
Scheduling Job ..
0 0/5 * * * ?
Timer scheduled now ..
Generating report
Report Generation Completed
Hope this helps!
Thursday, November 13, 2008
Article:Managing Complexity with BPEL Environment
SOA World published an article on BPEL Management written by me with Arvind Maheshwari.
You can read the article: Managing Complexity with BPEL Management!
Thursday, November 06, 2008
Enterprise Java – State of the World!
One of my friends commented: “Java is no longer cool! Not hot either! What is the current state of enterprise Java?”
First it was .Net and then came a bonanza of scripting languages such as Ruby. All these technologies were there to eclipse the popularity of Java and J2EE. The hypes for these technologies were short-lived. The forecast for demise of Java EE was highly exaggerated. Java and J2EE still lives on!
I divide the players in the enterprise Java markets primarily into two buckets. The commercial vendors selling J2EE application server and the vendors building open source and so called free products. However a third force is emerging that is looking to disrupt the J2EE market space.
The commercial market space is now officially two horses’ race after Oracle acquired BEA. The battle is still on for the two traditional rivals! One application server (WebLogic) is stylish and always ahead with emerging technology and the other one proprietary loaded (Websphere) with the old baggage. Java EE 5 finalized in June 2006 and IBM Websphere just got certified with Java EE 5. That’s more than two years since the spec was finalized. That’s not strange though. JBoss that still do not have a production release that is Java EE 5 certified. Although they announced it's arrival more than a month back, I do not see a production version available as yet. They have a release candidate!
Now that we discussed JBoss’s certification issue let us look at the open source products. About two years back JBoss was the crown prince in the open source market. None of the other products Jonas, Glassfish or Geronimo had capabilities to challenge its supremacy. However JBoss lost the momentum in past year and half after being acquired by RedHat. Glassfish has gained a significant mindshare in last year and half thanks to their quality Java EE 5 implementation. I think the delay in shipping a quality Java EE 5 implementation by JBoss was a primary reason. Geronimo has not gotten much traction! However we should not forget that many customers still use Tomcat with just web applications. Although Tomcat does not have all bells and whistles of Java EE – it is still the most dominant open source container.
I put Spring in the third bucket. Spring is a great framework that makes application development simple. Java EE 5 borrowed a lot of great ideas from the Spring framework. Spring Framework certainly helped enterprise Java to go further. SpringSource, the company behind Spring Framework launched their OSGi-based application server named Spring dm Server. Spring dm Server not only competes with other application server vendors in the market. It also competes with Java EE! It allows you to deploy WAR modules and OSGi bundles. It is at its first version and lacks good high availability, manageability features. SpringSource hopes to implement part of Java EE 6 specs. If they are successful – Spring dm Server may be a disruptive force for the Java EE application server market. I will blog about my first impressions on Spring dm Server (write capabilities and limitations) in my upcoming blog.
Many people have raised concerns about slow adoption rate of Java EE 5. Is the slow adoption by two major players (IBM and JBoss) inhibiting the adoption rate for Java EE 5? Possibly! However we have to remember that for most companies, generating revenue is more important than the underlying technology. Many customers have deployed their applications using J2EE 1.4 and they achieved their performance and scalability goals so they cannot just throw those away and jump on to the Java EE 5 bandwagon. Having said that many customers are using Java EE 5 only with new development projects. The sales of my book has picked up lately.
With economy going down south- budgets for new projects are limited! Having said that Java is still the leading platform for building enterprise applications.
The JCP team is gearing up to finalize Java EE 6 by JavaOne 2009. This gives a fuzzy feeling that enterprise Java is still thriving. What do you think?
Wednesday, July 30, 2008
Using EJBContext from an EJB 3 Interceptor
I got a question from a customer that he wants to use EJBContext from an EJB 3 Interceptor.
Yes, it’s very simple. Just inject the EJBContext into the interceptor using @Resource injection.
See the example code that uses methods of SessionContext as follows:
package actionbazaar.buslogic;
import javax.annotation.Resource;
import javax.interceptor.AroundInvoke;
import javax.interceptor.InvocationContext;
public class CheckPermissionInterceptor {
@Resource
private javax.ejb.SessionContext ctx;
@AroundInvoke
public Object checkUserRole(InvocationContext ic) throws Exception {
System.out.println("*** CheckPermission Interceptor invoked for "
+ ic.getTarget() + " ***");
if (!ctx.isCallerInRole("admin")) {
throw new SecurityException("User: '"
+ ctx.getCallerPrincipal().getName()
+ "' does not have permissions for method "
+ ic.getMethod());
}
return ic.proceed();
}
}
If you want the run-able version of the example code, you can download from http://manning.com/panda and look at Chapter 5 example.
Monday, July 28, 2008
My Sessions at Oracle Open World 2008
I’ve two sessions at Oracle Open World 2008, San Francisco. Here are my session details:
Track: Application Server and Transaction Processing
Room: Rm 2006
Date: 2008-09-22
Start Time: 11:30
S298522 : Top Five Things DBAs Must Know About Managing Middleware
Track: Application Server and Transaction Processing
Room: Rm 2003
Date: 2008-09-25
Start Time: 15:00
See you at San Francisco!
Friday, July 18, 2008
EJB 3 In Action available at Safari Online
Monday, July 07, 2008
Introduction to EclipseLink
Thursday, June 26, 2008
EJB 3 Stateless bean Web service in WebLogic Server
First develop your EJB3 session bean web service as follows:
@WebService(name="PlaceBid",
serviceName="PlaceBidService", portName = "PlaceBidPort",
targetNamespace = "http://actionbazaar.com/xml")
@SOAPBinding(style = SOAPBinding.Style.DOCUMENT)
@PersistenceContext(unitName="actionBazaar",name="actionBazaar")
@Stateless
public class PlaceBidBean {
public Long addBid(String userId, Long itemId, Double bidPrice) throws BidException {
….
}
}
Deployment
Unlike OC4J, WebLogic do not support parsing of JAX-WS annotations at deployment time and if you try to deploy the compiled EJB 3 Web service, you will get deployment time exception. You have to run the EJB 3 WS thru annotation parsing tool (jwsc –java web services compile) supplied with WebLogic to generate the artifacts and package in your ejb-jar module.
Here is an example ant task to create the web service:
<target
name="build-ws-server" description="Target that builds the
target Web Service">
<jwsc
srcdir="${src.ejb.dir}"
destdir="${bld.service.dir}"
classpath="${common.j2ee.class.path}"
fork="true"
keepGenerated="true"
deprecation="${deprecation}"
keepTempFiles="true"
listfiles="true"
debug="${debug}">
<jws
file="actionbazaar/buslogic/PlaceBidBean.java" type="JAXWS"
explode="true"/>
</jwsc>
</target>
<target name="package-ejb"
depends="compile-ejb-classes,build-ws-server">;
<mkdir dir="${bld.ejb.dir}/actionbazaar/buslogic/jaxws" />
<copy todir="${bld.ejb.dir}/actionbazaar/buslogic/jaxws">
<fileset dir="${bld.service.dir}/actionbazaar/buslogic/PlaceBidBean/actionbazaar/buslogic/jaxws" includes="*"/> </copy>
<echo message="-----> Create EJB jar file"/>
<jar jarfile="${bld.ear.dir}/${ejb.name}.jar">
<fileset dir="${bld.ejb.dir}" includes="**" />
</jar>
</target >
Make sure to package the generated artifacts in the EJB JAR and then deploy the EJB-JAR or EAR to the WebLogic Server. Note that if your web service depends upon custom Java objects - the generated artifacts contain duplicate Java classes that you already may have. These duplicated classes are on a separate package structure and cause ClassCastException for me. So I avoid packaging these classes.
Accessing EJB 3 Web service
After successful deployment you can access the web service as follows:
http://hostname:port/ejb-name/web-service-name?wsdl
http://localhost:7001/PlaceBidBean/PlaceBidBeanService?wsdl
Hope this helps.
You can download the working examples from here. Chapter 15 contains web services example.
Friday, June 20, 2008
EJB 3, JPA, Web Services and Spring Examples for WebLogic Server
Finally I was able to complete porting of all book examples of EJB 3 In Action to run on WebLogic Server.
You can download these from here
These contain a host of examples on EJB 3, JPA, Web Services and Spring Framework. Now we have complete examples for four servers: Glassfish, OC4J, WebLogic and JBoss.
Note that I tested the examples with an Oracle XE database. For simplicity, the examples are configured to use the exampleServer and default PointBase DB that is shipped with it. However some of these examples will properly not on PointBase because it does not support DB Sequence.
All chapters have the common domain model based on our famous ActionBazaar Application
Chapter 5: EJB 3 Interceptors, Timers
Chapter 8: O-R Mapping Annotations
Chapter 9: Entity Manager API
Chapter 10: JPQL and Native SQL Queries
Chapter 11: O-R Mapping with XML
Chapter 12: EM API from Web Tier, Java SE
Chapter 13: Extended Persistence Context
Chapter 15: EJB 3 Web services
Chapter 16: Spring with EJB 3 and JPA
Please try these out and let me know if you find any bugs!
Monday, June 02, 2008
EJB 3 Dependency Injection Refcard

I wrote a Reference Card on EJB 3 Dependency Injection for Developer Zone. This is a quick reference card that describes metadata annotations and XML descriptor elements that you use for injecting resources and services.
You can access this reference card for free from Developer Zone at http://refcardz.dzone.com/refcardz/dependency-injection-in-ejb3
Tuesday, April 29, 2008
EJB 3 In Action Code Examples on WebLogic 10
In my previous blog, I made the code examples available for first four chapters of EJB 3 In Action for WebLogic 10. However I did not provide you instructions to run these examples (Chapter 2-4) for WebLogic 10.
Chapter 3 depends upon a JDBC DataSource and Chapter 4 uses JDBC DataSource and a JMS Queue.
- Download examples from here and unzip to a directory say c:\ejb3inaction\weblogic
- Set the environment variables for your server as follows:
%BEA_HOME%/wlserver_10.0/samples/domains/wl_server/setExamplesEnv
- Change to your directory to the directory
cd c:\ejb3inaction\weblogic
ant CreateResources
This will configure resources such as JDBC DataSource, JMS Connection Factory, Queues, etc.
4. To deploy the application, you can use WLS Admin Console. If you prefer you can use ant to deploy the application for a specific chapter.
cd chapter2
ant
- To run the application client:
ant run
Thursday, April 17, 2008
Diagnosing Production Java applications with AD4J
So I thought I would give Oracle AD4J a spin and will try to find out what is going! It is good that Oracle AD4J does not require any code changes in application, because it does not use byte code instrumentation. Nor does it require to restart/redeploy the application – so it was a perfect fit.
And it really helped diagnose the problem by me get into bottom of the issues. It was indeed a DB issue as I had initially suspected.
I will not bore you with installation and configuration steps of AD4J – rather I will outline how AD4J helped me diagnose the issue.
Finding the Offending Thread
As soon as I logon to AD4J console and clicked to view active threads – it showed all threads with the correct state and I saw one thread is with status “DBWait”.

That gave me an indication that something going fishy in the database request from from JPA provider.
Finding DB issue
When I clicked on DB Wait link to view details, it became clear that the transaction is running into some row lock contention with another user session.

Finding the SQL statement

It also helped me find the other session that held the lock. Apparently we found that it was a batch process that was hanging for some reasons. After the hanging session was killed the application ran like a champ again!
Also I found that the JPQL query for retrieving SRs was running slower because of some missing indexes on the column and it was making a full table scan. Nice, it also AD4J allows to run explain for sql statements.
Downloading AD4J
You can download AD4J from OTN (http://www.oracle.com/technology/software/products/oem/htdocs/jade.html)
Installing AD4J Console and agents
Installing AD4J Console is easy. You can follow this guide to do this installation of AD4J Console and agent.
After you deploy the agent you are good to go. Your JVM for application server will be automatically discovered in the console.
The AD4J agent is a WAR file that needs to be deployed to the server. You can follow the instructions in the install guide to install the agent in favorite application server. I was using my favorite container OC4J, however it supports BEA WebLogic, IBM Websphere, JBoss, and Tomcat. You can run AD4J also with standalone Java.
If you want to trace the problem to the DB tier you can install the DB Agent. You can follow the instructions in this guide.
I will play around with AD4J and blog little more about its feature in future. In the meantime you can review it's usage scenario documented in here.
Tuesday, April 15, 2008
My interview @Java Lobby
Monday, March 31, 2008
Using JMX to Start/Stop Message Driven Bean
OC4J 10.1.3.x allows users to start/stop MDBs dynamically without having recycle container or application.
For example, you can disable an MDB upon start/deployment by adding enabled="false" in your orion-ejb-jar.xml as follows
<message-driven-deployment name="MessageLogger" enabled="false">
MDB will not start when the application is deployed/started.
You can use Application Server Control to start the MDB later as shown in the following screen shot:
You may want to perform this operation from command line. You can download this zip file that contains code to stop/start MDB using JMX.
- Unpackage the zip and change ant-oracle.properties file to change your URL, userid and password
- Set ORACLE_HOME to the directory where OC4J installed
- To start your MDB:
ant start -DappName=ejb30mdb -DejbModule=ejb30mdb-ejb -DmdbName MessageLogger
- To stop it
ant stop -DappName=ejb30mdb -DejbModule=ejb30mdb-ejb -DmdbName MessageLogger
Following is the code snippet from the Java Class that perform the stop/start operation:
StartStopMDB mdb = new StartStopMDB();
try {
mdb.connect("service:jmx:"+args[0], args[1] ,args[2] );
System.out.println(mdb);
System.out.printf("Client connected? %s\n",mdb.isConnected());
MBeanServerConnection mbs = jmxCon.getMBeanServerConnection();
String objName = "oc4j:j2eeType=MessageDrivenBean,EJBModule=\""+args[4]
+"\",J2EEApplication="+args[3]+",J2EEServer=standalone,name=\""+args[5]+"\"";
ObjectName myMDBObjectName = new ObjectName(objName);
MessageDrivenBeanMBeanProxy MDBMBean =
(MessageDrivenBeanMBeanProxy)MBeanServerInvocationHandler.newProxyInstance(mbs,
myMDBObjectName, MessageDrivenBeanMBeanProxy.class, false);
if (args[6].equals("start"))
{
System.out.println("Starting up MDB: "+args[5] +" in ejb module:"+args[4]+
" in application name:"+args[3]);
MDBMBean.start();
System.out.println("Successfully started MDB!");
}
else if (args[6].equals("stop")) {
System.out.println("Stopping MDB: "+args[5] +
" in ejb module:"+args[4]+ " in application name:"+args[3]);
MDBMBean.stop();
System.out.println("Successfully started MDB!");
}
mdb.close();
} catch (Exception e) {
e.printStackTrace();
}
}
Hope this helps!
Wednesday, March 26, 2008
Using TopLink Essentials as the JPA Provider for WebLogic 10
First, you have to download TopLink Essentials either from OTN or Glassfish web site.
I packaged the toplink-essentals.jar, toplink-essentials-agent.jar in the lib directory for the EAR so the structure of EAR looked like as follows:
chapter2-ejb.jar
lib/toplink-essentials.jar
lib/toplink-essentials-agent.jar
I specified provider class oracle.toplink.essentials.PersistenceProvider
in my persistence.xml packaged in my EJB module as follows:
<persistence-unit name="actionBazaar">
<provider>
class oracle.toplink.essentials.PersistenceProvider
</provider>
<properties>
<property name="toplink.ddl-generation" value="create-tables"> <property name="toplink.ddl-generation.output-mode" value="database">
If you want to use container managed entity manager with WebLogic’s JTA transaction manager you have to create your server platform class by extending oracle.toplink.essentials.transaction.JTATransactionController as follows:
package debu.weblogic;
import javax.transaction.TransactionManager;
import oracle.toplink.essentials.transaction.JTATransactionController;
public class WebLogicTransactionController extends JTATransactionController
{
private static final String WLS_TRANSACTION_MANAGER_NAME = "javax.transaction.TransactionManager";
public WebLogicTransactionController(){
}
protected TransactionManager acquireTransactionManager() throws Exception {
TransactionManager tm = (TransactionManager)jndiLookup(WLS_TRANSACTION_MANAGER_NAME);
return tm;
}
}
As you might have seen already that I’ve specified this class as the target-server property in persistence class.
You can package this class as a part of your application in the same EAR file where you packaged the TopLink Essentials jar files and the entity classes.
Using TopLink 11 with WebLogic 10
If you are using TopLink 11 preview (or EclipseLink) you do not have to create your own server platform class but you can use the server platform shipped in toplink.jar for WebLogic 10.
Here is how your persistence.xml look like when you use TopLink 11.
<persistence-unit name="actionBazaar">
<provider>
oracle.toplink.PersistenceProvider
</provider>
<jta-data-source>
jdbc/ActionBazaarDS</jta-data-source>
<properties>
<property name="toplink.ddl-generation" value="create-tables">
<property name="toplink.ddl-generation.output-mode" value="database">
<property name="toplink.target-server" value="WebLogic_10">
</property>
Note that you have to package toplink-ojdbc.jar in addition to toplink.jar and antlr.jar if you are using Oracle DB as the underlying database.
Hope this helps.
Need to go to bed, feeling sleepy now!
Sunday, March 23, 2008
EJB 3 In Action Examples on WebLogic 10
java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory
That's it ..
In the next blog entry, I will discuss the code changes the instructions to run Chapter 2-4 and outline changes made to run JPA and MDB examples.