Friday, February 27, 2009

How to configure Hermes JMS for Weblogic and Glassfish

it's a bit painful...



create a session, (action/new/new session)
in the Providers tab, right click, add group wl10 with library: 

weblogic.jar
wlfullclient.jar

for Connection Factory choose "hermes.JNDIConnectionFactory", loader wl10,

property:
binding=javax/jms/QueueConnectionFactory
initialContextFactory=weblogic.jndi.WLInitialContextFactory
providerURL=t3://localhost:7001
securityCredentials=yourpasswordhere
securityPrincipal=weblogic


then click on "discover"....

I wish they had made it simpler, indeed...

check out also this:
http://blogs.oracle.com/jamesbayer/2008/01/hermes_jms_open_source_jms_con.html

it is wise to create a Context and point it to your server. Don't forget to set your initialContextFactory=weblogic.jndi.WLInitialContextFactory
and the loader to wl10

if you get an exception Cannot instantiate class: weblogic.jndi.WLInitialContextFactory  , see here
http://hermesjms.org/forum/viewtopic.php?f=12&t=172
, most likely the Loader is not set.


For Glassfish, I have found these instructions:

http://www.hermesjms.com/forum/viewtopic.php?f=25&t=352

but they probably apply to something different from Glassfish Enterprise Edition 3.0... googling around I understand that one should use com.sun.appserv.naming.S1ASCtxFactory as a Initial Context Factory,
but I could not find this class anywhere in the NetBeans and Glassfish jar files...





Thursday, February 26, 2009

WLST to create a FileStore and a SAF agent


cd('/')
cmo.createFileStore('FileStore_auto_1')

cd('/Deployments/FileStore_auto_1')
cmo.setDirectory('FileStore_auto_1')
set('Targets',jarray.array([ObjectName('com.bea:Name=AdminServer,Type=Server')], ObjectName))

cd('/')
cmo.createSAFAgent('SAFAgent-0')

cd('/SAFAgents/SAFAgent-0')
cmo.setStore(getMBean('/Deployments/FileStore_auto_1'))
set('Targets',jarray.array([ObjectName('com.bea:Name=AdminServer,Type=Server')], ObjectName))
cmo.setServiceType('Sending-only')





Saturday, February 21, 2009

handy SOAP envelope for you

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pvh="http://com/alsb/pvhello">
   <soapenv:Header/>
   <soapenv:Body>
      <pvh:getGreeting>
         <pvh:message>?</pvh:message>
      </pvh:getGreeting>
   </soapenv:Body>
</soapenv:Envelope>


the XSD is available here:




Friday, February 20, 2009

Finding out what Weblogic processes is running in Unix

if you are using NodeManager, it will most likely be running on port 5556


netstat -putanuw | grep 555

will give you this:

tcp 0 0 :::5556 :::* LISTEN 32092/java


where 32092 is the NodeManager's PID

ps -ef | grep 32092

will give you:

beasvbd 10921 22827 0 13:53 pts/0 00:00:00 grep 32092
beasvbd 11121 32092 0 Feb13 ? 00:03:31 /opt/bea/jrockit/R27.3.1/bin/java blablabla weblogic.Server
beasvbd 32092 32069 0 Feb13 ? 00:00:23 /opt/bea/jrockit/R27.3.1/bin/java blablabla weblogic.NodeManager



note that the weblogic.Server's parent PID is the NodeManager's PID


32069 is the shell's PID, which was used to start the server


Note that a Weblogic instance can have multiple Network channels:

[beasvbd@bcdev05 bea_install]$ netstat -putanuw | grep 5610
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 ::ffff:127.0.0.1:5610 :::* LISTEN 29082/java
tcp 0 0 ::ffff:10.40.16.109:5610 :::* LISTEN 29082/java
tcp 0 0 ::ffff:10.40.20.109:5610 :::* LISTEN 29082/java


each of them corresponds to a different Network Interface. note that the PID is the same.

Tuesday, February 17, 2009

Monitoring the content of a directory

if you want to keep under control the content of a directory, here is a quick and dirty Unix script:

while :; do echo `date`; ls -ltr .ssh; sleep 1; done

you can achieve the same with watch date; ls -ltr .ssh

Monday, February 16, 2009

Silent installation of WLI

the only way to make it work is by specifying also a value for ECLIPSE32_HOME, otherwise it fails with a


com.bea.plateng.common.util.ObjectStoreValueNotFoundException: Unable to locate object store key ECLIPSE32_HOME


./platform1020_linux32.bin -mode=silent -silent_xml=pvtests/silent_wli100.xml -log=installlog.log

<bea-installer></bea-installer><input-fields></input-fields><data-value name="ECLIPSE32_HOME" value="/data/software/pvtests/eo"></data-value>
<data-value name="BEAHOME" value="/data/software/pvtests"></data-value><data-value name="USER_INSTALL_DIR" value="/data/software/pvtests/installdir">
</data-value><data-value name="INSTALL_MERCURY_PROFILING_TOOLS" value="false"></data-value>
<data-value name="COMPONENT_PATHS" value="WebLogic Server/Server|WebLogic Server/Server Add-ons|WebLogic Integration/Integration Server|WebLogic Integration/Workshop Integration Extension"></data-value>

