I am going to show how you would create a WebLogic data source to Pivotal GemFireXD 1.3. In this example I am using the developer edition of Weblogic which known as "Free Oracle WebLogic Server 12c (12.1.3) Zip Distribution and Installers for Developers" You can download / configure it as follows.
http://www.oracle.com/technetwork/middleware/downloads/index-087510.html
Note: I am assuming you have WebLogic 12C running with GemFireXD also running. I am also assuming a WLS install directory as follows with a domain called "mydomain"
/Users/papicella/vmware/software/weblogic/wls12130
1. Ensure you have the GemFireXD client driver copied into your WLS domain lib directory as follows, prior to starting WLS
/Users/papicella/vmware/software/weblogic/wls12130/user_projects/domains/mydomain/lib/gemfirexd-client.jar
2. Navigate to the WebLogic Console as follows
http://localhost:7001/console/
3. Login using your server credentials
4. From the Domain Structure tree navigate to "Services -> Data Sources"
5. Click on "New -> Generic Data Source"
6. Fill in the form as follows
Name: GemFireXD-DataSource
JNDI Name: jdbc/gemfirexd-ds
Type: Select "Other" from the drop down list box
7. Click "Next"
8. Click "Next"
9. Uncheck "Supports Global Transactions" and click next
10. Enter the following details for credentials. The GemFireXD cluster is not setup for auhentication so this is just a fake username/password to allow us to proceed.
Username: app
Password: app
11. Click "Next"
12. Enter the following CONFIG parameters for your GemFireXD Cluster
Driver Class Name: com.pivotal.gemfirexd.jdbc.ClientDriver
URL: jdbc:gemfirexd://localhost:1527/
Test Table Name: sysibm.sysdummy1
Leave the rest as their default values , it's vital you don't alter the default values here.
13. Click the "Test Configuration" button at this point to verify you can connect, if Successful you will see a message as follows
14. Click "Next"
15. Check the server you wish to target this Data Source for. If you don't do this the Data Source will not be deployed and accessible. In DEV only WLS you only have "myserver" to select.
16. Click "Finish"
It should show your all done and no re-starts are required. To access the Data Source you need to use JNDI with the path "jdbc/gemfirexd-ds"
Search This Blog
Showing posts with label Weblogic. Show all posts
Showing posts with label Weblogic. Show all posts
Thursday, 30 October 2014
Thursday, 7 July 2011
Starting a Coherence Server From WLS 10.3.4 Console
Decided it might make sense to use Node Manager to stop/start my stand alone coherence servers which will be accessed by the WebLogic managed server instances as storage disabled members. The process is pretty straight forward and is shown in this blog entry below. However there is one thing to be aware of.
http://blogs.oracle.com/jamesbayer/entry/weblogic_server_1034_screencas
In my example I wanted to use Coherence 3.7 and so to do that I needed to add the following to the "Server Start" Classpath field
/u01/Middleware/coherence/370/coherence/lib/coherence.jar
Once I did that and tried to start the Coherence Server from the admin console , using node manager it failed with an error as follows.
So what I needed was the following.
/u01/Middleware/coherence/370/coherence/lib/coherence.jar:/u01/Middleware/1034/modules/features/weblogic.server.modules.coherence.server_10.3.4.0.jar
Once started the Log file for the coherence server exists on the file system as follows:
$DOMAIN_HOME/servers_coherence/{COH_SERVER_NAME}/logs/{COH_SERVER_NAME}.out
The PID for the server is found here, I normally add that to the log file but it's not possible when starting Coherence this way.
$DOMAIN_HOME/servers_coherence/{COH_SERVER_NAME}/data/nodemanager/{COH_SERVER_NAME}.pid
http://blogs.oracle.com/jamesbayer/entry/weblogic_server_1034_screencas
In my example I wanted to use Coherence 3.7 and so to do that I needed to add the following to the "Server Start" Classpath field
/u01/Middleware/coherence/370/coherence/lib/coherence.jar
Once I did that and tried to start the Coherence Server from the admin console , using node manager it failed with an error as follows.
Jul 8, 2011 4:36:25 AM> <INFO> <NodeManager> <Server output log file
is
'/u01/Middleware/domains/1034/acs_dom/servers_coherence/CoherenceServer1/logs/CoherenceServer1.out'>
Exception in thread "Main Thread" java.lang.NoClassDefFoundError:
weblogic/nodemanager/server/provider/WeblogicCacheServer
Caused by: java.lang.ClassNotFoundException:
weblogic.nodemanager.server.provider.WeblogicCacheServer
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
The poblem here is if you leave the classpath blank in the startup properties in the console configuration, then the two minimal jars (weblogic.server.modules.coherence.server_10.3.4.0.jar and coherence.jar) that are required are added for you. Once you specify a non-empty classpath (which is what I did), then you have to explicitly include those jars plus any others you want.
So what I needed was the following.
/u01/Middleware/coherence/370/coherence/lib/coherence.jar:/u01/Middleware/1034/modules/features/weblogic.server.modules.coherence.server_10.3.4.0.jar
Once started the Log file for the coherence server exists on the file system as follows:
$DOMAIN_HOME/servers_coherence/{COH_SERVER_NAME}/logs/{COH_SERVER_NAME}.out
The PID for the server is found here, I normally add that to the log file but it's not possible when starting Coherence this way.
$DOMAIN_HOME/servers_coherence/{COH_SERVER_NAME}/data/nodemanager/{COH_SERVER_NAME}.pid
Monday, 4 July 2011
Installing WLS 10.3.4 domain across 2 Compute Nodes on Exalogic
Got a rare opportunity to access 2 compute nodes on Exalogic and I thought it would be a good opportunity to test creating a WLS domain across the 2 compute nodes. Here is some brief steps showing how this was done.
1. Create a share to be used by both compute nodes. In this demo we created one as follows.
2. Install WLS software onto the share as shown below.
3. Now we can create a PRODUCTION domain into a share in a directory as follows "/u01/Middleware/domains/1034/acs_dom". Ensure you create a machine for each compute node and ensure you place the managed servers you wish on each compute node in the domain config screens.
4. In this demo we want to create a node manager process on each compute node sharing the same domain directory. To do this we simply create seperate directories for each on our compute nodes and copy a set of node manager files available in the default $WLS_HOME/wlserver_10.3/common/nodemanager directory.
Example of node07 files
nodemanager.properties example, the HOME will differ in the node08 file.
NodeManagerHome=/u01/Middleware/domains/1034/nodemanager/node07
StartScriptEnabled=true
StopScriptEnabled=true
5. Edit startNodeManager.sh to include node manager home location now it's moved
away from WLS_HOME. Example for node07.
NODEMGR_HOME="/u01/Middleware/domains/1034/nodemanager/node07"
6. Start both node managers from there directories on each compute node, example for node07.
/u01/Middleware/domains/1034/nodemanager/node07/startNodeManager.sh
7. For the ADMIN SERVER node ensure we set the following in "startWebLogic.sh".
# START WEBLOGIC
JAVA_OPTIONS="${JAVA_OPTIONS} -Dweblogic.security.SSL.ignoreHostnameVerification=true"
echo "starting weblogic with Java version:"
8. Start admin server, here we use node07.
/u01/Middleware/domains/1034/acs_dom/bin/startWebLogic.sh
9. Log into the admin console
10. Ensure the node manager processes are available from each machine and reachable.
11. Start all managed servers, once you ensure the node manager is reachable. I prefer to start managed servers from the command line but given we have 2 node managers on the compute nodes we can use that through the admin console.
Example of such a setup.
1. Create a share to be used by both compute nodes. In this demo we created one as follows.
/u01/Middleware
2. Install WLS software onto the share as shown below.
[oracle@auxlcn07 1034]$ pwd /u01/Middleware/1034 [oracle@auxlcn07 1034]$ d total 148 drwxr-xr-x+ 7 oracle oinstall 464 Jun 30 21:25 modules/ drwxr-xr-x+ 8 oracle oinstall 9 Jun 30 21:25 utils/ drwxr-x---+ 7 oracle oinstall 9 Jun 30 21:25 jrockit_160_22_D1.1.1-3/ -rw-r--r--+ 1 oracle oinstall 623 Jun 30 21:25 ocm.rsp -rw-r--r--+ 1 oracle oinstall 73475 Jun 30 21:25 registry.dat -rw-r--r--+ 1 oracle oinstall 2306 Jun 30 21:25 registry.xml -rw-r--r--+ 1 oracle oinstall 26 Jun 30 21:25 .home drwxr-xr-x+ 8 oracle oinstall 13 Jun 30 21:25 ./ drwxr-xr-x+ 9 oracle oinstall 11 Jun 30 21:25 wlserver_10.3/ drwxr-xr-x+ 6 oracle oinstall 9 Jun 30 21:25 coherence_3.6/ -rw-rw----+ 1 oracle oinstall 192 Jul 1 08:25 domain-registry.xml drwxr-xr-x+ 2 oracle oinstall 12 Jul 1 17:16 logs/ drwx------+ 6 oracle oinstall 6 Jul 4 15:56 ../
3. Now we can create a PRODUCTION domain into a share in a directory as follows "/u01/Middleware/domains/1034/acs_dom". Ensure you create a machine for each compute node and ensure you place the managed servers you wish on each compute node in the domain config screens.
[oracle@auxlcn07 acs_dom]$ d total 23 drwxr-xr-x+ 4 oracle oinstall 4 Jul 1 08:25 ../ drwxr-x---+ 2 oracle oinstall 3 Jul 1 08:25 autodeploy/ drwxr-x---+ 2 oracle oinstall 3 Jul 1 08:25 console-ext/ drwxr-x---+ 2 oracle oinstall 3 Jul 1 08:25 lib/ drwxr-x---+ 2 oracle oinstall 6 Jul 1 08:25 security/ -rw-r-----+ 1 oracle oinstall 650 Jul 1 08:25 startManagedWebLogic_readme.txt drwxr-x---+ 2 oracle oinstall 7 Jul 1 08:25 init-info/ -rw-r-----+ 1 oracle oinstall 462 Jul 1 08:25 fileRealm.properties -rwxr-x---+ 1 oracle oinstall 252 Jul 1 08:25 startWebLogic.sh* drwxr-x---+ 10 oracle oinstall 12 Jul 1 08:26 config/ drwxr-x---+ 12 oracle oinstall 16 Jul 1 08:29 ./ drwxr-----+ 2 oracle oinstall 2 Jul 1 10:50 pending/ -rw-r-----+ 1 oracle oinstall 32 Jul 1 10:50 edit.lok drwxr-----+ 2 oracle oinstall 2 Jul 1 10:50 tmp/ drwxr-----+ 8 oracle oinstall 8 Jul 1 14:10 servers/ drwxr-x---+ 5 oracle oinstall 11 Jul 1 15:38 bin/
Note: No need for pack/unpack given we are using a share.
4. In this demo we want to create a node manager process on each compute node sharing the same domain directory. To do this we simply create seperate directories for each on our compute nodes and copy a set of node manager files available in the default $WLS_HOME/wlserver_10.3/common/nodemanager directory.
[oracle@auxlcn07 nodemanager]$ pwd /u01/Middleware/domains/1034/nodemanager [oracle@auxlcn07 nodemanager]$ d total 6 drwxr-xr-x+ 4 oracle oinstall 4 Jun 30 21:54 ./ drwxr-xr-x+ 4 oracle oinstall 4 Jul 1 08:25 ../ drwxr-xr-x+ 2 oracle oinstall 8 Jul 1 14:27 node08/ drwxr-xr-x+ 2 oracle oinstall 9 Jul 1 15:29 node07/
Example of node07 files
[oracle@auxlcn07 node07]$ pwd /u01/Middleware/domains/1034/nodemanager/node07 [oracle@auxlcn07 node07]$ d total 30 drwxr-xr-x+ 4 oracle oinstall 4 Jun 30 21:54 ../ -rw-r-----+ 1 oracle oinstall 130 Jul 1 08:44 nm_data.properties -rw-r-----+ 1 oracle oinstall 77 Jul 1 11:20 nodemanager.domains -rw-r--r--+ 1 oracle oinstall 164 Jul 1 11:28 nodemanager.properties -rwxr-x---+ 1 oracle oinstall 4378 Jul 1 13:23 startNodeManager.sh* -rw-r-----+ 1 oracle oinstall 1379 Jul 1 14:02 nodemanager.log.1 -rw-r-----+ 1 oracle oinstall 0 Jul 1 14:28 nodemanager.log.lck -rw-r-----+ 1 oracle oinstall 15618 Jul 1 14:29 nodemanager.log drwxr-xr-x+ 2 oracle oinstall 9 Jul 1 15:29 ./
nodemanager.properties example, the HOME will differ in the node08 file.
NodeManagerHome=/u01/Middleware/domains/1034/nodemanager/node07
StartScriptEnabled=true
StopScriptEnabled=true
5. Edit startNodeManager.sh to include node manager home location now it's moved
away from WLS_HOME. Example for node07.
NODEMGR_HOME="/u01/Middleware/domains/1034/nodemanager/node07"
6. Start both node managers from there directories on each compute node, example for node07.
/u01/Middleware/domains/1034/nodemanager/node07/startNodeManager.sh
7. For the ADMIN SERVER node ensure we set the following in "startWebLogic.sh".
# START WEBLOGIC
JAVA_OPTIONS="${JAVA_OPTIONS} -Dweblogic.security.SSL.ignoreHostnameVerification=true"
echo "starting weblogic with Java version:"
8. Start admin server, here we use node07.
/u01/Middleware/domains/1034/acs_dom/bin/startWebLogic.sh
9. Log into the admin console
10. Ensure the node manager processes are available from each machine and reachable.
11. Start all managed servers, once you ensure the node manager is reachable. I prefer to start managed servers from the command line but given we have 2 node managers on the compute nodes we can use that through the admin console.
Example of such a setup.
Friday, 17 June 2011
WebLogic - Obtain Groups of an Autenticated User
Note for myself:
for(Principal p: subject.getPrincipals()) {
if(p instanceof WLSGroup) {
if(first) {
first=false;
} else {
groups.append(", ");
}
groups.append(p.getName());
} else if (p instanceof WLSUser) {
user = p.getName();
}
}
Monday, 11 April 2011
JRuby OTN How to's With FMW and Oracle RDBMS
A couple of OTN how to's which show how to use JRuby with some of the Oracle Fusion Middleware products as well as single instance and RAC oracle databases.
1. Using JRuby with Oracle Database
http://www.oracle.com/technetwork/articles/dsl/jruby-oracle11g-330825.html
2. Use JRuby with JMX for Oracle WebLogic Server 11g
http://www.oracle.com/technetwork/articles/oem/jruby-wls-jmx-356114.html
3. Use a JRuby Script to Verify an Oracle RAC Setup using SCAN
http://www.oracle.com/technetwork/articles/oem/jruby-ucp-rac-355460.html
1. Using JRuby with Oracle Database
http://www.oracle.com/technetwork/articles/dsl/jruby-oracle11g-330825.html
2. Use JRuby with JMX for Oracle WebLogic Server 11g
http://www.oracle.com/technetwork/articles/oem/jruby-wls-jmx-356114.html
3. Use a JRuby Script to Verify an Oracle RAC Setup using SCAN
http://www.oracle.com/technetwork/articles/oem/jruby-ucp-rac-355460.html
Wednesday, 9 March 2011
How-To: Use Oracle WebLogic Server with a JDBC GridLink Data Source
This recently created how-to I created show's how to configure and test your new Oracle WebLogic 10.3.4 JDBC GridLink Data Source. The demo here is using an 11g R2 RAC cluster with SCAN. The link is as follows which includes a web test client.
http://www.oracle.com/technetwork/middleware/weblogic/wls-jdbc-gridlink-howto-333331.html
http://www.oracle.com/technetwork/middleware/weblogic/wls-jdbc-gridlink-howto-333331.html
Tuesday, 8 March 2011
Accessing a JAX-RS RESTful Web Service From JRuby
In this example we access our deployed JAX-RS Web Service from Weblogic 10.3.4. For such a setup see the previous blog entry below.
Deploying a RESTful Web Service From JDeveloper 11g to Weblogic 10.3.4
1. Download the ZIP of Jersey which contains all the JARS we need here.
zip of Jersey
2. The 2 client JAR files we need are as follows. Place them into an directory where you will run the JRuby script from.
3. Create a JRuby script called "jax-rs-weblogic.rb" with content as follows
4. Edit the @uri1 and @uri2 instance variables to point to your Weblogic 10.3.4 server details and or paths to the JAX-RS Web Service.
5. Run as follows.
> jrb jax-rs-weblogic.rb
OUTPUT
Run at Tue Mar 08 07:57:54 +1100 2011 using JRuby 1.8.7
** FMW Weblogic 10.3.4 JAX-RS Web Service Invoke Test **
** Simple GET request .... **
Hello World!
** Simple GET request with Query Param **
Hello PAS
Ended at Tue Mar 08 07:57:54 +1100 2011
Deploying a RESTful Web Service From JDeveloper 11g to Weblogic 10.3.4
1. Download the ZIP of Jersey which contains all the JARS we need here.
zip of Jersey
2. The 2 client JAR files we need are as follows. Place them into an directory where you will run the JRuby script from.
- jersey-client-1.5.jar
- jersey-core-1.5.jar
3. Create a JRuby script called "jax-rs-weblogic.rb" with content as follows
require 'java'
require 'jersey-client-1.5.jar'
require 'jersey-core-1.5.jar'
java_import 'com.sun.jersey.api.client.Client'
java_import 'com.sun.jersey.api.client.WebResource'
class TestJAXRSResource
def initialize
@client = Client.create
@uri1 = "http://wayne-p2.au.oracle.com:7003/jaxrs-demo/jersey/helloworld/sayHello"
@uri2 = "http://wayne-p2.au.oracle.com:7003/jaxrs-demo/jersey/helloworld/sayHelloWithName"
end
#add getters and setters for all attrributes
attr_reader :client, :uri1, :uri2
def invoke_simple_method_get()
puts "** Simple GET request .... **"
resource = @client.resource @uri1
response = resource.get java.lang.String.java_class
puts response
end
def invoke_simple_method_get_with_param (name)
puts "** Simple GET request with Query Param **"
resource = @client.resource @uri2
response = resource.queryParam("name", name).get(java.lang.String.java_class)
puts response
end
end
print "Run at #{Time.now} using JRuby #{RUBY_VERSION}\n\n"
print "** FMW Weblogic 10.3.4 JAX-RS Web Service Invoke Test **\n\n"
test = TestJAXRSResource.new
test.invoke_simple_method_get
test.invoke_simple_method_get_with_param :pas
print "\nEnded at #{Time.now} \n"
4. Edit the @uri1 and @uri2 instance variables to point to your Weblogic 10.3.4 server details and or paths to the JAX-RS Web Service.
5. Run as follows.
> jrb jax-rs-weblogic.rb
OUTPUT
Run at Tue Mar 08 07:57:54 +1100 2011 using JRuby 1.8.7
** FMW Weblogic 10.3.4 JAX-RS Web Service Invoke Test **
** Simple GET request .... **
Hello World!
** Simple GET request with Query Param **
Hello PAS
Ended at Tue Mar 08 07:57:54 +1100 2011
Wednesday, 2 March 2011
Deploying a RESTful Web Service From JDeveloper 11g to Weblogic 10.3.4
I previously blogged how to create a RESTFul Web Service in JDeveloper 11g as per this entry. Here are the steps required to now deploy this to WLS 10.3.4 directly from JDeveloper itself. It's just a few basic steps.
1. Ensure you have deployed the rqeuired Jersey libraries on WLS 10.3.4 and targetted them to the managed server you are going to deploy to. Those libraries are shipped with WLS 10.3 in $WLS_HOME/common/deployable-libraries.
2. Create a weblogic.xml within your "Demo" project which includes the references to the 2 libraries above.
3. Create a WAR deployment profile within your "Demo" project ensuring you don't deploy the libraries you used in JDeveloper. They are not needed as the libraries exist in WLS 10.3.4 which we are referencing. In short your WAR file would only contain 3 files here.
1004 Wed Mar 02 13:08:34 EST 2011 WEB-INF/classes/pas/au/jdev/rs/HelloWorld.class
635 Tue Mar 01 10:50:52 EST 2011 WEB-INF/web.xml
780 Wed Mar 02 13:08:16 EST 2011 WEB-INF/weblogic.xml
4. Deploy the WAR file targeting it to the managed server from JDeveloper itself.
[01:10:00 PM] ---- Deployment started. ----
[01:10:00 PM] Target platform is (Weblogic 10.3).
[01:10:32 PM] Retrieving existing application information
[01:10:33 PM] Running dependency analysis...
[01:10:33 PM] Building...
[01:10:33 PM] Deploying profile...
[01:10:34 PM] Wrote Web Application Module to C:\jdev\jdevprod\11114\jdeveloper\jdev\mywork\JAX-RS-RESTFulWebServices\Demo\deploy\helloworld-jaxrs.war
[01:10:37 PM] Deploying Application...
[01:11:08 PM] [Deployer:149191]Operation 'deploy' on application 'helloworld-jaxrs' is initializing on 'apple'
[01:11:12 PM] [Deployer:149192]Operation 'deploy' on application 'helloworld-jaxrs' is in progress on 'apple'
[01:11:16 PM] [Deployer:149194]Operation 'deploy' on application 'helloworld-jaxrs' has succeeded on 'apple'
[01:11:24 PM] [Deployer:149191]Operation 'deploy' on application 'helloworld-jaxrs' is initializing on 'apple'
[Deployer:149192]Operation 'deploy' on application 'helloworld-jaxrs' is in progress on 'apple'
[01:11:24 PM] Application Deployed Successfully.
[01:11:28 PM] The following URL context root(s) were defined and can be used as a starting point to test your application:
[01:11:28 PM] http://10.187.81.36:7003/jaxrs-demo
[01:11:30 PM] Elapsed time for deployment: 1 minute, 30 seconds
[01:11:30 PM] ---- Deployment finished. ----
1. Ensure you have deployed the rqeuired Jersey libraries on WLS 10.3.4 and targetted them to the managed server you are going to deploy to. Those libraries are shipped with WLS 10.3 in $WLS_HOME/common/deployable-libraries.
2. Create a weblogic.xml within your "Demo" project which includes the references to the 2 libraries above.
<?xml version = '1.0' encoding = 'windows-1252'?>
<weblogic-web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.bea.com/ns/weblogic/weblogic-web-app http://www.bea.com/ns/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd"
xmlns="http://www.bea.com/ns/weblogic/weblogic-web-app">
<context-root>jaxrs-demo</context-root>
<library-ref>
<library-name>jersey-bundle</library-name>
<specification-version>1.1.1</specification-version>
<implementation-version>1.1.5.1</implementation-version>
</library-ref>
<library-ref>
<library-name>jsr311-api</library-name>
<specification-version>1.1.1</specification-version>
<implementation-version>1.1.1</implementation-version>
</library-ref>
</weblogic-web-app>
3. Create a WAR deployment profile within your "Demo" project ensuring you don't deploy the libraries you used in JDeveloper. They are not needed as the libraries exist in WLS 10.3.4 which we are referencing. In short your WAR file would only contain 3 files here.
1004 Wed Mar 02 13:08:34 EST 2011 WEB-INF/classes/pas/au/jdev/rs/HelloWorld.class
635 Tue Mar 01 10:50:52 EST 2011 WEB-INF/web.xml
780 Wed Mar 02 13:08:16 EST 2011 WEB-INF/weblogic.xml
4. Deploy the WAR file targeting it to the managed server from JDeveloper itself.
[01:10:00 PM] ---- Deployment started. ----
[01:10:00 PM] Target platform is (Weblogic 10.3).
[01:10:32 PM] Retrieving existing application information
[01:10:33 PM] Running dependency analysis...
[01:10:33 PM] Building...
[01:10:33 PM] Deploying profile...
[01:10:34 PM] Wrote Web Application Module to C:\jdev\jdevprod\11114\jdeveloper\jdev\mywork\JAX-RS-RESTFulWebServices\Demo\deploy\helloworld-jaxrs.war
[01:10:37 PM] Deploying Application...
[01:11:08 PM] [Deployer:149191]Operation 'deploy' on application 'helloworld-jaxrs' is initializing on 'apple'
[01:11:12 PM] [Deployer:149192]Operation 'deploy' on application 'helloworld-jaxrs' is in progress on 'apple'
[01:11:16 PM] [Deployer:149194]Operation 'deploy' on application 'helloworld-jaxrs' has succeeded on 'apple'
[01:11:24 PM] [Deployer:149191]Operation 'deploy' on application 'helloworld-jaxrs' is initializing on 'apple'
[Deployer:149192]Operation 'deploy' on application 'helloworld-jaxrs' is in progress on 'apple'
[01:11:24 PM] Application Deployed Successfully.
[01:11:28 PM] The following URL context root(s) were defined and can be used as a starting point to test your application:
[01:11:28 PM] http://10.187.81.36:7003/jaxrs-demo
[01:11:30 PM] Elapsed time for deployment: 1 minute, 30 seconds
[01:11:30 PM] ---- Deployment finished. ----
Thursday, 17 February 2011
JRuby Script to Monitor a Oracle WebLogic GridLink Data Source Remotely
In WebLogic 10.3.4 release, a single data source implementation has been introduced to support Oracle RAC cluster. To simplify and consolidate its support for Oracle RAC, WebLogic Server has provided a single data source that is enhanced to support the capabilities of Oracle RAC. It provides a single connection pool/data source within Oracle WebLogic Server that supports the consumption of database services in an unrestricted manner. For more information on this see the URL below.
http://download.oracle.com/docs/cd/E17904_01/web.1111/e13737/gridlink_datasources.htm
In the example below we show how we can monitor this new Active GridLink Data Source from a JRuby script to get runtime information as the Data Source is in use from the MBean. In this example we are assuming our Data Source has a name "jdbc/gridlinkDS" which was created in the console of WebLogic itself.
1. Determine the remote connection URL to connect to WebLogic 10.3.4. The URL will be something as follows which shows are are connecting to the runtime MBean server of the managed server itself. In short this will be where you have targeted your GridLink Data Source to, it's not the ADMIN SERVER it's the managed server itself.
Format:
service:jmx:iiop://{hostname}:{managed-server-port}/jndi/weblogic.management.mbeanservers.runtime
Example:
service:jmx:iiop://wayne-p2.au.oracle.com:7003/jndi/weblogic.management.mbeanservers.runtime
2. At this point it's worth connecting using JConsole remotely to the WebLogic server using the URL above as this will help you see how the MBeans are structured and what you then need to alter the JRuby script with. Start jconsole ensuring your using wlfullclient.jar in the classpath from $WLS_HOME/server/lib directory.
Windows Example: (Connecting to a remote linux x86 server)
> jconsole -J-Djava.class.path=C:\jdev\weblogic-client\1034\wlfullclient.jar;C:\jdev\jdk\jdk1.6.0_21\lib\jconsole.jar -J-Djmx.remote.protocol.provider.pkgs=weblogic.management.remote
3. Connect using the service url from #1 above and with your username/password for the managed server where the GridLink Data Source is targeted for.
4. Click on the "MBeans" tab
5. At this point we want to determine what the MBean for the GridLink Data Source is but also what the MBean names are for the instances within the RAC cluster. To do that click on "com.bea" using the + symbol to expand the tree.
6. Scroll down and locate your GridLink Data Source in this case it's "jdbc/gridlinkDS" , use the + symbol to expand the tree
7. Click on the + symbol next to "JDBCOracleDataSourceRuntime"
8. Now actually click on "JDBCOracleDataSourceRuntime" to reveal the MBean name for the actual GidLink Data Source. Make a note of it which is displayed in the field "Object Name" in the right hand side of the dialog.
com.bea:ServerRuntime=apple,Name=jdbc/gridlinkDS,Type=JDBCOracleDataSourceRuntime
9. Select the "Attributes" node in the tree to view the GridLink Data Source runtime attributes.
10. Double click on the "Instances" Value field to reveal the MBean names for the individual instances within your cluster. Make a note of them as we will need them shortly. For my example there as follows.
com.bea:ServerRuntime=apple,Name=A11,Type=JDBCOracleDataSourceInstanceRuntime,JDBCOracleDataSourceRuntime=jdbc/gridlinkDS
com.bea:ServerRuntime=apple,Name=A12,Type=JDBCOracleDataSourceInstanceRuntime,JDBCOracleDataSourceRuntime=jdbc/gridlinkDS
11. Create a test client as follows
12. Edit the following lines as per the information we collected above.
require 'C:/jdev/weblogic-client/1034/wlfullclient.jar'
...
#Connection details to MBeanServer within Weblogic 10.3.4
url = "service:jmx:iiop://wayne-p2.au.oracle.com:7003/jndi/weblogic.management.mbeanservers.runtime"
username = "weblogic"
password = "welcome1"
# parent GridLink Data Source MBean name
parent_ds_runtime_mbean_name =
"com.bea:ServerRuntime=apple,Name=jdbc/gridlinkDS,Type=JDBCOracleDataSourceRuntime"
# child instance MBean array, add for each instance in the RAC cluster
child_ds_instances =
["com.bea:ServerRuntime=apple,Name=A11,Type=JDBCOracleDataSourceInstanceRuntime,JDBCOracleDataSourceRuntime=jdbc/gridlinkDS",
"com.bea:ServerRuntime=apple,Name=A12,Type=JDBCOracleDataSourceInstanceRuntime,JDBCOracleDataSourceRuntime=jdbc/gridlinkDS"]
...
Note: We previously installed "jmx4r" ruby gem to allow us to use JMX API to communicate with the WebLogic server as follows
> jruby -S gem install jmx4r
13. Run the JRuby script as follows it will continually run sleeping every 20 seconds to display runtime information regarding your GridLink Data Source. To end it simply use CNRL-C to stop it running.
> jruby gridlink-monitor.rb
Output
Run at Thu Feb 17 21:55:32 +1100 2011
MonitorGridLinkDataSource [user=weblogic, passwd=welcome1, url=service:jmx:iiop://wayne-p2.au.oracle.com:7003/jndi/weblogic.management.mbean
servers.runtime]
** JDBC GridLink Data Source mbean "jdbc/gridlinkDS" **
Name: ActiveConnectionsCurrentCount, Value: 0
Name: WaitingForConnectionFailureTotal, Value: 0
Name: Instances, Value:
com.bea:ServerRuntime=apple,Name=A11,Type=JDBCOracleDataSourceInstanceRuntime,JDBCOracleDataSourceRuntime=jdbc/gridlinkDS
com.bea:ServerRuntime=apple,Name=A12,Type=JDBCOracleDataSourceInstanceRuntime,JDBCOracleDataSourceRuntime=jdbc/gridlinkDS
Name: FailedRCLBBasedBorrowCount, Value: 0
Name: WaitingForConnectionTotal, Value: 0
Name: ConnectionsTotalCount, Value: 28
Name: SuccessfulRCLBBasedBorrowCount, Value: 0
Name: DriverVersion, Value: 11.2.0.2.0
Name: WaitingForConnectionCurrentCount, Value: 0
Name: LeakedConnectionCount, Value: 0
Name: HighestNumUnavailable, Value: 20
Name: PrepStmtCacheAccessCount, Value: 0
Name: LastTask, Value:
Name: Parent, Value: com.bea:Name=apple,Type=ServerRuntime
Name: WaitSecondsHighCount, Value: 0
Name: ActiveConnectionsHighCount, Value: 20
Name: FailedAffinityBasedBorrowCount, Value: 0
Name: PrepStmtCacheHitCount, Value: 0
Name: ActiveConnectionsAverageCount, Value: 0
Name: VersionJDBCDriver, Value: oracle.jdbc.OracleDriver
Name: DatabaseProductVersion, Value: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
Name: SuccessfulAffinityBasedBorrowCount, Value: 0
Name: PrepStmtCacheDeleteCount, Value: 0
Name: ReserveRequestCount, Value: 36
Name: FailuresToReconnectCount, Value: 0
Name: WaitingForConnectionHighCount, Value: 0
Name: PrepStmtCacheMissCount, Value: 0
Name: Enabled, Value: true
Name: FailedReserveRequestCount, Value: 0
Name: Type, Value: JDBCOracleDataSourceRuntime
Name: HighestNumAvailable, Value: 20
Name: WorkManagerRuntimes, Value:
Name: DatabaseProductName, Value: Oracle
Name: ONSClientRuntime, Value: com.bea:ServerRuntime=apple,Name=jdbc/gridlinkDS,Type=ONSClientRuntime,JDBCOracleDataSourceRuntime=jdbc/gridl
inkDS
Name: Properties, Value: {user=scott}
Name: CurrCapacityHighCount, Value: 20
Name: PrepStmtCacheCurrentSize, Value: 0
Name: ServiceName, Value:
Name: JDBCDriverRuntime, Value:
Name: WaitingForConnectionSuccessTotal, Value: 0
Name: NumUnavailable, Value: 0
Name: PrepStmtCacheAddCount, Value: 0
Name: DriverName, Value: Oracle JDBC driver
Name: NumAvailable, Value: 20
Name: ModuleId, Value: jdbc/gridlinkDS
Name: Name, Value: jdbc/gridlinkDS
Name: State, Value: Running
Name: ConnectionDelayTime, Value: 133
Name: DeploymentState, Value: 2
Name: CurrCapacity, Value: 20
** Instance MBean
[com.bea:ServerRuntime=apple,Name=A11,Type=JDBCOracleDataSourceInstanceRuntime,JDBCOracleDataSourceRuntime=jdbc/gridlinkDS]
Name: Parent, Value: com.bea:ServerRuntime=apple,Name=jdbc/gridlinkDS,Type=JDBCOracleDataSourceRuntime
Name: Enabled, Value: true
Name: ActiveConnectionsCurrentCount, Value: 0
Name: Type, Value: JDBCOracleDataSourceInstanceRuntime
Name: NumAvailable, Value: 10
Name: Signature, Value: instance=A11,service=pas_srv,database=A1,host=auw2k3
Name: CurrentWeight, Value: 1
Name: Name, Value: A11
Name: ConnectionsTotalCount, Value: 14
Name: ReserveRequestCount, Value: 19
Name: State, Value: Enabled
Name: NumUnavailable, Value: 0
Name: CurrCapacity, Value: 10
Name: InstanceName, Value: A11
** Instance MBean
[com.bea:ServerRuntime=apple,Name=A12,Type=JDBCOracleDataSourceInstanceRuntime,JDBCOracleDataSourceRuntime=jdbc/gridlinkDS]
Name: Parent, Value: com.bea:ServerRuntime=apple,Name=jdbc/gridlinkDS,Type=JDBCOracleDataSourceRuntime
Name: Enabled, Value: true
Name: ActiveConnectionsCurrentCount, Value: 0
Name: Type, Value: JDBCOracleDataSourceInstanceRuntime
Name: NumAvailable, Value: 10
Name: Signature, Value: instance=A12,service=pas_srv,database=A1,host=auw2k4
Name: CurrentWeight, Value: 1
Name: Name, Value: A12
Name: ConnectionsTotalCount, Value: 14
Name: ReserveRequestCount, Value: 17
Name: State, Value: Enabled
Name: NumUnavailable, Value: 0
Name: CurrCapacity, Value: 10
Name: InstanceName, Value: A12
Sleeping for 20 seconds....
http://download.oracle.com/docs/cd/E17904_01/web.1111/e13737/gridlink_datasources.htm
In the example below we show how we can monitor this new Active GridLink Data Source from a JRuby script to get runtime information as the Data Source is in use from the MBean. In this example we are assuming our Data Source has a name "jdbc/gridlinkDS" which was created in the console of WebLogic itself.
1. Determine the remote connection URL to connect to WebLogic 10.3.4. The URL will be something as follows which shows are are connecting to the runtime MBean server of the managed server itself. In short this will be where you have targeted your GridLink Data Source to, it's not the ADMIN SERVER it's the managed server itself.
Format:
service:jmx:iiop://{hostname}:{managed-server-port}/jndi/weblogic.management.mbeanservers.runtime
Example:
service:jmx:iiop://wayne-p2.au.oracle.com:7003/jndi/weblogic.management.mbeanservers.runtime
2. At this point it's worth connecting using JConsole remotely to the WebLogic server using the URL above as this will help you see how the MBeans are structured and what you then need to alter the JRuby script with. Start jconsole ensuring your using wlfullclient.jar in the classpath from $WLS_HOME/server/lib directory.
Windows Example: (Connecting to a remote linux x86 server)
> jconsole -J-Djava.class.path=C:\jdev\weblogic-client\1034\wlfullclient.jar;C:\jdev\jdk\jdk1.6.0_21\lib\jconsole.jar -J-Djmx.remote.protocol.provider.pkgs=weblogic.management.remote
3. Connect using the service url from #1 above and with your username/password for the managed server where the GridLink Data Source is targeted for.
4. Click on the "MBeans" tab
5. At this point we want to determine what the MBean for the GridLink Data Source is but also what the MBean names are for the instances within the RAC cluster. To do that click on "com.bea" using the + symbol to expand the tree.
6. Scroll down and locate your GridLink Data Source in this case it's "jdbc/gridlinkDS" , use the + symbol to expand the tree
7. Click on the + symbol next to "JDBCOracleDataSourceRuntime"
8. Now actually click on "JDBCOracleDataSourceRuntime" to reveal the MBean name for the actual GidLink Data Source. Make a note of it which is displayed in the field "Object Name" in the right hand side of the dialog.
com.bea:ServerRuntime=apple,Name=jdbc/gridlinkDS,Type=JDBCOracleDataSourceRuntime
9. Select the "Attributes" node in the tree to view the GridLink Data Source runtime attributes.
10. Double click on the "Instances" Value field to reveal the MBean names for the individual instances within your cluster. Make a note of them as we will need them shortly. For my example there as follows.
com.bea:ServerRuntime=apple,Name=A11,Type=JDBCOracleDataSourceInstanceRuntime,JDBCOracleDataSourceRuntime=jdbc/gridlinkDS
com.bea:ServerRuntime=apple,Name=A12,Type=JDBCOracleDataSourceInstanceRuntime,JDBCOracleDataSourceRuntime=jdbc/gridlinkDS
11. Create a test client as follows
require 'java'
require 'rubygems'
require 'jmx4r'
require 'C:/jdev/weblogic-client/1034/wlfullclient.jar'
java_import 'javax.management.ObjectName'
java_import java.lang.System
class MonitorGridLinkDataSource
def initialize(user, passwd, url)
System.setProperty("jmx.remote.protocol.provider.pkgs", "weblogic.management.remote")
@user, @passwd, @url = user, passwd, url
@conn = JMX::MBean.establish_connection :url => @url, :username => @user, :password => @passwd
end
# add getters and setters for all attrributes we wish to expose
attr_reader :user, :passwd, :url, :conn
def display_array (value)
data = ""
value.each do |x|
data += "\n\t" + x.to_s
end
return data
end
def display_attribute_data(conn, object_name, attribute)
s = conn.get_attribute object_name, attribute
search_str = s.to_s
if (/^\[Ljava.lang.String/.match(search_str)) or
(/^\[I/.match(search_str)) or
(/^\[Ljavax.management.ObjectName/.match(search_str))
# we have a array with data
return display_array s
else
return search_str
end
end
def to_s
"MonitorGridLinkDataSource [user=#{@user}, passwd=#{@passwd}, " +
"url=#{@url}]"
end
def run(parent_ds_runtime_mbean_name, child_ds_instances)
mbean = JMX::MBean.find_by_name parent_ds_runtime_mbean_name
object_name = ObjectName.new parent_ds_runtime_mbean_name
#
# Display main JDBC grindlink Data Source MBean info
#
printf "\n** JDBC GridLink Data Source mbean \"jdbc/gridlinkDS\" ** \n\n"
# display attributes key/values
mbean.attributes.each do |key, value|
puts "Name: #{value}, Value: #{display_attribute_data conn, object_name, value}\n"
end
#
# Now display info about each RAC instances within the gridlink DS
#
# Note: there will be as many instances as your RAC cluster contains here, in my case
# just a 2 node RAC cluster here
child_ds_instances.each {|mbean_name|
ds1_mbean = JMX::MBean.find_by_name mbean_name
object_name1 = ObjectName.new mbean_name
printf "\n** Instance MBean \n\t[#{mbean_name}] \n\n"
ds1_mbean.attributes.each do |key, value|
puts "Name: #{value}, Value: #{display_attribute_data conn, object_name1, value}\n"
end
}
end
end
print "Run at ", Time.now , "\n"
#Connection details to MBeanServer within Weblogic 10.3.4
url = "service:jmx:iiop://wayne-p2.au.oracle.com:7003/jndi/weblogic.management.mbeanservers.runtime"
username = "weblogic"
password = "welcome1"
# parent GridLink Data Source MBean name
parent_ds_runtime_mbean_name =
"com.bea:ServerRuntime=apple,Name=jdbc/gridlinkDS,Type=JDBCOracleDataSourceRuntime"
# child instance MBean array, add for each instance in the RAC cluster
child_ds_instances =
["com.bea:ServerRuntime=apple,Name=A11,Type=JDBCOracleDataSourceInstanceRuntime,JDBCOracleDataSourceRuntime=jdbc/gridlinkDS",
"com.bea:ServerRuntime=apple,Name=A12,Type=JDBCOracleDataSourceInstanceRuntime,JDBCOracleDataSourceRuntime=jdbc/gridlinkDS"]
begin
mon_grid_link_ds = MonitorGridLinkDataSource.new username, password, url
puts mon_grid_link_ds
while (true)
mon_grid_link_ds.run parent_ds_runtime_mbean_name, child_ds_instances
# sleep for 20 seconds
puts "\nSleeping for 20 seconds....\n"
sleep 20
end
rescue
print "\n** Error occured **\n"
print "Failed executing GridLink Data Source Monitoring from JRuby ", $!, "\n"
end
print "\nEnded at ", Time.now , "\n"
12. Edit the following lines as per the information we collected above.
require 'C:/jdev/weblogic-client/1034/wlfullclient.jar'
...
#Connection details to MBeanServer within Weblogic 10.3.4
url = "service:jmx:iiop://wayne-p2.au.oracle.com:7003/jndi/weblogic.management.mbeanservers.runtime"
username = "weblogic"
password = "welcome1"
# parent GridLink Data Source MBean name
parent_ds_runtime_mbean_name =
"com.bea:ServerRuntime=apple,Name=jdbc/gridlinkDS,Type=JDBCOracleDataSourceRuntime"
# child instance MBean array, add for each instance in the RAC cluster
child_ds_instances =
["com.bea:ServerRuntime=apple,Name=A11,Type=JDBCOracleDataSourceInstanceRuntime,JDBCOracleDataSourceRuntime=jdbc/gridlinkDS",
"com.bea:ServerRuntime=apple,Name=A12,Type=JDBCOracleDataSourceInstanceRuntime,JDBCOracleDataSourceRuntime=jdbc/gridlinkDS"]
...
Note: We previously installed "jmx4r" ruby gem to allow us to use JMX API to communicate with the WebLogic server as follows
> jruby -S gem install jmx4r
13. Run the JRuby script as follows it will continually run sleeping every 20 seconds to display runtime information regarding your GridLink Data Source. To end it simply use CNRL-C to stop it running.
> jruby gridlink-monitor.rb
Output
Run at Thu Feb 17 21:55:32 +1100 2011
MonitorGridLinkDataSource [user=weblogic, passwd=welcome1, url=service:jmx:iiop://wayne-p2.au.oracle.com:7003/jndi/weblogic.management.mbean
servers.runtime]
** JDBC GridLink Data Source mbean "jdbc/gridlinkDS" **
Name: ActiveConnectionsCurrentCount, Value: 0
Name: WaitingForConnectionFailureTotal, Value: 0
Name: Instances, Value:
com.bea:ServerRuntime=apple,Name=A11,Type=JDBCOracleDataSourceInstanceRuntime,JDBCOracleDataSourceRuntime=jdbc/gridlinkDS
com.bea:ServerRuntime=apple,Name=A12,Type=JDBCOracleDataSourceInstanceRuntime,JDBCOracleDataSourceRuntime=jdbc/gridlinkDS
Name: FailedRCLBBasedBorrowCount, Value: 0
Name: WaitingForConnectionTotal, Value: 0
Name: ConnectionsTotalCount, Value: 28
Name: SuccessfulRCLBBasedBorrowCount, Value: 0
Name: DriverVersion, Value: 11.2.0.2.0
Name: WaitingForConnectionCurrentCount, Value: 0
Name: LeakedConnectionCount, Value: 0
Name: HighestNumUnavailable, Value: 20
Name: PrepStmtCacheAccessCount, Value: 0
Name: LastTask, Value:
Name: Parent, Value: com.bea:Name=apple,Type=ServerRuntime
Name: WaitSecondsHighCount, Value: 0
Name: ActiveConnectionsHighCount, Value: 20
Name: FailedAffinityBasedBorrowCount, Value: 0
Name: PrepStmtCacheHitCount, Value: 0
Name: ActiveConnectionsAverageCount, Value: 0
Name: VersionJDBCDriver, Value: oracle.jdbc.OracleDriver
Name: DatabaseProductVersion, Value: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
Name: SuccessfulAffinityBasedBorrowCount, Value: 0
Name: PrepStmtCacheDeleteCount, Value: 0
Name: ReserveRequestCount, Value: 36
Name: FailuresToReconnectCount, Value: 0
Name: WaitingForConnectionHighCount, Value: 0
Name: PrepStmtCacheMissCount, Value: 0
Name: Enabled, Value: true
Name: FailedReserveRequestCount, Value: 0
Name: Type, Value: JDBCOracleDataSourceRuntime
Name: HighestNumAvailable, Value: 20
Name: WorkManagerRuntimes, Value:
Name: DatabaseProductName, Value: Oracle
Name: ONSClientRuntime, Value: com.bea:ServerRuntime=apple,Name=jdbc/gridlinkDS,Type=ONSClientRuntime,JDBCOracleDataSourceRuntime=jdbc/gridl
inkDS
Name: Properties, Value: {user=scott}
Name: CurrCapacityHighCount, Value: 20
Name: PrepStmtCacheCurrentSize, Value: 0
Name: ServiceName, Value:
Name: JDBCDriverRuntime, Value:
Name: WaitingForConnectionSuccessTotal, Value: 0
Name: NumUnavailable, Value: 0
Name: PrepStmtCacheAddCount, Value: 0
Name: DriverName, Value: Oracle JDBC driver
Name: NumAvailable, Value: 20
Name: ModuleId, Value: jdbc/gridlinkDS
Name: Name, Value: jdbc/gridlinkDS
Name: State, Value: Running
Name: ConnectionDelayTime, Value: 133
Name: DeploymentState, Value: 2
Name: CurrCapacity, Value: 20
** Instance MBean
[com.bea:ServerRuntime=apple,Name=A11,Type=JDBCOracleDataSourceInstanceRuntime,JDBCOracleDataSourceRuntime=jdbc/gridlinkDS]
Name: Parent, Value: com.bea:ServerRuntime=apple,Name=jdbc/gridlinkDS,Type=JDBCOracleDataSourceRuntime
Name: Enabled, Value: true
Name: ActiveConnectionsCurrentCount, Value: 0
Name: Type, Value: JDBCOracleDataSourceInstanceRuntime
Name: NumAvailable, Value: 10
Name: Signature, Value: instance=A11,service=pas_srv,database=A1,host=auw2k3
Name: CurrentWeight, Value: 1
Name: Name, Value: A11
Name: ConnectionsTotalCount, Value: 14
Name: ReserveRequestCount, Value: 19
Name: State, Value: Enabled
Name: NumUnavailable, Value: 0
Name: CurrCapacity, Value: 10
Name: InstanceName, Value: A11
** Instance MBean
[com.bea:ServerRuntime=apple,Name=A12,Type=JDBCOracleDataSourceInstanceRuntime,JDBCOracleDataSourceRuntime=jdbc/gridlinkDS]
Name: Parent, Value: com.bea:ServerRuntime=apple,Name=jdbc/gridlinkDS,Type=JDBCOracleDataSourceRuntime
Name: Enabled, Value: true
Name: ActiveConnectionsCurrentCount, Value: 0
Name: Type, Value: JDBCOracleDataSourceInstanceRuntime
Name: NumAvailable, Value: 10
Name: Signature, Value: instance=A12,service=pas_srv,database=A1,host=auw2k4
Name: CurrentWeight, Value: 1
Name: Name, Value: A12
Name: ConnectionsTotalCount, Value: 14
Name: ReserveRequestCount, Value: 17
Name: State, Value: Enabled
Name: NumUnavailable, Value: 0
Name: CurrCapacity, Value: 10
Name: InstanceName, Value: A12
Sleeping for 20 seconds....
Friday, 21 January 2011
Invoking a JAX-WS Oracle Weblogic 11g (10.3.4) Web Service from JRuby
The following demo show how to call a JAX-WS from Oracle Weblogic Server 11g (10.3.4) from a JRuby script. The real work is done by JDeveloper 11g (11.1.1.4) which creates the Web Service, generates a proxy client JAR which JRuby then uses to invoke the Web Service.
So in JDeveloper we have 2 projects one for the Web Service and one for the Proxy.
The Web Service is deployed to Weblogic 10.3.4 as shown below.
1. Create a JRuby script named "jaxws11g.rb" as follows
2. The JAR file referenced below is the Web Service proxy JAR file which is generated by JDeveloper once a proxy project is created from the WSDL file for the Web Service.
# the web service client JAR file generated from JDeveloper 11g Proxy wizard
require 'SimpleWSService-Client.jar'
3. Run shown below which simply identified the Weblogic managed server name it's running in and the date it was invoked.
> jruby jaxws11g.rb
Run at Fri Jan 21 11:10:37 +1100 2011 using JRuby 1.8.7
** FMW Weblogic 10.3.4 Web Service Invoke Test **
SimpleWS invoked at Thu Jan 20 11:05:13 EST 2011 from Weblogic Managed Server named apple
Ended at Fri Jan 21 11:10:38 +1100 2011
So in JDeveloper we have 2 projects one for the Web Service and one for the Proxy.
The Web Service is deployed to Weblogic 10.3.4 as shown below.
1. Create a JRuby script named "jaxws11g.rb" as follows
require 'java'
# the web service client JAR file generated from JDeveloper 11g Proxy wizard
require 'SimpleWSService-Client.jar'
java_import 'pas.au.wsclient.SimpleWSPortClient'
class TestWLSWebService
def initialize
@wsclient = SimpleWSPortClient.new
end
def invoke_method
return @wsclient.invoke_method
end
end
print "Run at #{Time.now} using JRuby #{RUBY_VERSION}\n\n"
print "** FMW Weblogic 10.3.4 Web Service Invoke Test **\n\n"
test = TestWLSWebService.new
print test.invoke_method
print "\n\nEnded at #{Time.now} \n"
2. The JAR file referenced below is the Web Service proxy JAR file which is generated by JDeveloper once a proxy project is created from the WSDL file for the Web Service.
# the web service client JAR file generated from JDeveloper 11g Proxy wizard
require 'SimpleWSService-Client.jar'
3. Run shown below which simply identified the Weblogic managed server name it's running in and the date it was invoked.
> jruby jaxws11g.rb
Run at Fri Jan 21 11:10:37 +1100 2011 using JRuby 1.8.7
** FMW Weblogic 10.3.4 Web Service Invoke Test **
SimpleWS invoked at Thu Jan 20 11:05:13 EST 2011 from Weblogic Managed Server named apple
Ended at Fri Jan 21 11:10:38 +1100 2011
The Web Service is a simple class as follows
package pas.au.ws;
import java.util.Date;
import javax.jws.WebService;
@WebService
public class SimpleWS
{
public SimpleWS()
{
}
public String getManagedServerName ()
{
String retData =
String.format("SimpleWS invoked at %s from Weblogic Managed Server named %s",
new Date(),
System.getProperty("weblogic.Name"));
return retData;
}
}
Thursday, 11 November 2010
Referencing Coherence from Web Applications (WAR) in WLS 11g
I am constantly providing coherence.jar in the WEB-INF/lib of my web based (WAR) applications in WLS 11g. So obviously it made more sense to deploy coherence.jar as library and then reference it but WLS 11g does not allow web based applications to reference shared library JAR files as per the link below.
http://download.oracle.com/docs/cd/E13222_01/wls/docs92/programming/libraries.html#wp1071062
Here is what i did to get this to work.
1. Create a shared library coherence.jar for version 3.6 as shown below. I targeted this to the managed servers I was using.
2. In my WAR file create a META-INF/MANIFEST.MF with content as follows.
Extension-List: cohlib
cohlib-Extension-Name: coherence
cohlib-Specification-Version: 3.6.0.0
cohlib-Implementation-Version: 3.6.0.0
3. The JDeveloper 11g project would look something like this, as you can clearly see there is no coherence.jar in WEB-INF\lib folder with this setup.
I found this setup as follows enabling me to use JAR files as libraries from WAR / Web Based Applications.
http://download.oracle.com/docs/cd/E13222_01/wls/docs92/programming/libraries.html#wp1064645
http://download.oracle.com/docs/cd/E13222_01/wls/docs92/programming/libraries.html#wp1071062
"You cannot reference any other type of shared J2EE library (EJB, Enterprise application, or plain JAR file) from the
weblogic.xml deployment descriptor file of a Web Application."Here is what i did to get this to work.
1. Create a shared library coherence.jar for version 3.6 as shown below. I targeted this to the managed servers I was using.
2. In my WAR file create a META-INF/MANIFEST.MF with content as follows.
Extension-List: cohlib
cohlib-Extension-Name: coherence
cohlib-Specification-Version: 3.6.0.0
cohlib-Implementation-Version: 3.6.0.0
3. The JDeveloper 11g project would look something like this, as you can clearly see there is no coherence.jar in WEB-INF\lib folder with this setup.
I found this setup as follows enabling me to use JAR files as libraries from WAR / Web Based Applications.
http://download.oracle.com/docs/cd/E13222_01/wls/docs92/programming/libraries.html#wp1064645
Tuesday, 2 November 2010
Connecting to WLS 11g MBeanServer using jconsole on a windows client
Viewing the MBeans available in WLS 11g from the client side with jconsole is done as follows. The key here is to create the necessary client side JAR file required to access WLS 11g using JMX. In this example we are using JDK 1.6.
Note: The steps for JDK 1.5 are NOT identical to these.
1. First create a wlfullclient.jar with steps as follows on the WLS server. This will give you what you need on the client side to connect to WLS MBean Server.
- Change directories to the
- Use the following command to create
2. Now add/provide wlfullclient.jar to the classpath for jconsole on the client side as follows.
3. Jconsole should display requesting you to provide the remote server you wish to connect to. In this example I am simply going to connect to the RUNTIME MBean Sever with connect details as follows for the "Remote Process" field. Also I have to add a username/password for the WLS 11g server in order to connect.
4. Press the connect button and now you can easily see which MBeans you wish to view.
For more information on the MBeans in WLS 11g refer to this URL.
http://download.oracle.com/docs/cd/E14571_01/apirefs.1111/e13951/core/index.html
Note: The steps for JDK 1.5 are NOT identical to these.
1. First create a wlfullclient.jar with steps as follows on the WLS server. This will give you what you need on the client side to connect to WLS MBean Server.
- Change directories to the
server/lib directory. cd
WL_HOME/server/lib- Use the following command to create
wlfullclient.jar in the server/lib directory: java -jar wljarbuilder.jar
2. Now add/provide wlfullclient.jar to the classpath for jconsole on the client side as follows.
jconsole -J-Djava.class.path=wlfullclient.jar;C:\jdev\jdk\jdk1.6.0_21\lib\jconsole.jar -J-Djmx.remote.protocol.provider.pkgs=weblogic.management.remote
3. Jconsole should display requesting you to provide the remote server you wish to connect to. In this example I am simply going to connect to the RUNTIME MBean Sever with connect details as follows for the "Remote Process" field. Also I have to add a username/password for the WLS 11g server in order to connect.
service:jmx:iiop://wayne-p2.au.oracle.com:7003/jndi/weblogic.management.mbeanservers.runtime
4. Press the connect button and now you can easily see which MBeans you wish to view.
For more information on the MBeans in WLS 11g refer to this URL.
http://download.oracle.com/docs/cd/E14571_01/apirefs.1111/e13951/core/index.html
Wednesday, 5 May 2010
Installing ADF runtime into FMW 11gR1 patchset 2
If you wish to use ADF with FMW 11gR1 pathset 2 (11.1.1.3) you will need to install it as follows into your stand alone FMW home.
Note: Assuming you already have Weblogic 10.3.3 installed.
1. Navigate to this web page which is where we need to download some files from.
http://www.oracle.com/technology/software/products/middleware/htdocs/fmw_11_download.html
2. Download and install "Application Development Runtime (11.1.1.2.0)" into your stand alone Weblogic 10.3.3
3. Now download and install "Application Development Runtime (11.1.1.3.0)" into your stand alone Weblogic 10.3.3.
4. Now run config.sh to create a new domain for ADF applications. I normally select "Oracle Enterprise Manager" which will then include the JRF required for ADF, as shown below.

5. Then in EM itself apply the JRF template to the managed servers which will host ADF applications developed in JDeveloper 11.1.1.3.
- Click the + symbol for "Weblogic Domain".
- Click on the + symbol for your domain.
- Select the managed server you wish to enable ADF applications for.
- Click on the button "Apply JRF Template".
6. Finally deploy an ADF app from JDeveloper 11.1.1.3 to verify the setup.
[09:22:08 AM] ---- Deployment started. ----
[09:22:08 AM] Target platform is (Weblogic 10.3).
[09:22:08 AM] Retrieving existing application information
[09:22:09 AM] Running dependency analysis...
[09:22:09 AM] Building...
[09:22:19 AM] Deploying 2 profiles...
[09:22:23 AM] Wrote Web Application Module to D:\jdev\jdevprod\11gr3\jdeveloper\jdev\mywork\ADFDemo\ViewController\deploy\ADFDemo_ViewController_webapp1.war
[09:22:25 AM] Wrote Enterprise Application Module to D:\jdev\jdevprod\11gr3\jdeveloper\jdev\mywork\ADFDemo\deploy\ADFDemo_application1.ear
[09:22:26 AM] Deploying Application...
[09:22:29 AM] [Deployer:149191]Operation 'deploy' on application 'ADFDemo_application1' is initializing on 'apple'
[09:22:36 AM] [Deployer:149192]Operation 'deploy' on application 'ADFDemo_application1' is in progress on 'apple'
[09:22:47 AM] [Deployer:149194]Operation 'deploy' on application 'ADFDemo_application1' has succeeded on 'apple'
[09:22:47 AM] Application Deployed Successfully.
[09:22:47 AM] The following URL context root(s) were defined and can be used as a starting point to test your application:
[09:22:47 AM] http://10.187.81.36:7003/adfdemo
[09:22:47 AM] Elapsed time for deployment: 39 seconds
[09:22:47 AM] ---- Deployment finished. ----
Note: Assuming you already have Weblogic 10.3.3 installed.
1. Navigate to this web page which is where we need to download some files from.
http://www.oracle.com/technology/software/products/middleware/htdocs/fmw_11_download.html
2. Download and install "Application Development Runtime (11.1.1.2.0)" into your stand alone Weblogic 10.3.3
3. Now download and install "Application Development Runtime (11.1.1.3.0)" into your stand alone Weblogic 10.3.3.
4. Now run config.sh to create a new domain for ADF applications. I normally select "Oracle Enterprise Manager" which will then include the JRF required for ADF, as shown below.

5. Then in EM itself apply the JRF template to the managed servers which will host ADF applications developed in JDeveloper 11.1.1.3.
- http://{server}:{port}/em - Click on the + symbol for your domain.
- Select the managed server you wish to enable ADF applications for.
- Click on the button "Apply JRF Template".
6. Finally deploy an ADF app from JDeveloper 11.1.1.3 to verify the setup.
[09:22:08 AM] ---- Deployment started. ----
[09:22:08 AM] Target platform is (Weblogic 10.3).
[09:22:08 AM] Retrieving existing application information
[09:22:09 AM] Running dependency analysis...
[09:22:09 AM] Building...
[09:22:19 AM] Deploying 2 profiles...
[09:22:23 AM] Wrote Web Application Module to D:\jdev\jdevprod\11gr3\jdeveloper\jdev\mywork\ADFDemo\ViewController\deploy\ADFDemo_ViewController_webapp1.war
[09:22:25 AM] Wrote Enterprise Application Module to D:\jdev\jdevprod\11gr3\jdeveloper\jdev\mywork\ADFDemo\deploy\ADFDemo_application1.ear
[09:22:26 AM] Deploying Application...
[09:22:29 AM] [Deployer:149191]Operation 'deploy' on application 'ADFDemo_application1' is initializing on 'apple'
[09:22:36 AM] [Deployer:149192]Operation 'deploy' on application 'ADFDemo_application1' is in progress on 'apple'
[09:22:47 AM] [Deployer:149194]Operation 'deploy' on application 'ADFDemo_application1' has succeeded on 'apple'
[09:22:47 AM] Application Deployed Successfully.
[09:22:47 AM] The following URL context root(s) were defined and can be used as a starting point to test your application:
[09:22:47 AM] http://10.187.81.36:7003/adfdemo
[09:22:47 AM] Elapsed time for deployment: 39 seconds
[09:22:47 AM] ---- Deployment finished. ----
Thursday, 25 February 2010
Accessing a Data Source Remotely in FMW 11g (11.1.1.2.0) from JDeveloper 11g (11.1.1.2.0)
I needed to access a data source remotely on FMW 11g server from JDeveloper 11g. I found that to do this I needed to follow these steps.
Note: This was done using 11.1.1.2 which is the latest version of FMW 11g and JDeveloper 11g
1. Edit setDomainEnv script to ensure you set this property to true. By default it's false.
WLS_JDBC_REMOTE_ENABLED="-Dweblogic.jdbc.remoteEnabled=true"
2. Re-start your server to pick up the change done at step #1 above.
3. In your project add the following libraries to allow remote access and the required JDBC driver library.
5. Output as follows.
25/02/2010 9:22:56 AM pas.au.remote.wls11g.RemoteDataSourceAccess run
INFO: Started RemoteDataSourceAccess at Thu Feb 25 09:22:56 EST 2010
25/02/2010 9:23:03 AM pas.au.remote.wls11g.RemoteDataSourceAccess run
INFO: Got connection : weblogic.jdbc.rmi.SerialConnection_weblogic_jdbc_rmi_internal_ConnectionImpl_weblogic_jdbc_wrapper_PoolConnection_oracle_jdbc_driver_T4CConnection_1032_WLStub@1
25/02/2010 9:23:03 AM pas.au.remote.wls11g.RemoteDataSourceAccess run
INFO: Auto Commit = true
25/02/2010 9:23:03 AM pas.au.remote.wls11g.RemoteDataSourceAccess run
INFO: Ended RemoteDataSourceAccess at Thu Feb 25 09:23:03 EST 2010
Note: This was done using 11.1.1.2 which is the latest version of FMW 11g and JDeveloper 11g
1. Edit setDomainEnv script to ensure you set this property to true. By default it's false.
WLS_JDBC_REMOTE_ENABLED="-Dweblogic.jdbc.remoteEnabled=true"
2. Re-start your server to pick up the change done at step #1 above.
3. In your project add the following libraries to allow remote access and the required JDBC driver library.
- Weblogic 10.3 Remote-Client
- Oracle JDBC
package pas.au.remote.wls11g;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Date;
import java.util.Hashtable;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
public class RemoteDataSourceAccess
{
private Logger logger = Logger.getLogger(this.getClass().getSimpleName());
public RemoteDataSourceAccess()
{
}
public void run ()
{
logger.log(Level.INFO, "Started RemoteDataSourceAccess at " + new Date());
InitialContext ctx = null;
try
{
ctx = getInitialContext();
DataSource ds = (DataSource) ctx.lookup("jdbc/scottDS");
Connection conn = (Connection) ds.getConnection();
logger.log(Level.INFO, "Got connection : " + conn);
logger.log(Level.INFO, "Auto Commit = " + conn.getAutoCommit());
}
catch (NamingException e)
{
logger.log(Level.SEVERE, "Error occurred", e);
System.exit(1);
}
catch (SQLException e)
{
logger.log(Level.SEVERE, "SQLException occurred", e);
System.exit(1);
}
logger.log(Level.INFO, "Ended RemoteDataSourceAccess at " + new Date());
}
public static InitialContext getInitialContext() throws NamingException
{
String JNDI_FACTORY="weblogic.jndi.WLInitialContextFactory";
String url = "t3://wayne-p2.au.oracle.com:7003";
String username = "weblogic";
String password = "welcome1";
Hashtable<String,String> env = new Hashtable<String,String>();
env.put(Context.SECURITY_PRINCIPAL, username);
env.put(Context.SECURITY_CREDENTIALS, password);
env.put(Context.INITIAL_CONTEXT_FACTORY, JNDI_FACTORY);
env.put(Context.PROVIDER_URL, url);
return new InitialContext(env);
}
public static void main(String[] args)
{
RemoteDataSourceAccess test = new RemoteDataSourceAccess();
test.run();
}
}
5. Output as follows.
25/02/2010 9:22:56 AM pas.au.remote.wls11g.RemoteDataSourceAccess run
INFO: Started RemoteDataSourceAccess at Thu Feb 25 09:22:56 EST 2010
25/02/2010 9:23:03 AM pas.au.remote.wls11g.RemoteDataSourceAccess run
INFO: Got connection : weblogic.jdbc.rmi.SerialConnection_weblogic_jdbc_rmi_internal_ConnectionImpl_weblogic_jdbc_wrapper_PoolConnection_oracle_jdbc_driver_T4CConnection_1032_WLStub@1
25/02/2010 9:23:03 AM pas.au.remote.wls11g.RemoteDataSourceAccess run
INFO: Auto Commit = true
25/02/2010 9:23:03 AM pas.au.remote.wls11g.RemoteDataSourceAccess run
INFO: Ended RemoteDataSourceAccess at Thu Feb 25 09:23:03 EST 2010
Monday, 14 September 2009
Web Services Security in OFM 11g R1
I ran 2 good blog entries for securing web services from JDeveloper 11g onto WLS 11g R1. Both these are great starting points for that and worked well. Saves a lot of time when it's all laid out step by step.
http://one-size-doesnt-fit-all.blogspot.com/2009/08/one-way-ssl-with-jax-ws-using.html
http://kingsfleet.blogspot.com/2009/01/security-policy-worked-example.html
I always create my WLS domains adding Fusion Middleware Control and that then gives you the ability to test the web service from a browser as well as view some runtime statistics for the web service itself when logging into the "/em" application installed into the admin server.
The blog entry showing how to install Fusion Middleware Control into a WLS 11g R1 domain is as follows. I even started deploying from that application rather then using the traditional console application.
http://theblasfrompas.blogspot.com/2009/07/installing-adf-runtime-on-oracle-fusion.html
So in short
1. Log into em using an url as follows
http://{server}:{adminserverport}/em
2. Click on your web service application
3. If indeed web services exist in the application you will see a web services table and "Java EE Web Services" tab as shown below.

4. Click on the "Test" icon to test your web service.
http://one-size-doesnt-fit-all.blogspot.com/2009/08/one-way-ssl-with-jax-ws-using.html
http://kingsfleet.blogspot.com/2009/01/security-policy-worked-example.html
I always create my WLS domains adding Fusion Middleware Control and that then gives you the ability to test the web service from a browser as well as view some runtime statistics for the web service itself when logging into the "/em" application installed into the admin server.
The blog entry showing how to install Fusion Middleware Control into a WLS 11g R1 domain is as follows. I even started deploying from that application rather then using the traditional console application.
http://theblasfrompas.blogspot.com/2009/07/installing-adf-runtime-on-oracle-fusion.html
So in short
1. Log into em using an url as follows
http://{server}:{adminserverport}/em
2. Click on your web service application
3. If indeed web services exist in the application you will see a web services table and "Java EE Web Services" tab as shown below.

4. Click on the "Test" icon to test your web service.
Monday, 25 May 2009
ADF11g fail over within a Weblogic 10.3 Cluster
I recently setup failover for a simple ADF11g application within a Oracle weblogic 10.3 cluster. Once you have your Oracle Weblogic 10.3 cluster in place you really only need to do 2 things on your application side.
Part A
1. Right click on your application module and select "Configurations".
2. Select your config and press the "Edit" button.
3. Click on "Pooling and Scalability" tab.
4. Select the check box "Failover Transaction State Upon Managed Release".
5. Press OK
This will generate the following for your bc4j.xcfg file in your model project with fail over feature switched on.
This provides the most pessimistic protection against application server failure. The application module instances' state is always saved and may be activated by any application module instance at any time. Of course, this capability comes at expense of the additional overhead of eager passivation on each request.
For more information on state management see the following link:
http://download.oracle.com/docs/cd/E12839_01/web.1111/b31974/bcstatemgmt.htm#BABHIBDG
Part B
Now finally we need to ensure our view project which is packaged as a WAR file includes a weblogic.xml file within the WEB-INF folder as follows. This will ensure we setup our application to use HTTP Session replication in the event of a node failure.
Part A
1. Right click on your application module and select "Configurations".
2. Select your config and press the "Edit" button.
3. Click on "Pooling and Scalability" tab.
4. Select the check box "Failover Transaction State Upon Managed Release".
5. Press OK
This will generate the following for your bc4j.xcfg file in your model project with fail over feature switched on.
<AppModuleConfig DeployPlatform="LOCAL"
JDBCName="scott"
jbo.project="model.Model"
name="AppModuleLocal"
ApplicationName="model.AppModule">
<AM-Pooling jbo.dofailover="true"/>
<Security AppModuleJndiName="model.AppModule"/>
</AppModuleConfig>
This provides the most pessimistic protection against application server failure. The application module instances' state is always saved and may be activated by any application module instance at any time. Of course, this capability comes at expense of the additional overhead of eager passivation on each request.
For more information on state management see the following link:
http://download.oracle.com/docs/cd/E12839_01/web.1111/b31974/bcstatemgmt.htm#BABHIBDG
Part B
Now finally we need to ensure our view project which is packaged as a WAR file includes a weblogic.xml file within the WEB-INF folder as follows. This will ensure we setup our application to use HTTP Session replication in the event of a node failure.
<?xml version = '1.0' encoding = 'windows-1252'?>
<weblogic-web-app
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.bea.com/ns/weblogic/weblogic-web-app.xsd"
xmlns="http://www.bea.com/ns/weblogic/weblogic-web-app">
<session-descriptor>
<timeout-secs>300</timeout-secs>
<invalidation-interval-secs>60</invalidation-interval-secs>
<persistent-store-type>replicated_if_clustered</persistent-store-type>
</session-descriptor>
</weblogic-web-app>
While testing this I used the following managed server property to determine which
managed server I was accessing at the time.
String instance = System.getProperty("weblogic.Name");
Wednesday, 6 May 2009
Oracle Weblogic 10.3 Using SSL with the Oracle JDBC THIN driver
I recently created this how to with product management showing how to configure a data source in Oracle WebLogic 10.3 using SSL with the JDBC THIN driver.
http://www.oracle.com/technology/products/weblogic/howto/jdbcssl/index.html
http://www.oracle.com/technology/products/weblogic/howto/jdbcssl/index.html
Thursday, 5 February 2009
Oracle Weblogic 10.3 / RAC 11g Integration How To
I worked with product management to create a how to for Oracle Weblogic 10.3 / RAC 11g Integration. The URL is on OTN now as follows. It comes with a sample web application to test your configuration out as well.
http://www.oracle.com/technology/products/weblogic/howto/rac/index.html
It comes with a white paper as well created by a product manager
http://www.oracle.com/technology/products/weblogic/OracleWLS_RAC.pdf
http://www.oracle.com/technology/products/weblogic/howto/rac/index.html
It comes with a white paper as well created by a product manager
http://www.oracle.com/technology/products/weblogic/OracleWLS_RAC.pdf
Monday, 2 February 2009
Using Log4J with Jdeveloper 11g / Integrated Weblogic Server
A quick demo on how to use Log4j within a JDeveloper workspace for 11g when running web projects. In this example we are using a simple HTTP servlet with just a doGet method defined
1. Create the default "log4j.properties" file within the root src folder of your web project.
# **Set root logger level to DEBUG and its only appender to A.
log4j.rootLogger=DEBUG, A
# ***** A is set to be a ConsoleAppender.
log4j.appender.A=org.apache.log4j.ConsoleAppender
# ***** A uses PatternLayout.
log4j.appender.A.layout=org.apache.log4j.PatternLayout
log4j.appender.A.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
Eg:

2. Add the log4j JAR file to the project's web-inf/lib directory for runtime and as a project library JAR file for compile time. In my case I used the JAR file as follows
> log4j-1.2.15.jar
3. Here is the servlet code which will then use log4j at runtime.
4. When run within the "Integrated Weblogic Server" verify runtime output as follows within JDeveloper's log window.
Target URL -- http://127.0.0.1:7101/Log4JTest-ServletDemo-context-root/log4jservletdemo
0 [[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'] INFO Log4JServletDemo - init() method of servlet Log4JServletDemo
63 [[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'] INFO Log4JServletDemo - init() doGet method of servlet Log4JServletDemo
When your ready to create a WAR file for deployment to an External Weblogic 10.3 server then the log4j.properties file should be added to the web-inf/classes folder automatically with this setup.
1. Create the default "log4j.properties" file within the root src folder of your web project.
# **Set root logger level to DEBUG and its only appender to A.
log4j.rootLogger=DEBUG, A
# ***** A is set to be a ConsoleAppender.
log4j.appender.A=org.apache.log4j.ConsoleAppender
# ***** A uses PatternLayout.
log4j.appender.A.layout=org.apache.log4j.PatternLayout
log4j.appender.A.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
Eg:

2. Add the log4j JAR file to the project's web-inf/lib directory for runtime and as a project library JAR file for compile time. In my case I used the JAR file as follows
> log4j-1.2.15.jar
3. Here is the servlet code which will then use log4j at runtime.
package pas.au.log4j;
import java.io.IOException;
import java.io.PrintWriter;
import org.apache.log4j.Category;
import org.apache.log4j.PropertyConfigurator;
import java.util.Properties;
import java.io.FileInputStream;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.log4j.Logger;
public class Log4JServletDemo
extends HttpServlet
{
Logger log = Logger.getLogger(this.getClass().getSimpleName());
private static final String CONTENT_TYPE = "text/html; charset=windows-1252";
public void init(ServletConfig config)
throws ServletException
{
super.init(config);
log.info("init() method of servlet Log4JServletDemo");
}
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>Log4JServletDemo</title></head>");
out.println("<body>");
out.println("<h2>Log4j demo</h2>");
log.info("init() doGet method of servlet Log4JServletDemo");
out.println("</body></html>");
out.close();
}
}
4. When run within the "Integrated Weblogic Server" verify runtime output as follows within JDeveloper's log window.
Target URL -- http://127.0.0.1:7101/Log4JTest-ServletDemo-context-root/log4jservletdemo
0 [[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'] INFO Log4JServletDemo - init() method of servlet Log4JServletDemo
63 [[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'] INFO Log4JServletDemo - init() doGet method of servlet Log4JServletDemo
When your ready to create a WAR file for deployment to an External Weblogic 10.3 server then the log4j.properties file should be added to the web-inf/classes folder automatically with this setup.
Monday, 15 December 2008
Associate an IDE DB Connection to a Workspace for Web projects in JDeveloper 11g
In JDeveloper 10g you could easily deploy all database connections when running a web project in the embedded OC4J server thus allowing each connection to be represented as a data source at runtime. Turns out the same can be done in JDeveloper 11g and Weblogic Integrated server however the steps are a little different.
1. View -> Database Navigator
2. Drag the IDE connection you wish to use in your workspace. The end result is as follows for the Workspace "WebLogicStuff"

3. Now whenever you run any web project from WebLogicStuff workspace then the database connection "scott" will automatically be deployed as an application level data source.
4. In order to access the connection "scott" we should use a JNDI location as follows within our code.
java:comp/env/jdbc/scottDS
java:comp/env/jdbc/{jdevide-connection-name}DS
Here is some java code we can then use to perform a JNDI lookup of the data source via a simple method which requires the location above to be passed to the method.
1. View -> Database Navigator
2. Drag the IDE connection you wish to use in your workspace. The end result is as follows for the Workspace "WebLogicStuff"

3. Now whenever you run any web project from WebLogicStuff workspace then the database connection "scott" will automatically be deployed as an application level data source.
4. In order to access the connection "scott" we should use a JNDI location as follows within our code.
java:comp/env/jdbc/scottDS
The format would be as follows, depending on the connection name.java:comp/env/jdbc/{jdevide-connection-name}DS
Here is some java code we can then use to perform a JNDI lookup of the data source via a simple method which requires the location above to be passed to the method.
private Connection getConnection (String dataSourceLocation)
throws NamingException, SQLException
{
Connection conn = null;
// Get a context for the JNDI look up
Context ctx = new InitialContext();
// Look up a data source
javax.sql.DataSource ds
= (javax.sql.DataSource) ctx.lookup (dataSourceLocation);
// Create a connection object
conn = ds.getConnection();
return conn;
}
Subscribe to:
Posts (Atom)