Nice little shell script to trace memory occupation of Weblogic processes

this script was provided by the generosity of Mark van Holsteijn www.xebia.com , a man with strong brain muscles.

showWebLogic.sh

#!/bin/bash

#!/bin/bash

echo "pid minheap maxheap vsize residnt share text data name jvm"
ps -ef | grep java | grep -v grep | while read LINE
do
        MINHEAP=$(echo $LINE | sed 's/.*-Xms\([^ ]*\).*/\1/')
        MAXHEAP=$(echo $LINE | sed 's/.*-Xmx\([^ ]*\).*/\1/')
        PID=$(echo $LINE | awk '{print $2}')
        JVM=$(echo $LINE | awk '{print $8}')

        NAME=$(echo $LINE | sed -n -e 's/.*-Dweblogic.Name=\([^ ]*\).*/\1/p')
        if [ -z "$NAME" ] ; then
                NAME=$(echo $LINE | sed -n -e 's/.*weblogic.\(NodeManager\).*/\1/p')
        fi
        if [ -z "$NAME" ] ; then
                NAME="UnknownApp"
        fi
        cat /proc/$PID/statm | \
        awk -vpid=$PID \
        -vjvm="$JVM" \
        -vname="$NAME" \
        -vminheap=$MINHEAP \
        -vmaxheap=$MAXHEAP \
        '{ printf ("%ld\t%s\t%s\t%ldmb\t%ldmb\t%ldmb\t%ldmb\t%ldmb\t%s\t%s\n",
        pid, minheap, maxheap,
        ($1 * 4) / 1024,
        ($2 * 4) / 1024,
        ($3 * 4) / 1024,
        $(4 * 4)/1024, ($6 * 4)/1024, name, jvm); }'

done







the output is:

pid minheap maxheap vsize residnt share text data name jvm

6811 128m 256m 1473mb 169mb 3mb 0mb 1391mb NodeManager /opt/bea/jrockit/R27.3.1/bin/java

8289 512m 512m 2060mb 903mb 4mb 0mb 1962mb pierre_dev_eb_alsb_admin_server java

9893 1024m 1024m 2474mb 1300mb 3mb 0mb 2383mb pierre_dev_eb_alsb_server_1 /opt/bea/jrockit/R27.3.1/bin/java


Saturday, February 14, 2009

some useful Weblogic administration classes

com.bea.plateng.common.registry.LicenseMerger : executed by the UpdateLicense shell script

com.bea.plateng.wizard.WizardController: it's the main class (see MANIFEST.MF) invoked by the installer when installing a BEA product (alsb300_wls100_generic.jar)




Weblogic WLST from Java

Another huge pain in the neck is having to write complex code in Python (or Jython, whatever).

Why should I forgo my Eclipse IDE, with remote debugger, autocomplete, etc to use an unstable Dynamic language which fails without a warning?

So for complex code involving Weblogic tasks, here is how you can generate and run Python statememts withing Java code:


package com.pierre.wlst;


import weblogic.management.scripting.WLST;

import weblogic.management.scripting.utils.WLSTInterpreter;


public class WLSTWrapper {


public static void main(String[] args) {

WLSTWrapper wrapper = new WLSTWrapper();

wrapper. doSomething();

}

public void doSomething() {

WLST.ensureInterpreter();

WLSTInterpreter interpreter = WLST.getWLSTInterpreter();

interpreter.exec("connect('weblogic', 'weblogic', 'localhost:7001')");

interpreter.exec("ls()");

}

}





Running Ant tasks from Java

let's face it, Ant is great but it's a pain in the butt when it comes to writing complex code, with variables, loops, conditions etc.
That's why I love the idea of running Ant tasks directly from Java.
Here is how.
The trick is to bear in mind the Ant object model: A Project contains Targets, a Target contains Tasks. A Task can't run without a Project, otherwise you get a NPE (my compliments to Ant developers for handling so gracefully this exception :o) ).

Of course you can build a "Ant Wrapper" framework on top of this paradygm...


package com.pierre.ant;

import java.io.File;

import org.apache.tools.ant.Project;
import org.apache.tools.ant.Target;
import org.apache.tools.ant.taskdefs.Copy;

public class AntRunner {

public static void main(String[] args) {
AntRunner runner = new AntRunner();
runner.scp();
}
/**
Copy file from a to b, locally
*/
public void scp() {
Project project = new Project();
Target target = new Target();
project.addTarget("ciao", target);
Copy scp = new Copy();
scp.setFile(new File("c:/tmp/vacations.xsd"));
scp.setTodir(new File("c:/temp"));
scp.setProject(project);
target.addTask(scp);
target.execute();
}
}