Monday, December 30, 2013

OSB, WebLogic and Logback / SLF4j

Being totally fed up with the OSB reporting provider, I am setting up logback.
Maven:
<dependency>
  <groupId>ch.qos.logback</groupId>
  <artifactId>logback-core</artifactId>
  <version>1.0.13</version>
</dependency>
<dependency>
  <groupId>ch.qos.logback</groupId>
  <artifactId>logback-classic</artifactId>
  <version>1.0.13</version>
</dependency>
             
<dependency>
  <groupId>ch.qos.logback</groupId>
  <artifactId>logback-parent</artifactId>
  <version>1.0.13</version>
  <type>pom</type>
</dependency>
 
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>1.7.5</version>
</dependency>



vi /opt/oracle/fmw11_1_1_5/wlserver_10.3/common/bin/commEnv.sh

add this to WEBLOGIC_CLASSPATH:

${CLASSPATHSEP}/opt/oracle/fmw11_1_1_5/wlserver_10.3/server/lib/slf4j-api-1.7.5.jar${CLASSPATHSEP}/opt/oracle/fmw11_1_1_5/wlserver_10.3/server/lib/logback-core-1.0.13.jar${CLASSPATHSEP}/opt/oracle/fmw11_1_1_5/wlserver_10.3/server/lib/logback-classic-1.0.13.jar

and copy the JARs:

cd /opt/oracle/fmw11_1_1_5/wlserver_10.3/server/lib/

this only if you have Nexus, otherwise.... copy them manually:

wget http://nexus.nespresso.com/service/local/repositories/adobe-ext/content/ch/qos/logback/logback-core/1.0.13/logback-core-1.0.13.jar

wget http://nexus.nespresso.com/service/local/repositories/adobe-ext/content/ch/qos/logback/logback-classic/1.0.13/logback-classic-1.0.13.jar

wget http://nexus.nespresso.com/service/local/repositories/adobe-ext/content/org/slf4j/slf4j-api/1.7.5/slf4j-api-1.7.5.jar

vi /opt/oracle/domains/osbpl1do/config/osb/logback.xml

<configuration debug="true" scan="true" scanPeriod="30 seconds">
    <jmxConfigurator />
 
    <property name="LOG_DIR" value="/opt/var/log/weblogic/server/" />
 
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <!-- encoders are assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder
            by default -->
        <encoder>
            <pattern>%d %-5level [%thread] %logger{36} - %msg%n
            </pattern>
        </encoder>
    </appender>
 
    <appender name="GM"
        class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${LOG_DIR}GM.log</file>
            <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
              <fileNamePattern>GM.%i.log.zip</fileNamePattern>
              <minIndex>1</minIndex>
              <maxIndex>10</maxIndex>
            </rollingPolicy>
            <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
              <maxFileSize>50MB</maxFileSize>
            </triggeringPolicy>
            <encoder>
                <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
                </pattern>
            </encoder>
    </appender>
 
 
    <logger name="POC_LOG4j" additivity="false" level="INFO">
        <appender-ref ref="GM" />
    </logger>
 
    <root level="DEBUG">
        <appender-ref ref="STDOUT" />
    </root>
 
 
</configuration>


I provide a custom XPath to log :
package com.acme.osb.logging;
import org.apache.xmlbeans.XmlObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
 * Used by OSB to report an Event
 *
 * @author NNVernetPI
 *
 */
public class MessageTrackerSLF4J {
    public static String logMessage(String technicalMessageid,
            String businessId, String eventType, String interfaceName,
            XmlObject payload) {
        Logger projectLogger = LoggerFactory.getLogger(interfaceName);
        StringBuilder sb = new StringBuilder();
        if (projectLogger.isDebugEnabled()) {
            sb.append(" ::InterfaceName::  ").append(interfaceName)
                    .append(" ::Payload:: ").append(payload.xmlText())
                    .append(" ::BusinessID::  ").append(businessId);
        } else {
            sb.append(" ::TechnicalMessageID::  ").append(technicalMessageid)
                    .append(" ::BusinessID::  ").append(businessId)
                    .append(" ::InterfaceName::  ").append(interfaceName)
                    .append(" ::EventType::  ").append(eventType)
                    .append(" ::ServerName:: ")
                    .append(System.getProperty("weblogic.Name"));
        }
        projectLogger.info(sb.toString());
        String logmessage = "Info Message Logged for:: " + interfaceName;
        return logmessage;
    }
    public static String errorLogger(String technicalMessageid,
            String businessId, String interfaceName, XmlObject payload,
            String priority, XmlObject fault) {
        Logger projectLogger = LoggerFactory.getLogger(interfaceName);
        StringBuilder sb = new StringBuilder();
        sb.append("::TechnicalMessageID::  ").append(technicalMessageid)
                .append("  ::InterfaceName::  ").append(interfaceName)
                .append("  ::BusinessID::  ").append(businessId)
                .append(" ::Payload:: ").append(payload.xmlText())
                .append(" ::Priority::  ").append(priority)
                .append(" ::FaultDescription:: ").append(fault.xmlText())
                .append(" ::ServerName:: ")
                .append(System.getProperty("weblogic.Name"));
        projectLogger.error(sb.toString());
        String responseMessage = "Error Message Logged for:: " + interfaceName;
        return responseMessage;
    }
}


which I expose as XPath this way:
  <xpf:function>
            <xpf:name>LOG_SLF_errorLogger</xpf:name>
            <xpf:comment>logs an error</xpf:comment>
            <xpf:namespaceURI>http://www.acme.com/acme2/xquery/xquery-functions</xpf:namespaceURI>
            <xpf:className>com.acme.osb.logging.MessageTrackerSLF4J</xpf:className>
            <xpf:method>java.lang.String errorLogger(java.lang.String, java.lang.String, java.lang.String, org.apache.xmlbeans.XmlObject, java.lang.String, org.apache.xmlbeans.XmlObject)</xpf:method>
            <xpf:isDeterministic>false</xpf:isDeterministic>
            <xpf:scope>Pipeline</xpf:scope>
            <xpf:scope>SplitJoin</xpf:scope>
        </xpf:function>     
        
  <xpf:function>
            <xpf:name>LOG_SLF_messageTracker</xpf:name>
            <xpf:comment>logs an event</xpf:comment>
            <xpf:namespaceURI>http://www.acme.com/acme2/xquery/xquery-functions</xpf:namespaceURI>
            <xpf:className>com.acme.osb.logging.MessageTrackerSLF4J</xpf:className>
            <xpf:method>java.lang.String logMessage(java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.apache.xmlbeans.XmlObject)</xpf:method>
            <xpf:isDeterministic>false</xpf:isDeterministic>
            <xpf:scope>Pipeline</xpf:scope>
            <xpf:scope>SplitJoin</xpf:scope>
        </xpf:function>        


Since I have activated the jmxConfigurator, I can reload the logback.xml configuration file by connecting with JMX:

jconsole -J-Djava.class.path=C:\Oracle\MIDDLE~1\JDK160~1\lib\jconsole.jar;C:\Oracle\MIDDLE~1\JDK160~1\lib\tools.jar;C:\Oracle\Middleware\wlserver_10.3\server\lib\wlfullclient.jar -J-Djmx.remote.protocol.provider.pkgs=weblogic.management.remote -debug
and connect as:
service:jmx:iiop://myserver.acme.com:8001/jndi/weblogic.management.mbeanservers.runtime



The advantage is that I can also set programmatically the logger level for each logger, via JMX.



see here the doc, the first argument is the loggerName, the second is the level

A note: reloadByFileName() requires the FULL PATH : /opt/oracle/domains/osbpl1do/config/osb/logback.xml



Thursday, December 19, 2013

Adding JAR in the weblogic domain lib folder

The problem is: if I put a JAR in the $DOMAIN_HOME/lib folder, will it be actually added to the System classpath, and available to ANYTHING which turns inside WebLogic?
To test this, I create a class
public class Pippo {
 public static String ciao() {
  return "CIAO!";
 }
}


and export it to a file pvtestjava.jar, and put the jar in the domain/lib folder, and restart the whole thing.

IN THE SERVER STDOUT file (NOT in the log file...) I can see:

<Dec 19, 2013 11:23:38 AM CET> <Info> <Security> <BEA-090906> <Changing the default 
Random Number Generator in RSA CryptoJ from
 ECDRBG to FIPS186PRNG. To disable this change, specify -Dweblogic.security.allowCryptoJDefaultPRNG=true>
<Dec 19, 2013 11:23:38 AM CET> <Notice> <WebLogicServer> <BEA-000395>
 <Following extensions directory contents added to the end of the classpath:
/opt/oracle/domains/osbpl1do/lib/log4j_1.2.8.jar:
/opt/oracle/domains/osbpl1do/lib/pvtestjava.jar>
<Dec 19, 2013 11:23:39 AM CET> <Info> <WebLogicServer> <BEA-000377> <Starting WebLogic Server with Java HotSpot(TM) 64-Bit Server VM Version 20.8-b03 from Sun Microsystems Inc.>



HOWEVER, refrain from rejoicing so soon. Not necessarily your application will see the JAR.
The documentation says
"" The JARS in the domain /lib directory will not be appended to the system classpath. The classloader that gets created is a child of the system classloader. Any classes that are in JARs in the domain /lib directory will only be visible to J2EE applications, such as EAR files. Classes in the system classpath cannot access classes in the domain /lib directory.""
For instance, the "Driver Interceptor:" to profile a Datasource will not be able to use this classpath extension mechanism. And if you dump the system classpath you will NOT see those domain/lib jars.

The EXTENSION classpath can be explicitly set with -Dweblogic.ext.dirs=$DOMAIN_HOME/lib

Tuesday, December 17, 2013

WebLogic "run as" webApplication

Here http://docs.oracle.com/cd/E11035_01/wls100/security/thin_client.html#wp1046373 you find an example on how to attach a principal to a webapp request, without having to explicitly passing it like in:

curl -u username:password url

it works like a breeze

weblogic.xml:

<?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>gridlinkha</context-root>
    <run-as-role-assignment>
       <role-name>hypericrole</role-name>
       <run-as-principal-name>weblogic</run-as-principal-name>
     </run-as-role-assignment>  
</weblogic-web-app>




web.xml:


<?xml version = '1.0' encoding = 'windows-1252'?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
         version="2.5" xmlns="http://java.sun.com/xml/ns/javaee">
  <servlet>
    <servlet-name>FCFHAServlet</servlet-name>
    <servlet-class>oracle.support.ha.FCFHAServlet</servlet-class>
        <run-as>
      <role-name>hypericrole</role-name>
    </run-as>
  </servlet>
    <security-role>
    <role-name>hypericrole</role-name>
  </security-role>
  <servlet-mapping>
    <servlet-name>FCFHAServlet</servlet-name>
    <url-pattern>/fcfhaservlet</url-pattern>
  </servlet-mapping>
  <welcome-file-list>
    <welcome-file>/index.html</welcome-file>
  </welcome-file-list>
</web-app>




OSB: wlsbjmsrpDataSource can be looked up only by an Admin or ALSBSystem user

The short way:
cd /opt/oracle/domains/osbdev1do/servers/osbdev1ms1/data/ldap/ldapfiles

less EmbeddedLDAP.data

search for wlsbjmsrpDataSource 


you will find the policy:

<Policy xmlns="urn:oasis:names:tc:xacml:2.0:policy:schema:os" PolicyId="urn:bea:xacml:2.0:entitlement:resource:type@E@Fjndi@G@M@Oapplication@E@M@Opath@E@VwlsbjmsrpDataSource@W" RuleCombiningAlgId="urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:first-applicable"><Description>Rol(ALSBSystem) | Rol(Admin)</Description><Target><Resources><Resource><ResourceMatch MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal"><AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">type=<jndi>, application=, path={wlsbjmsrpDataSource}</AttributeValue><ResourceAttributeDesignator AttributeId="urn:oasis:names:tc:xacml:2.0:resource:resource-ancestor-or-self" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true"/></ResourceMatch></Resource></Resources></Target><Rule RuleId="primary-rule" Effect="Permit"><Condition><Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:or"><Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-is-in"><AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">ALSBSystem</AttributeValue><SubjectAttributeDesignator AttributeId="urn:oasis:names:tc:xacml:2.0:subject:role" DataType="http://www.w3.org/2001/XMLSchema#string"/></Apply><Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-is-in"><AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Admin</AttributeValue><SubjectAttributeDesignator AttributeId="urn:oasis:names:tc:xacml:2.0:subject:role" DataType="http://www.w3.org/2001/XMLSchema#string"/></Apply></Apply></Condition></Rule><Rule RuleId="deny-rule" Effect="Deny"></Rule></Policy>



so if you are using the GridLink http://www.oracle.com/technetwork/articles/gridlink-rac-488352.zip monitoring application, you should make sure it runs with a technical id which is Admin or ALSBSystem .

Saturday, December 14, 2013

Bertrand Russel on Managers

"I once saw a photograph of a large herd of wild elephants in Central Africa seeing an airplane for the first time, and all in state of wild collective terror... As, however, there were no managers among them, the terror died down when the airplane was out of sight."

More Russel's quotes here. Good old Bertrand Russel, he was my adolescence hero, he inspired me to be a Conscience Objector against war, at a time when in Italy it was still a tough challenge.





(PS the original quote was "journalists", not "managers")

Wednesday, December 11, 2013

Git: SSL certificate problem: unable to get local issuer certificate

git clone https://stash.acme.com/scm/pup/biemond-orawls-vagrant.git

Cloning into 'biemond-orawls-vagrant'...
fatal: unable to access 'https://stash.acme.com/scm/pup/biemond-orawls-vagrant.git/': SSL certificate problem: unable to get local issuer certificate

The secret is
set GIT_SSL_NO_VERIFY=true
git clone etc etc


Tuesday, December 10, 2013

Remove annoying debug info from wlst.sh

I normally run /opt/oracle/fmw11_1_1_5/osb/common/bin/wlst.sh for all WLST commands.

This print a page of debug information (mostly, twice the CLASSPATH and once the PATH.
It's a lot of unneeded info which clutters the logs.

The script will invoke in sequence:
/opt/oracle/fmw11_1_1_5/osb/common/bin/setHomeDirs.sh
/opt/oracle/fmw11_1_1_5/utils/config/10.3/setHomeDirs.sh
/opt/oracle/fmw11_1_1_5/oracle_common/common/bin/wlst.sh

...
and plenty of other scripts, but finally it will call /opt/oracle/fmw11_1_1_5/wlserver_10.3/common/bin/wlst.sh
it's interesting that we have 4 wlst.sh scripts:
/opt/oracle/fmw11_1_1_5/oracle_common/common/bin/wlst.sh
/opt/oracle/fmw11_1_1_5/osb/common/bin/wlst.sh
/opt/oracle/fmw11_1_1_5/osb/harvester/wlst.sh
/opt/oracle/fmw11_1_1_5/wlserver_10.3/common/bin/wlst.sh

One echo is in /opt/oracle/fmw11_1_1_5/wlserver_10.3/common/bin/wlst.sh
The other echo CLASSPATH=$CLASSPATH statement is in
/opt/oracle/fmw11_1_1_5/wlserver_10.3/server/bin/setWLSEnv.sh


Saturday, December 7, 2013

Getting started with Spring UI MVC, a basic WebApplication "download and play"

Something that literally runs me crazy is when you must spend one hour just to setup the basics just to be able to start working with a new product. Need to download a dozen files, manually hack a few XML... just to do a basic Hello World. So aggravating.

Existing tutorials also do their best to flood you with words and giving you only fragmentary instructions on how to get started.

In reality, nothing is more educational than having a ready environment to start playing with the product. Just give me that sandbox, a link to the documentation and shut up.

Here for instance there are instructions on how to get started with Spring Source Tooolkit.

Here is a "download and play" https://javatoolsforweblogic.googlecode.com/svn/trunk/wlavatar.zip Eclipse project. All you need is to install Maven and create the Eclipse variable MVN_REPO to point to your Maven repository, then open a prompt in the Project's root folder and type "mvn package". Have fun.



Wednesday, December 4, 2013

JMXTerm and WebLogic

Download the uberjar http://wiki.cyclopsgroup.org/jmxterm/download (I love that, no need to have complicated classpaths). This link worked for me.

On how to configure WebLogic for JMS see here.

This is a sample session:
java -jar jmxterm-1.0-alpha-4-uber.jar
#this will connect remotely
open myserver.acme.com:8888
#this will list all available beans
beans
#this will filter only com.bea stuff
domain com.bea
#this will set your current bean
bean com.bea:Name=wlsbjmsrpDataSource,ServerRuntime=osbpl1as,Type=JDBCDataSourceRuntime
#this will get an attrbute from current bean
get ActiveConnectionsCurrentCount


For a more complete example: Here a lot of useful commands.



Git: Received HTTP code 407 from proxy

I was cloning a git project:

git clone https://github.com/jiaqi/jmxterm

and I got
fatal: unable to access 'https://github.com/jiaqi/jmxterm/': Received HTTP code 407 from proxy after
 CONNECT


just do

git config --global http.proxy http://myusername:mypassword@proxy.acme.com:8080

and it will work (inshallah)

WLST: certificate parsing exception PKIX

"The loading of the trusted certificate list raised a certificate parsing exception PKIX: Unsupported OID in the AlgorithmIdentifier object"

it turned out that I had to add to the WLST trust store (wlsTrust.jks) the root certificate of the CA certifying the Identity Store of the domain

and add this to wlst.sh :

export WLST_PROPERTIES="-Dweblogic.security.SSL.ignoreHostnameVerification=true -Dweblogic.security.TrustKeyStore=CustomTrust -Dweblogic.security.CustomTrustKeyStoreFileName=/opt/oracle/certs/wlsTrust.jks -Dweblogic.security.CustomTrustKeyStorePassPhrase=bla -Dweblogic.security.CustomTrustKeyStoreType=JKS"



Monday, December 2, 2013

Puppet and WebLogic the Biemond way

I always follow Biemond post, on the the richest sources of inspiration for all Oracle Professionals.

Here he makes his WebLogic/Puppet module available to the public:
http://biemond.blogspot.ch/2013/11/new-puppet-3-weblogic-provisioning.html

I login as root on my vagrant VirtualBox (RHEL) and I type:
puppet --version
3.2.4 (Puppet Enterprise 3.0.1)

Then I type
puppet module install biemond/orawls

Notice: Preparing to install into /etc/puppetlabs/puppet/modules ...
Notice: Created target directory /etc/puppetlabs/puppet/modules
Notice: Downloading from https://forge.puppetlabs.com ...
Notice: Installing -- do not interrupt ...
/etc/puppetlabs/puppet/modules
âââ biemond-orawls (v0.2.1)

Cool!
I see that he has also provided a Vagrant box https://github.com/biemond/biemond-orawls-vagrant. I do a "git clone https://github.com/biemond/biemond-orawls-vagrant" and I got the biemond-orawls-vagrant folder with my vagrantfile in it. I cd biemond-orawls-vagrant and do vagrant up.

I get this nasty message
Vagrant has detected that you have a version of VirtualBox installed
that is not supported. Please install one of the supported versions
listed below to use Vagrant:

4.0, 4.1, 4.2

and in fact I have the latest 4.3.4 version of VirtualBox.
I do vagrant --version
Vagrant version 1.1.5
Ok let's download the latest 1.3.5 vagrant .
and install it (it takes a looooong time, reboot required )
I repeat "vagrant up" and this time Vagrant is happy and it downloads the centos-6.4-x86_64 base box (600 MB, it can take a long time depending on the connection speed)


The second attempt fails because there is no /vagrant/jdk-7u45-linux-x64.tar.gz file

I download the missing file from http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html and I put the jdk-7u45-linux-x64.tar.gz file in the same folder where I keep the vagrantfile (it will be synced by Vagrant, and mapped to /vagrant/jdk-7u45-linux-x64.tar.gz - after a vagrant destroy and another vagrant up... ).

When you connect to the VBOX, configure your putty with 127.0.0.1 port 2222 (note that in the VirtualBOx, it's also specified the IP 127.0.0.1, otherwise each time the IP of the host changes, you have to change the putty configuration...)

This time around, it complains that /data/install/wls1036_generic.jar is not found.

I download it from here http://download.oracle.com/otn/nt/middleware/11g/wls/1036/wls1036_generic.jar and manually copy it to /data/install and to the /vagrant share (melius abundare quam deficere) in the VBOX

I run "vagrant provision".

Again, p17071663_1036_Generic.zip is missing (ah if only I had read the doc before...)...
to get this file, you must log into support.oracle.com, click on "patches", specify the WebLogic 10.3.6 Product for Any platform and you will be presented with only one download: "SU Patch [BYJ1]: WLS PATCH SET UPDATE 10.3.6.0.6 (Patch) p17071663_1036_Generic.zip"

This time around I get a "Error: /Stage[main]/Bsu/Orawls::Bsu[BYJ1]/Exec[exec bsu ux BYJ1]/returns: change from notrun to 0 failed: Command exceeded timeout" after the extraction of the patchset.

For the OSB version, refer to:

https://github.com/matthewbaldwin/vagrant-osb

which is really well documented.

PS Important: don't run "vagrant up" because the node1 will copydomain from admin node BEFORE this is ready. You should first do "vagrant up admin", then "vagrant up node1" and vagrant up node2". After the "vagrant up admin" the admin server is running and accessble from the host machine with http://10.10.10.10:7001/console/ (this is not a global ip, it will work only locally)

OSB: disable enable status of Proxy Services

#There is a change to do to be able to run this WLST script:
#vi /opt/oracle/fmw11_1_1_5/osb/common/bin/wlst.sh
#change this:
#export CLASSPATH
#into this:
#CLASSPATH=/opt/oracle/fmw11_1_1_5/osb/lib/sb-kernel-api.jar:/opt/oracle/fmw11_1_1_5/osb/lib/sb-kernel-impl.jar:/opt/oracle/fmw11_1_1_5/osb/modules/com.bea.common.configfwk_1.5.0.0.jar:$CLASSPATH
#export CLASSPATH


import javax.management
import java.util
import javax.management.remote
import javax.naming
import weblogic.management.mbeanservers.domainruntime
import com.bea.wli.sb.management.configuration

from java.util import Hashtable
from java.util import HashSet
from javax.management.remote import JMXServiceURL
from weblogic.management.mbeanservers.domainruntime import DomainRuntimeServiceMBean
from javax.naming import Context
from javax.management.remote import JMXConnectorFactory
from javax.management import ObjectName
from com.bea.wli.sb.management.configuration import SessionManagementMBean
from com.bea.wli.sb.management.configuration import ALSBConfigurationMBean
from com.bea.wli.sb.management.configuration import CommonServiceConfigurationMBean
import weblogic.management.jmx.MBeanServerInvocationHandler
from com.bea.wli.config import Ref



from com.bea.wli.config.env import EnvValueQuery
from com.bea.wli.config.env import QualifiedEnvValue
from com.bea.wli.config.resource import DependencyQuery
from com.bea.wli.sb.management.query import ProxyServiceQuery
from com.bea.wli.sb.management.query import BusinessServiceQuery

from com.bea.wli.sb.util import EnvValueTypes
from java.util import Collection
from java.util import Collections

def readvarsDPCL(clargs):
    print "readvarsDPCL executed with clargs=", clargs
    domain = None
    password = None
    command = None
    list = None
    opts, args = getopt.getopt(clargs, "d:p:c:l:")
    for opt, arg in opts:
        if opt in "-d":
            domain = arg
        if opt in "-p":
            password = arg
        if opt in "-c":
            command = arg
        if opt in "-l":
            list = arg
    return domain, password, command, list



def enableDisableAllServices(command):
    refs = configMBean.getRefs(Ref.DOMAIN)
    refsList = ArrayList()
    refsList.addAll(refs)
    
    for ref in refsList :
        if ref.getTypeId() == "ProxyService" or ref.getTypeId() == "BusinessService" :
            if ref.getTypeId() == "ProxyService" :
                projectName = ref.getFullName()
                found = False
                for project in list.split(','):
                    if project in projectName:
                        found = True
                if (list == 'ALL') or found:
                    if command == 'enable':
                        print "enabling service for ", projectName
                        proxyServiceConfigurationMBean.enableService(ref)
                    if command == 'disable':
                        print "disabling service for ", projectName
                        proxyServiceConfigurationMBean.disableService(ref)
                    if command == 'status':
                        print "service ", projectName , " enabled=", proxyServiceConfigurationMBean.isEnabled(ref)


#reading command line parameters
domain, password, command, list = readvarsDPCL(sys.argv[1:])
print "domain=", domain

if (domain == None) :
    print('ERROR: invalid command, expected arguments "domain" ')
    exit()



#please enter here your parameters
adminUserName, adminPassword, adminURL = ["bla", "bla", "bla"]
LISTEN_ADDRESS_VIP = 'bla'
PORT = 'bla'

if (adminPassword == None) :
     sys.stderr.write("unable to proceed, password not set\n")
     sys.exit()

if (command == None):
    print "please provide a command (enable/disable)"
    exit()
         
if (list == None):
    print "please provide a comma separated list of projects (ALL for all projects)"
    exit()
             
sessionName = "EnabledChange"

serviceURL=JMXServiceURL("t3", LISTEN_ADDRESS_VIP, int(PORT), "/jndi/" + DomainRuntimeServiceMBean.MBEANSERVER_JNDI_NAME)

h=Hashtable()
h.put(Context.SECURITY_PRINCIPAL, adminUserName)
h.put(Context.SECURITY_CREDENTIALS, adminPassword)
h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, "weblogic.management.remote")

conn = JMXConnectorFactory.connect(serviceURL, h)

mbconn = conn.getMBeanServerConnection()

sm = JMX.newMBeanProxy(mbconn, ObjectName.getInstance(SessionManagementMBean.OBJECT_NAME), SessionManagementMBean)

sm.createSession(sessionName)

try:
    configMBean = JMX.newMBeanProxy(mbconn, ObjectName.getInstance("com.bea:Name=" + ALSBConfigurationMBean.NAME + "." + sessionName + ",Type=" + ALSBConfigurationMBean.TYPE), ALSBConfigurationMBean)
    domainService = weblogic.management.jmx.MBeanServerInvocationHandler.newProxyInstance(mbconn, ObjectName(DomainRuntimeServiceMBean.OBJECT_NAME), DomainRuntimeServiceMBean, false)
    proxyServiceConfigurationMBean = domainService.findService(String("ProxyServiceConfiguration.").concat(sessionName),'com.bea.wli.sb.management.configuration.ProxyServiceConfigurationMBean', None)
    enableDisableAllServices(command)
    sm.activateSession(sessionName, "Complete enable/disable services")
    conn.close()

except Exception, inst:
    print inst
    print sys.exc_info()[0]
    dumpStack()
    if sm.sessionExists(sessionName):
        print "undoing session"
        sm.discardSession(sessionName)
    sys.stderr.write("unable to work on domain " + domain)



An alternative script - connecting with t3 and using the secureConfig files for authentication - is:

#There is a change to do to be able to run this WLST script:
#vi /opt/oracle/fmw11_1_1_5/osb/common/bin/wlst.sh
#change this:
#export CLASSPATH
#into this:
#CLASSPATH=/opt/oracle/fmw11_1_1_5/osb/lib/sb-kernel-api.jar:/opt/oracle/fmw11_1_1_5/osb/lib/sb-kernel-impl.jar:/opt/oracle/fmw11_1_1_5/osb/modules/com.bea.common.configfwk_1.5.0.0.jar:$CLASSPATH
#export CLASSPATH


import javax.management
import java.util
import javax.management.remote
import javax.naming
import weblogic.management.mbeanservers.domainruntime
import com.bea.wli.sb.management.configuration

from java.util import Hashtable
from java.util import HashSet
from javax.management.remote import JMXServiceURL
from weblogic.management.mbeanservers.domainruntime import DomainRuntimeServiceMBean
from javax.naming import Context
from javax.management.remote import JMXConnectorFactory
from javax.management import ObjectName
from com.bea.wli.sb.management.configuration import SessionManagementMBean
from com.bea.wli.sb.management.configuration import ALSBConfigurationMBean
from com.bea.wli.sb.management.configuration import CommonServiceConfigurationMBean
import weblogic.management.jmx.MBeanServerInvocationHandler
from com.bea.wli.config import Ref
from cmdbfile import connectSecureToAdmin
import getopt

verbose = False

def readvarsDCL(clargs):
    print "readvarsDPCL executed with clargs=", clargs
    domain = None
    password = None
    command = None
    list = None
    opts, args = getopt.getopt(clargs, "d:c:l:")
    for opt, arg in opts:
        if opt in "-d":
            domain = arg
        if opt in "-c":
            command = arg
        if opt in "-l":
            list = arg
    return domain, command, list



def enableDisableAllServices(command):
    refs = configMBean.getRefs(Ref.DOMAIN)
    refsList = ArrayList()
    refsList.addAll(refs)
    if verbose: print len(refsList), " Refs found"
    
    for ref in refsList :
        if ref.getTypeId() == "ProxyService" :
            projectName = ref.getFullName()
            if verbose: print "processing ", projectName
            found = False
            for project in list.split(','):
                if project in projectName:
                    found = True
            if (list == 'ALL') or found:
                if command == 'enable':
                    print "enabling service for ", projectName
                    proxyServiceConfigurationMBean.enableService(ref)
                if command == 'disable':
                    print "disabling service for ", projectName
                    proxyServiceConfigurationMBean.disableService(ref)
                if command == 'status':
                    print "service ", projectName , " enabled=", proxyServiceConfigurationMBean.isEnabled(ref)


#reading command line parameters
domain, command, list = readvarsDCL(sys.argv[1:])
print "domain=", domain

if (domain == None) :
    print('ERROR: invalid arguments, expected arguments "domain" ')
    exit()

if (command == None or command not in ['enable', 'disable', 'status']):
    print "please provide a valid command (enable/disable/status)"
    exit()
         
if (list == None):
    print "please provide a comma separated list of projects (ALL for all projects)"
    exit()
             

userConfigFile, userKeyFile, serverURL = connectSecureToAdmin(domain)
connect(userConfigFile=userConfigFile,userKeyFile=userKeyFile,url=serverURL)

domainRuntime()

sessionName = "DisableEnableProjects" + Long(System.currentTimeMillis()).toString()
sessionMBean = findService(SessionManagementMBean.NAME,SessionManagementMBean.TYPE)
sessionMBean.createSession(sessionName)
print 'Session was created … ' + sessionName

try:
    proxyServiceConfigurationMBean = findService("ProxyServiceConfiguration." + sessionName,"com.bea.wli.sb.management.configuration.ProxyServiceConfigurationMBean")
    configMBean = findService(ALSBConfigurationMBean.NAME, ALSBConfigurationMBean.TYPE)
    enableDisableAllServices(command)
    sessionMBean.activateSession(sessionName, "Complete enable/disable services")

except Exception, inst:
    print inst
    print sys.exc_info()[0]
    dumpStack()
    if sessionMBean.sessionExists(sessionName):
        print "undoing session"
        sessionMBean.discardSession(sessionName)
    sys.stderr.write("unable to work on domain " + domain)




JMS message delete in Java

destinationJNDI should contain the JNDI name of the queue, like "CommonJmsServer1@jms.jndi.dq.NL_Notifications.NLNotificationReprocessQ".


ctx should be a valid InitialContext like:
idlist should be a CSV list of message IDs that you want to delete


 Properties env = new Properties();
  env.put(javax.naming.Context.PROVIDER_URL, PROVIDER_URL);
  env.put(Context.SECURITY_PRINCIPAL, WL_USER);
  env.put(Context.SECURITY_CREDENTIALS, WL_PASSWORD);
  env.put(Context.INITIAL_CONTEXT_FACTORY, WL_INITIAL_CONTEXT_FACTORY);
  InitialContext ctx = new InitialContext(env);


 javax.jms.Queue queue = (javax.jms.Queue) ctx.lookup(destinationJNDI.toString());

  // lookup the queue connection factory
  QueueConnectionFactory queueConnFactory = (QueueConnectionFactory) ctx.lookup(WEBLOGIC_JMS_XA_CONNECTION_FACTORY);
  // create a queue connection
  QueueConnection queueConn = queueConnFactory.createQueueConnection();
  queueConn.start();

  // create a queue session
  Session queueSession = queueConn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
  for (String id : idlist.split(",")) {
      if (id.startsWith("ID:") ) {
        MessageConsumer consumer = queueSession.createConsumer(queue, " JMSMessageID='" +   id + "'");
        Message message = consumer.receive(1000);
        out.write("message = " + message + " ");
        out.write("deleted ID " + id + " ");
      }
  }
  queueSession.close();
  queueConn.close();


(posted also on StackOverflow)

Sunday, December 1, 2013

Windows 8 is just plain horrible

I have made the big mistake of offering an acquaintance a brand new Laptop, to discover only too late it was mounting Windows 8.
It's like a computer turned into a IPhone. Plain stupid choice... the Iphone UI was meant for a small screen, while on a 17 inches screen you can afford a lot more ergonomics than an Iphone.

All the people who came to grip with it, simply hated the new User Interface.

There are tricks to make Windows 8 look more like its predecessors, but it's not going to be very effective IMHO.

I am sure you didn't need YET another reason to hate Microsoft, buy they are really doing their best to poison our life.
Do yourself a favour: refuse to buy anything who mounts Windows 8.
Better an old crappy laptop with Windows XP than this freak.

barefoot at office

I am a strong advocate of Primitivism - meaning by that from the invention of Agriculture (10k BC) onwards humanity has only experienced a degradation in the quality of life.

Small tribal units scattered over a vast territory and eking out a living my marginally cropping the fruits of Earth, was the real Zenith of civilization. Lascaux forever. No nuclear weapons, no pollution, no mass warfare, no electronic loneliness, no massive ecosystems destruction, no high-heels shoes with snotty women inside. Sometimes out might be eaten by a lion, but that's life - better a lion than scam capitalism.

Unfortunately in the corporate world it is believed that the more we complicate life, the better. So walking barefoot is not considered OK - although we have been doing that for million of years and it was quite OK since we did quite well as a species.

I am affected by flat feet because when a child I was made to wear the same shoes for several years until they busted my metatarsal arches. This flat feet condition can be extremely taxing on your quads and calves. Any kind of insoles or orthotics have proven useless if not harmful. When you are affected by flat-feet, the best thing you can do is walking barefoot. On grass, on sand, even on asphalt (but don't overdo it on asphalt or you will get painful blisters... asphalt is not natural and our feet were not engineered for it).

The second best alternative is to try some "special" minimalistic shoes, who get you as close as possible to the barefoot experience without management kicking you out: I am trying now this https://en.wikipedia.org/wiki/Vivobarefoot

I have tried also https://en.wikipedia.org/wiki/Vibram_FiveFingers but it's not really acceptable at office.... besides I hate accommodating each toe in a separate slot...

Healthy, primitive feet who have never known the imprisonment of a shoe:



Thursday, November 28, 2013

Plumbum: Never write shell scripts again

http://plumbum.readthedocs.org/en/latest/
I haven't evaluated it, but surely I am 100% in favor of writing shell scripts in Python...

ALL unix shells languages suck big time... I am 10 times more productive in Python (even being a beginner) than in bash or korn...

Eclipse: open .sh files with text editor

Something annoying is that in Eclipse, when you open a .sh file, it will run an external editor to edit it.

Open Preferences, General/Editors/File Associations and add the extension (file type) .sh and associate the editor "Text Editor".



Java, JMX, WebLogic and DomainRuntime

I try to run the code:

http://docs.oracle.com/cd/E12840_01/wls/docs103/jmx/accessWLS.html#wp1111297

I get this error:
java.net.MalformedURLException: Unsupported protocol: t3
I add "C:\Oracle\Middleware\wlserver_10.3\server\lib\wljmxclient.jar" to the classpath

This time I receive a
"org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 211 completed: No" caused by java.io.IOException: End-of-stream at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.readFully(SocketOrChannelConnectionImpl.java:666)

This is apparently an issue in the JVM (see Doc ID 1598451.1 ) ... they say one can add -Dcom.sun.CORBA.connection.ORBHighWaterMark=300 ... personally I give up in frustration.

Wednesday, November 27, 2013

weblogic.management.provider.EditSaveChangesFailedException

I try to activate a session in WLS, and I get this
java.lang.RuntimeException: weblogic.management.provider.EditSaveChangesFailedException
caused by

java.io.IOException: No such file or directory at java.io.UnixFileSystem.createFileExclusively(Native Method) at java.io.File.createNewFile(File.java:883) at weblogic.management.provider.internal.DescriptorHelper.getRecoveryFileForNewFile(DescriptorHelper.java:205) at weblogic.management.provider.internal.DescriptorHelper.saveDescriptorTree(DescriptorHelper.java:122) at weblogic.management.provider.internal.DescriptorHelper.saveDescriptorTree(DescriptorHelper.java:49) at weblogic.management.provider.internal.EditAccessImpl.saveChanges(EditAccessImpl.java:704) ... 133 more

It turned out that the file system was full :o(

No disk space monitoring? Ahi Ahi Ahi....



Monday, November 25, 2013

WebLogic JMS: setting TTL (time to live) aka Expiration Time on messages

you can set a Time To Live for a JMS message using the WLS console, with "Overrides / Time-to-Live Override", but you should also select the "Delivery Mode Override:" = Persistent, otherwise you get this error:
Message icon - Error An error occurred during activation of changes, please see the log for details.
Message icon - Error [Management:141191]The prepare phase of the configuration update failed with an exception:
Message icon - Error VALIDATION PROBLEMS WERE FOUND problem: cvc-enumeration-valid: string value 'No-Delivery' is not a valid enumeration value for delivery-mode-type in namespace http://xmlns.oracle.com/weblogic/weblogic-jms:

then you should also choose what to to with the expired message (Expiration Policy:), best thing is to redirect it to an Error Destination.

The weird thing is that this TTL Override doesn't see to work when you create a new JMS message from the WL console. If you monitor the JMS messages in the queue, the JMS Expiration is still set to 0.
In OSB, you can assign a default "JMS expiration" to the Business Service sending messages to the JMS destination, or you can assign a JMS Expiration at runtime (even in the test console).
Another way is to set the "Default Time-to-Live:" at Connection Factory level.
This is the WLST code to set the Override at JMS Destination level:
#you should have created a PV_OSB_TESTModule JMSModule and a PV_OSB_TESTQ Distributed Queue

cd('/JMSSystemResources/PV_OSB_TESTModule/JMSResource/PV_OSB_TESTModule/UniformDistributedQueues/PV_OSB_TESTQ/DeliveryFailureParams/PV_OSB_TESTQ')

cmo.setErrorDestination(getMBean('/JMSSystemResources/PV_OSB_TESTModule/JMSResource/PV_OSB_TESTModule/UniformDistributedQueues/PV_OSB_TESTReprocessQ'))


cmo.setExpirationPolicy('Redirect')

cd('/JMSSystemResources/PV_OSB_TESTModule/JMSResource/PV_OSB_TESTModule/UniformDistributedQueues/PV_OSB_TESTQ/DeliveryParamsOverrides/PV_OSB_TESTQ')


cmo.setTimeToLive(120000)




Saturday, November 23, 2013

JSP error page


<%@page isErrorPage="true" %>
<html>
<body>
<h1>Error page</h1>
<pre>
<% if (exception != null) {
 out.write("exception message=" + exception.toString());
}
else {
 out.write("no exception available");
} 
%>
</pre>
</body>
</html>




Websphere MQ: getting my feet wet into it

First install Eclipse
http://archive.eclipse.org/eclipse/downloads/drops/R-3.4.2-200902111700/download.php?dropFile=eclipse-SDK-3.4.2-win32.zip

Download and install it - do the custom installation without MQ Explorer which requires also Websphere Eclipse installation.

One restarted, you find an icon in the bottom right "Webpshere MQ Running".
Right click to open the Alert monitor

http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/index.jsp?topic=/com.ibm.mq.amqtac.doc/wq10860_.htm


For OSB, you should download com.ibm.mq.jar for 7.0.1 :

http://www-01.ibm.com/support/docview.wss?rs=171&uid=swg24019253&loc=en_US&cs=utf-8&lang=en

A useful tool is http://www.angussoft.co.uk/ queuezee. I could not make it work though :o(


________

HOw to configure OSB for MQ:

http://download.oracle.com/docs/cd/E13159_01/osb/docs10gr3/mqtransport/

new BS, Transport typed,  protocol MQ

Add URI

"The MQ Connection Resource default/mqConnection specified in URI mq://local-queue?conn=default/mqConnection does not exist"

Why? Because you need to create first a  New MQ Connection Resource

this tool can help:
http://www.niratul.com/

before you install, add this to env variable CLASSPATH  
C:\apps\mq\com.ibm.mq.commonservices.jar;C:\apps\mq\com.ibm.mq.defaultconfig.jar;C:\apps\mq\connector.jar;C:\apps\mq\com.ibm.mq.headers.jar;C:\apps\mq\com.ibm.mq.jar;C:\apps\mq\com.ibm.mq.jmqi.jar;C:\apps\mq\com.ibm.mq.pcf.jar;C:\apps\mq\com.ibm.mq.postcard.jar;C:\apps\mq\com.ibm.mq.tools.ras.jar

(these jars are in C:\Program Files\IBM\WebSphere MQ\java\lib)






OSB: Publish WSDL to UDDI

In OSB11 (Eclipse 3.5.3) if you right click on a WSDL you get
Web Services / Publish WSDL File

You choose "Publish this Web Service to the Unit Test UDDI Registry.

If you have not registered any UDDI Registry, you get this error message:

IWAB0363E No UDDI registry available

Do solve the problem, go to
http://ws.apache.org/juddi/releases.html

there is a 3.0.2,
download it, unzip it, deploy juddiv3-war-3.0.2.war to WebLogic.



in Eclipse do New , Other, enter UDDI and select "UDDI Registry".
You must create it inside a Oracle Service Bus Configuration project.



On Java side, you can use http://uddi4j.sourceforge.net/doc.html  UDDI4J to invoke the UDDI services.

Friday, November 22, 2013

WLST to monitor all Datasources on all Managed Servers by connecting only to the Admin

#connect to the admin server

domainRuntime()
allservers=ls('/ServerRuntimes/', returnMap='true')
for server in allservers:
    allds = ls('/ServerRuntimes/' + server + '/JDBCServiceRuntime/' + server + '/JDBCDataSourceRuntimeMBeans', returnMap='true')
    for ds in allds:
        cd ('/ServerRuntimes/' + server + '/JDBCServiceRuntime/' + server + '/JDBCDataSourceRuntimeMBeans/' + ds)
        print server, ds, cmo.getActiveConnectionsCurrentCount()




WebLogic JMX remote using JMX protocol and JMXTrans

Make sure this is enabled in your domain configuration:
a) [domain name]->[Configuration][General]->[Advanced]
[X] Platform MBean Server Enabled
[X] Platform MBean Server Used

b) [domain name]->[Security][General]
[X] Anonymous Admin Lookup Enabled




make sure each server listens on a different jmx port:
vi /opt/oracle/domains/osbpl1do/bin/setDomainEnv.sh

if [ "${SERVER_NAME}" = "osbpl1ms1" ] ; then
JAVA_OPTIONS="${JAVA_OPTIONS} -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8888 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djavax.management.builder.initial=weblogic.management.jmx.mbeanserver.WLSMBeanServerBuilder"
fi


if [ "${SERVER_NAME}" = "osbpl1as" ] ; then
JAVA_OPTIONS="${JAVA_OPTIONS} -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8889 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djavax.management.builder.initial=weblogic.management.jmx.mbeanserver.WLSMBeanServerBuilder"
fi



restart your servers

To monitor a DataSource Active Connections:

vi myds.json:

{
  "servers" : [ {
    "port" : "25006",
    "host" : "myhost.acme.com",
    "queries" : [ {
      "outputWriters" : [ {
        "@class" : "com.googlecode.jmxtrans.model.output.StdOutWriter",
        "settings" : {
        }
      } ],
      "obj" : "com.bea:ServerRuntime=acme-server-1,Name=acme-import.PickupPointDS,Type=JDBCDataSourceRuntime",
      "attr" : [ "ActiveConnectionsCurrentCount" ]
    }, {
      "outputWriters" : [ {
        "@class" : "com.googlecode.jmxtrans.model.output.StdOutWriter",
        "settings" : {
        }
      } ],
      "obj" : "java.lang:name=CMS Old Gen,type=MemoryPool",
      "attr" : [ "Usage" ]
    }, {
      "outputWriters" : [ {
        "@class" : "com.googlecode.jmxtrans.model.output.StdOutWriter",
        "settings" : {
        }
      } ],
      "obj" : "java.lang:name=ConcurrentMarkSweep,type=GarbageCollector",
      "attr" : [ "LastGcInfo" ]
    } ],
    "numQueryThreads" : 2
  } ]
}



./jmxtrans.sh start myds.json

you should get this

Result [attributeName=ActiveConnectionsCurrentCount, className=weblogic.jdbc.common.internal.DataSourceRuntimeMBeanImpl, typeName=Name=acme-import.PickupPointDS,ServerRuntime=acme-server-1,Type=JDBCDataSourceRuntime, values={ActiveConnectionsCurrentCount=0}, epoch=1385119401592]

To find the ObjectName (like: com.bea:ServerRuntime=acme-server-1,Name=acme-import.PickupPointDS,Type=JDBCDataSourceRuntime ) you connect to the Managed Server with WLST, serverRuntime(), then you cd to the MBean and you do "cmo", this will tell you the ObjectName. The attribute can be discovered wish "ls".

Thursday, November 21, 2013

Exception in HttpInboundMessageContext.close: java.net.SocketException: Socket closed

Apparently under VERY heavy load we get this error in a HTTP Business Service... still under investigation.

It's not using a nio muxer, so I don't this that the Patch 9552622 described in java.io.IOException: Broken Pipe Seen Frequently in WebLogic Server Logs (Doc ID 1476825.1) really applies...


####<Nov 20, 2013 9:10:28 PM CET> <Error> <WliSbTransports> <myhost> <osbpr1ms1> <[ACTIVE] ExecuteThread: '100' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <4cea82998b9a2c15:7ce38336:1427138d527:-8000-00000000000af294> <1384978228423> <BEA-381304> <Exception in HttpInboundMessageContext.close: java.net.SocketException: Socket closed
java.net.SocketException: Socket closed
        at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:99)
        at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
        at weblogic.servlet.internal.ChunkOutput.writeChunkTransfer(ChunkOutput.java:568)
        at weblogic.servlet.internal.ChunkOutput.writeChunks(ChunkOutput.java:539)
        at weblogic.servlet.internal.ChunkOutput.flush(ChunkOutput.java:427)
        at weblogic.servlet.internal.CharsetChunkOutput.flush(CharsetChunkOutput.java:298)
        at weblogic.servlet.internal.ChunkOutput$2.checkForFlush(ChunkOutput.java:648)
        at weblogic.servlet.internal.CharsetChunkOutput.write(CharsetChunkOutput.java:200)
        at weblogic.servlet.internal.ChunkOutputWrapper.write(ChunkOutputWrapper.java:148)
        at weblogic.servlet.internal.ServletOutputStreamImpl.write(ServletOutputStreamImpl.java:148)
        at org.apache.xmlbeans.impl.store.Cursor._save(Cursor.java:590)
        at org.apache.xmlbeans.impl.store.Cursor.save(Cursor.java:2537)
        at org.apache.xmlbeans.impl.values.XmlObjectBase.save(XmlObjectBase.java:223)
        at com.bea.wli.sb.sources.XmlObjectSource.writeTo(XmlObjectSource.java:92)
        at com.bea.wli.sb.sources.OutboundXOPSource.writeTo(OutboundXOPSource.java:116)
        at com.bea.wli.sb.transports.http.HttpInboundMessageContext.close(HttpInboundMessageContext.java:264)
        at sun.reflect.GeneratedMethodAccessor882.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.bea.wli.sb.transports.Util$4.invoke(Util.java:351)
        at $Proxy165.close(Unknown Source)
        at com.bea.wli.sb.pipeline.MessageProcessor.finishProcessing(MessageProcessor.java:398)
        at com.bea.wli.sb.pipeline.RouterCallback.onReceiveResponse(RouterCallback.java:108)
        at com.bea.wli.sb.pipeline.RouterCallback.run(RouterCallback.java:183)
        at weblogic.work.ContextWrap.run(ContextWrap.java:41)
        at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)






Wednesday, November 20, 2013

Tuesday, November 19, 2013

whoami vs who am i

ok this is like Linux 101:
[root@osb-vagrant ~]# who am i
root     pts/1        2013-11-19 11:01 (10.0.2.2)
[root@osb-vagrant ~]# whoami
root
[root@osb-vagrant ~]# sudo -u soa whoami
soa
[root@osb-vagrant ~]# sudo -u soa who am i
root     pts/1        2013-11-19 11:01 (10.0.2.2)


So if you allow some user to sudo a command, and you want to log who that user is, you should use "who am i" and not "whoami".

Monday, November 18, 2013

Maven hell as usual: No connector available ...

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project AcmeScripts: Failed to deploy artifacts/metadata: No connector available to access repository acme-repository (${acme.deploy.url}) of type default using the available factories WagonRepositoryConnectorFactory -> [Help 1]
Never seen this wagon anywhere.
In reality the issue was that in my pom.xml I had:
<version>1.0</version>
instead of
<version>1.0-SNAPSHOT</version>


Maven is an incredible piece of shit and I am more and more persuaded of it every time I use it.




Installing WebLogic: no space left on device

if you run the generic installer, be aware that it will unzip a load of stuff in the /tmp directory.
You might get a "no space left on device".
Run "df -m" to check how much space you have on /tmp... I guess it should be some 1.5 G at least.

If you can't increase /tmp, the workaround is to specify a tmpdir:

java -Djava.io.tmpdir=/vagrant -jar /opt/oracle/software/wls1035_generic.jar -mode=silent -silent_xml=/opt/oracle/bin/software/silent_${SOA_USER}.xml



Sunday, November 17, 2013

WLST reading a property file

thepropertyfile is a regular property file:
bla=value1
mumble=value2=3

This function handles also the case where a value contains a = sign


def getProperties(thepropertyfile):
    properties = dict()
    for line in open(thepropertyfile):
        strippedline = line.strip()
        if "=" in strippedline:
            key,value = line.strip().split('=', 1)
            properties[key] = value
    return properties


to get the value, do properties.get('bla')


Friday, November 15, 2013

Thread Deadlock on OSB today

Strange, I have never seen this before... maybe it's because 2 people with the same userid were using the console at the same time.



***************************************************************************************
<Nov 15, 2013 12:30:33 PM CET> <Critical> <WebLogicServer> <BEA-000394> <

DEADLOCK DETECTED:
==================

[deadlocked thread] [ACTIVE] ExecuteThread: '4' for queue: 'weblogic.kernel.Default (self-tuning)':
--------------------------------------------------------------------------------------------------
Thread '[ACTIVE] ExecuteThread: '4' for queue: 'weblogic.kernel.Default (self-tuning)'' is waiting to acquire lock 'com.bea.wli.config.component.impl.ReferenceMap@4d86f1a3' that is held by thread '[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)''

Stack trace:
------------
        com.bea.wli.config.component.impl.ReferenceMap.getAncestorsOrDescendents(ReferenceMap.java:820)
        com.bea.wli.sb.transports.TransportDependencyUtils.computeExternalRefs(TransportDependencyUtils.java:97)
        com.bea.wli.sb.transports.TransportDependencyUtils.completeResourcesDependencies(TransportDependencyUtils.java:409)
        com.bea.wli.sb.transports.ResourceLifecycleListenerImpl.changesCommitted(ResourceLifecycleListenerImpl.java:158)
        com.bea.wli.sb.transports.TransportManagerImpl.changesCommitted(TransportManagerImpl.java:1205)
        com.bea.wli.sb.service.ServiceChangeListener.changesCommitted(ServiceChangeListener.java:146)
        com.bea.wli.config.impl.ResourceListenerNotifier.afterEnd(ResourceListenerNotifier.java:120)
        com.bea.wli.config.transaction.TransactionListenerWrapper.afterEnd(TransactionListenerWrapper.java:90)
        com.bea.wli.config.transaction.TransactionManager.notifyAfterEnd(TransactionManager.java:1154)
        com.bea.wli.config.transaction.TransactionManager.commit(TransactionManager.java:1519)
        com.bea.wli.config.transaction.TransactionManager._endTransaction(TransactionManager.java:842)
        com.bea.wli.config.transaction.TransactionManager.endTransaction(TransactionManager.java:783)
        com.bea.wli.config.deployment.server.ServerDeploymentReceiver$2.run(ServerDeploymentReceiver.java:275)
        weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
        weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
        com.bea.wli.config.deployment.server.ServerDeploymentReceiver.commit(ServerDeploymentReceiver.java:260)
        weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:195)
        weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:13)
        weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:68)
        weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
        weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
        weblogic.work.ExecuteThread.run(ExecuteThread.java:178)

[deadlocked thread] [ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)':
--------------------------------------------------------------------------------------------------
Thread '[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'' is waiting to acquire lock 'com.bea.wli.config.transaction.TransactionManager@56622c18' that is held by thread '[ACTIVE] ExecuteThread: '4' for queue: 'weblogic.kernel.Default (self-tuning)''

Stack trace:
------------
        com.bea.wli.config.transaction.TransactionManager.enlistAsRead(TransactionManager.java:972)
        com.bea.wli.config.transaction.CopyOnWriteTransactionalOwner.getState(CopyOnWriteTransactionalOwner.java:65)
        com.bea.wli.config.transaction.TransactionalSet$1.access(TransactionalSet.java:80)
        com.bea.wli.config.transaction.TransactionalSet$1.access(TransactionalSet.java:78)
        com.bea.wli.config.transaction.CopyOnWriteAccessor.access(CopyOnWriteAccessor.java:50)
        com.bea.wli.config.transaction.CopyOnWriteAccessors$CopyOnWriteIterator.<init>(CopyOnWriteAccessors.java:47)
        com.bea.wli.config.transaction.TransactionalSet$1.<init>(TransactionalSet.java:78)
        com.bea.wli.config.transaction.TransactionalSet.iterator(TransactionalSet.java:78)
        com.bea.wli.config.component.impl.ReferenceMap.getNumDependents(ReferenceMap.java:731)
        com.bea.wli.config.task.impl.GetMetadataTask.getMetadata(GetMetadataTask.java:113)
        com.bea.wli.config.task.impl.GetMetadataTask._execute(GetMetadataTask.java:87)
        com.bea.wli.config.task.impl.GetMetadataTask._execute(GetMetadataTask.java:41)
        com.bea.wli.config.task.impl.SessionedTask$1.execute(SessionedTask.java:233)
        com.bea.wli.config.transaction.TransactionalTask._doExecute(TransactionalTask.java:217)
        com.bea.wli.config.transaction.TransactionalTask._doExecuteWithRetry(TransactionalTask.java:162)
        com.bea.wli.config.transaction.TransactionalTask.doExecute(TransactionalTask.java:142)
        com.bea.wli.config.task.impl.SessionedTask.doExecute(SessionedTask.java:236)
        com.bea.wli.config.task.impl.SessionedTask.doExecute(SessionedTask.java:191)
        com.bea.wli.config.task.impl.GetMetadataTask.getMetadata(GetMetadataTask.java:67)
        com.bea.wli.config.mbeans.Config.getMetadata(Config.java:206)
        com.bea.wli.config.mbeans.Config.getMetadata(Config.java:201)
        sun.reflect.GeneratedMethodAccessor614.invoke(Unknown Source)
        sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        java.lang.reflect.Method.invoke(Method.java:597)
        com.bea.alsb.console.support.ConsoleSideMBeanInvocationHandler.__invoke(ConsoleSideMBeanInvocationHandler.java:113)
        com.bea.alsb.console.support.ConsoleSideMBeanInvocationHandler.invoke(ConsoleSideMBeanInvocationHandler.java:71)
        $Proxy158.getMetadata(Unknown Source)
        com.bea.alsb.console.projects.ProjectsHelper.getFoldersMetadata(ProjectsHelper.java:255)
        com.bea.alsb.console.projects.ProjectsHelper.getSortedFoldersMetadata(ProjectsHelper.java:237)
        jsp_servlet._jsp._projects.__projectstree$1ProjectsTree.getFolders(__projectstree.java:201)
        jsp_servlet._jsp._projects.__projectstree$1ProjectsTree.getFolders(__projectstree.java:217)
        jsp_servlet._jsp._projects.__projectstree$1ProjectsTree.getProjectsTreeNodes(__projectstree.java:188)
        jsp_servlet._jsp._projects.__projectstree._jspService(__projectstree.java:248)
        weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
        weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
        weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
        weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
        weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
        weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
        org.apache.beehive.netui.pageflow.PageFlowPageFilter.continueChainNoWrapper(PageFlowPageFilter.java:455)
        org.apache.beehive.netui.pageflow.PageFlowPageFilter.runPage(PageFlowPageFilter.java:432)
        org.apache.beehive.netui.pageflow.PageFlowPageFilter.doFilter(PageFlowPageFilter.java:284)
        weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
        weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:524)
        weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispatcherImpl.java:444)
        org.apache.beehive.netui.pageflow.scoping.internal.ScopedRequestDispatcher.include(ScopedRequestDispatcher.java:119)
        com.bea.netuix.servlets.controls.content.JspContent.beginRender(JspContent.java:552)
        com.bea.netuix.servlets.controls.content.NetuiContent.beginRender(NetuiContent.java:365)
        com.bea.netuix.nf.ControlLifecycle$7.visit(ControlLifecycle.java:485)
        com.bea.netuix.nf.ControlTreeWalker.walkRecursiveRender(ControlTreeWalker.java:518)
        com.bea.netuix.nf.ControlTreeWalker.walkRecursiveRender(ControlTreeWalker.java:529)
        com.bea.netuix.nf.ControlTreeWalker.walkRecursiveRender(ControlTreeWalker.java:529)
        com.bea.netuix.nf.ControlTreeWalker.walkRecursiveRender(ControlTreeWalker.java:529)
        com.bea.netuix.nf.ControlTreeWalker.walkRecursiveRender(ControlTreeWalker.java:529)
        com.bea.netuix.nf.ControlTreeWalker.walk(ControlTreeWalker.java:220)
        com.bea.netuix.nf.Lifecycle.processLifecycles(Lifecycle.java:395)
        com.bea.netuix.nf.Lifecycle.processLifecycles(Lifecycle.java:361)
        com.bea.netuix.nf.Lifecycle.processLifecycles(Lifecycle.java:352)
        com.bea.netuix.nf.Lifecycle.run(Lifecycle.java:326)
        com.bea.netuix.nf.UIControl.render(UIControl.java:582)
        com.bea.netuix.servlets.controls.PresentationContext.render(PresentationContext.java:486)
        com.bea.netuix.servlets.util.RenderToolkit.renderChild(RenderToolkit.java:146)
        com.bea.netuix.servlets.jsp.taglib.RenderChild.doStartTag(RenderChild.java:62)
        jsp_servlet._framework._skeletons._wliconsole.__flowlayout._jspService(__flowlayout.java:271)
        weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
        weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
        weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
        weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
        weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:183)
        weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:526)
        weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispatcherImpl.java:444)
        com.bea.netuix.servlets.controls.application.laf.JspTools.renderJsp(JspTools.java:130)
        com.bea.netuix.servlets.controls.application.laf.JspControlRenderer.beginRender(JspControlRenderer.java:72)
        com.bea.netuix.servlets.controls.application.laf.PresentationControlRenderer.beginRender(PresentationControlRenderer.java:65)
        com.bea.netuix.nf.ControlLifecycle$7.visit(ControlLifecycle.java:481)
        com.bea.netuix.nf.ControlTreeWalker.walkRecursiveRender(ControlTreeWalker.java:518)
        com.bea.netuix.nf.ControlTreeWalker.walkRecursiveRender(ControlTreeWalker.java:529)
        com.bea.netuix.nf.ControlTreeWalker.walk(ControlTreeWalker.java:220)
        com.bea.netuix.nf.Lifecycle.processLifecycles(Lifecycle.java:395)
        com.bea.netuix.nf.Lifecycle.processLifecycles(Lifecycle.java:361)
        com.bea.netuix.nf.Lifecycle.processLifecycles(Lifecycle.java:352)
        com.bea.netuix.nf.Lifecycle.run(Lifecycle.java:326)
       com.bea.netuix.nf.UIControl.render(UIControl.java:582)
        com.bea.netuix.servlets.controls.PresentationContext.render(PresentationContext.java:486)
        com.bea.netuix.servlets.util.RenderToolkit.renderChild(RenderToolkit.java:146)
        com.bea.netuix.servlets.jsp.taglib.RenderChild.doStartTag(RenderChild.java:62)
        jsp_servlet._framework._skeletons._wliconsole.__gridlayout._jspService(__gridlayout.java:312)
        weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
        weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
        weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
        weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
        weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:183)
        weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:526)
        weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispatcherImpl.java:444)
        com.bea.netuix.servlets.controls.application.laf.JspTools.renderJsp(JspTools.java:130)
        com.bea.netuix.servlets.controls.application.laf.JspControlRenderer.beginRender(JspControlRenderer.java:72)
        com.bea.netuix.servlets.controls.application.laf.PresentationControlRenderer.beginRender(PresentationControlRenderer.java:65)
        com.bea.netuix.nf.ControlLifecycle$7.visit(ControlLifecycle.java:481)
        com.bea.netuix.nf.ControlTreeWalker.walkRecursiveRender(ControlTreeWalker.java:518)
        com.bea.netuix.nf.ControlTreeWalker.walkRecursiveRender(ControlTreeWalker.java:529)
        com.bea.netuix.nf.ControlTreeWalker.walkRecursiveRender(ControlTreeWalker.java:529)
        com.bea.netuix.nf.ControlTreeWalker.walkRecursiveRender(ControlTreeWalker.java:529)
        com.bea.netuix.nf.ControlTreeWalker.walkRecursiveRender(ControlTreeWalker.java:529)
        com.bea.netuix.nf.ControlTreeWalker.walkRecursiveRender(ControlTreeWalker.java:529)
        com.bea.netuix.nf.ControlTreeWalker.walkRecursiveRender(ControlTreeWalker.java:529)
        com.bea.netuix.nf.ControlTreeWalker.walkRecursiveRender(ControlTreeWalker.java:529)
        com.bea.netuix.nf.ControlTreeWalker.walkRecursiveRender(ControlTreeWalker.java:529)
        com.bea.netuix.nf.ControlTreeWalker.walk(ControlTreeWalker.java:220)
        com.bea.netuix.nf.Lifecycle.processLifecycles(Lifecycle.java:395)
        com.bea.netuix.nf.Lifecycle.processLifecycles(Lifecycle.java:361)
        com.bea.netuix.nf.Lifecycle.runOutbound(Lifecycle.java:208)
        com.bea.netuix.nf.Lifecycle.run(Lifecycle.java:162)
        com.bea.netuix.servlets.manager.UIServlet.runLifecycle(UIServlet.java:388)
        com.bea.netuix.servlets.manager.UIServlet.doPost(UIServlet.java:258)
        com.bea.netuix.servlets.manager.UIServlet.doGet(UIServlet.java:211)
        com.bea.netuix.servlets.manager.UIServlet.service(UIServlet.java:196)
        com.bea.netuix.servlets.manager.SingleFileServlet.service(SingleFileServlet.java:251)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        weblogic.servlet.AsyncInitServlet.service(AsyncInitServlet.java:130)
        weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
        weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
        weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
        weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
        weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
        oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111)
        java.security.AccessController.doPrivileged(Native Method)
        oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
        oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413)
        oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94)
        oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:161)
        oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
        weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
        oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:136)
        weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
        weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
        weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
        weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
        weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
        weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
        weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
        weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
        weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
        weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
        weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
        weblogic.work.ExecuteThread.run(ExecuteThread.java:178)

>
<Nov 15, 2013 12:30:34 PM CET> <Critical> <Health> <BEA-310006> <Critical Subsystem core has failed. Setting server state to FAILED.
Reason: Thread deadlock detected>
<Nov 15, 2013 12:30:34 PM CET> <Critical> <WebLogicServer> <BEA-000385> <Server health failed. Reason: health of critical service 'core' failed>




Tuesday, November 12, 2013

Bing, one more reason to hate Microsoft (just in case you didn't have already several millions)

Tonight I carelessly run a "Windows Update install all" and, much with my dismay, I found it installed Bing Desktop, it messed with my desktop background, with my Firefox settings (gmail opened each mail in a new windows) and god knows what else.

I tried to uninstall Bing Desktop and it said another installation was going on (???) ... so I had to restart, uninstall Bing desktop, restart again.... finally all seems ok.

If Microsoft has to use these VIRAL way of promoting their products, to me it seems like those door-to-door salesmen who put a foot across your door to prevent you from shutting the door on their face.

Pathetic.Microsoftic.

Puppet instant weblogic installation module in 30 seconds




define weblogic($user = 'soa') {

  $optpath = '/opt'
  $nmPort = '5556'
  $oracle_home = "${optpath}/oracle"
  $user_home = '/home/'
  $bea_home = "${oracle_home}/fmw11_1_1_5"
  $java_home = "/${optpath}/oracle/java"
  $java_home_target = '/usr/lib/jvm/jre-1.6.0-sun.x86_64/bin/java'
  $software_home = '/opt/oracle/software'

  group { 'soa' :
    ensure => 'present',
  }


  user { 'soa':
    ensure     => 'present',
    gid        => 'soa',
    home       => "/${user_home}/soa",
    password   => 'changeme',
    managehome => true,
  }

 
  # create /home/soa?/.bashrc

  file { "/${user_home}/${user}/.bashrc":
    ensure  => present,
    content => template('weblogic/bashrc.erb'),
    require => User["${user}"],
    owner   => "${user}",
  }


  file { "${optpath}":
    ensure => 'directory',
    owner  => 'root',
    group  => 'root',
    mode   => '0755'
  }

 

  file { ["${software_home}"]:
    ensure  => 'directory',
    owner   => 'soa',
    require => User['soa'],
  }

 

  file { "${java_home}":
    ensure => link,
    target => "${java_home_target}"
  }

 

  file { ["${oracle_home}", "${bea_home}"]:
    ensure  => 'directory',
    owner   => "${user}",
    require => User["${user}"],
  }

 

  file { ["${optpath}/var/", "${optpath}/var/log/", "${optpath}/var/log/weblogic/", "${optpath}/var/log/weblogic/server",
          "${optpath}/var/log/weblogic/nodemanager", "${optpath}/var/log/weblogic/scripts"]:
    ensure  => directory,
    owner   => $user,
    require => User[$user],
  }


  # download WebLogic jars

  file { 'wls1035_generic.jar':
 ensure => present,
 source => 'puppet:///modules/weblogic/wls1035_generic.jar',
        target => "${software_home}/wls1035_generic.jar",
  }

  file { "${software_home}/silent_${user}.xml":
    ensure  => present,
    content => template('weblogic/silent.xml.erb'),
    require => File["${oracle_home}"]
  }


  # execute silent installation
  exec { 'weblo-silent-install':
    command => "java -d64 -jar wls1035_generic.jar -mode=silent -silent_xml=silent_${user}.xml",
    cwd     => "${software_home}",
    path    => '/usr/bin:/bin',
    creates => "${bea_home}/registry.xml",
    require => [Nexus::Download['wls1035_generic.jar'], File["${software_home}/silent_${user}.xml"], ],

  }

}




all you need to do is to provide a silent.xml.erb and a bashrc.erb in the templates folder, plus the wls1035_generic.jar file in the files folder of the same weblogic module.

It might not be elegant but it's really simple and it works.



Calling an Oracle Stored Procedure in Java or in Python

I needed to schedule the execution of a Stored Procedure from a cron job.... somebody advised me to use a Java class to do that.
It proved to be really cumbersome... I have followed this example and it's working, but it's very verbose and ugly.
Also, in Java there is no built-in support for getopt style of reading CLI parameters, and using the gnu getopt library seemed overkill to me.
So at the end I will keep using good old zxJDBC from a Python (WLST) script, which supports stored procedures in a VERY simple way: http://www.jython.org/archive/21/docs/zxjdbc.html
db = zxJDBC.connect(...)
c = db.cursor()
params = [None]
c.callproc("funcout", params)

The only disturbing thing is that the startup time for WLST is a bit long, much longer than for a JVM.... but who cares, really, for a job who has to be called once every 10 minutes...


Friday, November 8, 2013

tar gzip exclude folder

Rule n.1:

never run tar inside the same folder you are tarring: tar will include the tar-file that it's creating... CRAZY!

Rule n. 2:

--exclude works only if it's the first parameter after tar... IN SOME versions of tar ONLY.... CRAZY!
in my version it has to come last.
cd /opt/oracle/backups
tar cvzf osbpr1dobackup11Nov2013_108.tar.gz /opt/oracle/domains/osbpr1do/ --exclude="shared/store/jms"


Rule n. 3:

if the exclude folder ends in /, tar will ignore it without warning.... CRAZY!

Rule n. 4:

The exclude parameter shoule be relative to the -C path:

this is good:

tar cvzf /opt/oracle/backups/deleteme.tar.gz -C /opt/oracle/bin/ . --exclude="src"

this is bad:

tar cvzf /opt/oracle/backups/deleteme.tar.gz -C /opt/oracle/bin/ . --exclude="/opt/oracle/bin/src"

That's why I never use tar but rather jar.

Thursday, November 7, 2013

Book: Anatomy of Fascism, by Paxton



Those soul who have been mesmerized by the likes of Orwell's "1984" or Huxley's "Brave New World", will appreciate the unrelenting rationalism by which Paxton dissect the phenomenon of Fascism, delving deep in the social and financial root causes of Europe's plunge into dictatorship.

While the World is plunging into a global form of Fiscal Fascism, where Corporations replace States and exert a totalitarian control on their subjects - with the ultimate goal of sucking all their riches - it helps to indulge in a retrospective analysis which entitles us to call these modern times a modern form of Fascism.



Sunday, November 3, 2013

bash scripts organized with rerun

A small "rerun tutorial" or "getting started with rerun".
Rerun wiki: https://github.com/rerun/rerun/wiki

Download the rpm here

#remember to do export http_proxy=http://myuser:mypw@proxy.acme.com:8080

wget http://repository-stagrlee.forge.cloudbees.com/release/rpms/rerun/rerun-1.0.2-1.fc17.noarch.rpm
rpm -i rerun-1.0.2-1.fc17.noarch.rpm
rerun
Available modules in "/usr/lib/rerun/modules":
stubbs: "Simple rerun module builder" - 1.0.2


then I download https://github.com/downloads/rerun-modules/rerun-modules/rerun-modules-repo-1.0-21.noarch.rpm, copy it locally (wget doesn't work with https on github, no clue...)
and I do:

rpm -i rerun-modules-repo-1.0-21.noarch.rpm

this one didn't work for me (connectivity problems) but it's not essential:
yum -y --disablerepo '*' --enablerepo 'rerun-modules' install '*'


I create my first module

rerun stubbs: add-module
Module name:
pippo
Module description:
my first rerun
Created module structure: /usr/lib/rerun/modules/pippo.


If you look in /usr/lib/rerun/modules/pippo, there is a lib folder - containing an empty functions.sh - and a command folder.

rerun stubbs:add-command
Module:
1) pippo
2) stubbs
#? 1
You picked module pippo (1)
Command:
hello
Description:
say hello
Wrote command script: /usr/lib/rerun/modules/pippo/commands/hello/script
Wrote test script: /usr/lib/rerun/modules/pippo/tests/hello-1-test.sh

then I add an option to the command:
rerun stubbs:add-option

Module:
1) pippo
2) stubbs
#? 1
You picked module pippo (1)
Command:
1) hello
#? 1
You picked command hello (1)
Option:
name
Description:
the person to greet
Required:
1) true
2) false
#? 1
Export:
1) true
2) false
#? 1
Default:
Pierre
Wrote option metadata: /usr/lib/rerun/modules/pippo/options/name/metadata
Updated command metadata:  /usr/lib/rerun/modules/pippo/commands/hello/metadata
Updated command script header: /usr/lib/rerun/modules/pippo/commands/hello/script



vi /usr/lib/rerun/modules/pippo/commands/hello/script
and after this text:
# - - -
# Put the command implementation here.
# - - -

I enter this: echo name is $NAME

I run it:

rerun pippo:hello --name Luigi
name is Luigi

and rerun it:

rerun pippo:hello
name is Pierre

Ok at least we have proven that it can can be made to work...

Saturday, November 2, 2013

git clone failing with Failed connect to github.com:443

On my RHEL box I tried:
git clone https://github.com/graphite-project/graphite-web.git
Initialized empty Git repository in /home/vagrant/graphite-web/.git/
and it was hanging and finally giving HTTP timeout error.
I tried then
export http_proxy=http://myuser:mypassword@myproxy:8080
and again
git clone https://github.com/graphite-project/graphite-web.git
Initialized empty Git repository in /home/vagrant/graphite-web/.git/
error: Failed connect to github.com:443; Operation now in progress while accessing https://github.com/graphite-project/graphite-web.git/info/refs

fatal: HTTP request failed

finally I did:
git config --global http.proxy http://myuser:mypassword@myproxy:8080
git clone https://github.com/graphite-project/graphite-web.git and I got the magic
Initialized empty Git repository in /home/vagrant/graphite-web/.git/
remote: Counting objects: 13933, done.
remote: Compressing objects: 100% (5434/5434), done.
remote: Total 13933 (delta 9025), reused 13065 (delta 8316)
Receiving objects: 100% (13933/13933), 17.15 MiB | 527 KiB/s, done.
Resolving deltas: 100% (9025/9025), done.


If you expected such a widely used product like git to give you some hint on how to troubleshoot such a common issue, you are expecting in vain, git is for geeks and geeks are not user friendly.



OSB: WLST to enable monitoring on Proxy Services

If there is something boring is having to manually enable/disable monitoring at Pipeline/STage/Action level on Proxy/Business services, with same or different aggregation interval.
Unfortunately OSB configuration API is not very friendly. ProxyServiceConfigurationMBean inherits the method enableMonitoring from its parent class CommonServiceConfigurationMBean.
Unfortunately in the method signature there is no mention of the extra parameters : level and aggregation period.
Here is the code:
#There is a change to do to be able to run this WLST script:
#vi /opt/oracle/fmw11_1_1_5/osb/common/bin/wlst.sh
#change this:
#export CLASSPATH
#into this:
#CLASSPATH=/opt/oracle/fmw11_1_1_5/osb/lib/sb-kernel-api.jar:/opt/oracle/fmw11_1_1_5/osb/lib/sb-kernel-impl.jar:/opt/oracle/fmw11_1_1_5/osb/modules/com.bea.common.configfwk_1.5.0.0.jar:$CLASSPATH
#export CLASSPATH


import javax.management
import java.util
import javax.management.remote
import javax.naming
import weblogic.management.mbeanservers.domainruntime
import com.bea.wli.sb.management.configuration

from java.util import Hashtable
from java.util import HashSet
from javax.management.remote import JMXServiceURL
from weblogic.management.mbeanservers.domainruntime import DomainRuntimeServiceMBean
from javax.naming import Context
from javax.management.remote import JMXConnectorFactory
from javax.management import ObjectName
from com.bea.wli.sb.management.configuration import SessionManagementMBean
from com.bea.wli.sb.management.configuration import ALSBConfigurationMBean
from com.bea.wli.sb.management.configuration import CommonServiceConfigurationMBean
import weblogic.management.jmx.MBeanServerInvocationHandler
from com.bea.wli.config import Ref

from com.bea.wli.config.env import EnvValueQuery
from com.bea.wli.config.env import QualifiedEnvValue
from com.bea.wli.config.resource import DependencyQuery
from com.bea.wli.sb.management.query import ProxyServiceQuery
from com.bea.wli.sb.management.query import BusinessServiceQuery

from com.bea.wli.sb.util import EnvValueTypes
from java.util import Collection
from java.util import Collections


def setMonitoringAllProjectsAndServices(isEnabled):
    refs = configMBean.getRefs(Ref.DOMAIN)
    refsList = ArrayList()
    refsList.addAll(refs)
    
    for ref in refsList :
        if ref.getTypeId() == "ProxyService" or ref.getTypeId() == "BusinessService" :
            if ref.getTypeId() == "ProxyService" :
                isPS = "1"
            else:
                isPS =  "0"
            if isEnabled:
                print "enabling monitoring for ", ref.getFullName()
                proxyServiceConfigurationMBean.enableMonitoring(ref)
            else:
                print "disabling monitoring for ", ref.getFullName()
                proxyServiceConfigurationMBean.disableMonitoring(ref)



sessionName = "Session to enable or disable monitoring"
hostname='myhost.acme.com'
port=9001
username='Pierluigi'
password='pippo'
serviceURL=JMXServiceURL("t3", hostname, port, "/jndi/" + DomainRuntimeServiceMBean.MBEANSERVER_JNDI_NAME)
h=Hashtable()
h.put(Context.SECURITY_PRINCIPAL, username)
h.put(Context.SECURITY_CREDENTIALS, password)
h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, "weblogic.management.remote")

conn = JMXConnectorFactory.connect(serviceURL, h)

mbconn = conn.getMBeanServerConnection()

sm = JMX.newMBeanProxy(mbconn, ObjectName.getInstance(SessionManagementMBean.OBJECT_NAME), SessionManagementMBean)

sm.createSession(sessionName)

configMBean = JMX.newMBeanProxy(mbconn, ObjectName.getInstance("com.bea:Name=" + ALSBConfigurationMBean.NAME + "." + sessionName + ",Type=" + ALSBConfigurationMBean.TYPE), ALSBConfigurationMBean)

domainService = weblogic.management.jmx.MBeanServerInvocationHandler.newProxyInstance(mbconn, ObjectName(DomainRuntimeServiceMBean.OBJECT_NAME), DomainRuntimeServiceMBean, false)

proxyServiceConfigurationMBean = domainService.findService(String("ProxyServiceConfiguration.").concat(sessionName),'com.bea.wli.sb.management.configuration.ProxyServiceConfigurationMBean', None)

setMonitoringAllProjectsAndServices(true)



sm.activateSession(sessionName, "Complete enable/disable service monitoring")
conn.close()




yum fails installing git on RHEL: There was an error communicating with RHN

yum install git-core
Loaded plugins: product-id, rhnplugin, security
There was an error communicating with RHN.
RHN Satellite or RHN Classic support will be disabled.
Error communicating with server. The message was:
Name or service not known
Setting up Install Process
No package git-core available.
Error: Nothing to do
First I check in cat /etc/yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=3

#  This is the default, if you make this bigger yum won't see if the metadata
# is newer on the remote and so you'll "gain" the bandwidth of not having to
# download the new metadata and "pay" for it by yum not having correct
# information.
#  It is esp. important, to have correct metadata, for distributions like
# Fedora which don't keep old packages around. If you don't like this checking
# interupting your command line usage, it's much better to have something
# manually check the metadata once an hour (yum-updatesd will do this).
# metadata_expire=90m

# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d


and nothing seems wrong.
Then I check in
cat /etc/sysconfig/rhn/up2date

# Automatically generated Red Hat Update Agent config file, do not edit.
# Format: 1.0
tmpDir[comment]=Use this Directory to place the temporary transport files
tmpDir=/tmp

disallowConfChanges[comment]=Config options that can not be overwritten by a config update action
disallowConfChanges=noReboot;sslCACert;useNoSSLForPackages;noSSLServerURL;serverURL;disallowConfChanges

skipNetwork[comment]=Skips network information in hardware profile sync during registration.
skipNetwork=0

stagingContent[comment]=Retrieve content of future actions in advance
stagingContent=1

networkRetries[comment]=Number of attempts to make at network connections before giving up
networkRetries=1

hostedWhitelist[comment]=RHN Hosted URL's
hostedWhitelist=

enableProxy[comment]=Use a HTTP Proxy
enableProxy=0

writeChangesToLog[comment]=Log to /var/log/up2date which packages has been added and removed
writeChangesToLog=0

serverURL[comment]=Remote server URL (use FQDN)
serverURL=http://pluto.pippo.com/XMLRPC

proxyPassword[comment]=The password to use for an authenticated proxy
proxyPassword=

stagingContentWindow[comment]=How much forward we should look for future actions. In hours.
stagingContentWindow=24

proxyUser[comment]=The username for an authenticated proxy
proxyUser=

versionOverride[comment]=Override the automatically determined system version
versionOverride=

sslCACert[comment]=The CA cert used to verify the ssl server
sslCACert=/usr/share/rhn/RHNS-CA-CERT

retrieveOnly[comment]=Retrieve packages only
retrieveOnly=0

debug[comment]=Whether or not debugging is enabled
debug=0

httpProxy[comment]=HTTP proxy in host:port format, e.g. squid.redhat.com:3128
httpProxy=

useNoSSLForPackages[comment]=Use the noSSLServerURL for package, package list, and header fetching (disable Akamai)
useNoSSLForPackages=0

systemIdPath[comment]=Location of system id
systemIdPath=/etc/sysconfig/rhn/systemid

enableProxyAuth[comment]=To use an authenticated proxy or not
enableProxyAuth=0

noReboot[comment]=Disable the reboot actions
noReboot=0

The "serverURL=http://pluto.pippo.com/XMLRPC" looks suspicious, since I am not in the pippo.com network...there must be some proxy issue here... but enableProxy is 0!!!

I find some light here. But they don't say what the "default Red Hat Network URL" is... bloody hell...

If I comment out the serverURL I get:

yum install git-core
Loaded plugins: product-id, rhnplugin, security
There was an error communicating with RHN.
RHN Satellite or RHN Classic support will be disabled.

Error Message:
        Please run rhn_register as root on this client
Error Class Code: 9
Error Class Info: Invalid System Credentials.
Explanation:
     An error has occurred while processing your request. If this problem
     persists please enter a bug report at bugzilla.redhat.com.
     If you choose to submit the bug report, please be sure to include
     details of what you were trying to do when this error occurred and
     details on how to reproduce this problem.



Ok it looks like I need some good RH training...



JMXTrans and Graphite: getting started

You can achieve very decent monitoring of a Java application - including the JVM itself - with jmxtrans and graphite .

No more horrible hand-crafted tool to extract and chart JMS data.

A TRANS in Italian is a transexual, typically Brazilian - more knows as VIADOS - so hearing JMXTrans always puts me in a good mood because Italians like to make jokes about sex.

OK, let's be serious.
First read the excellent jmxtrans Wiki here.
As suggested by jmstrans site, I listened to the presentation by Coda Hale but frankly it didn't say much new, he speaks well but not very informative

Getting started:
download the tar.gz here

tar xvzf jmxtrans-242.tar.gz
cd jmxtrans-242/rpm
.... mmm when I run build.sh it asks me a release and version?????


I will download a rpm from here (instructions on the site are incomplete... not good...)

rpm -i jmxtrans-20121016.145842.6a28c97fbb-0.noarch.rpm

I verify the installation parameters:
less /etc/sysconfig/jmxtrans

# configuration file for package jmxtrans
export JAR_FILE="/usr/share/jmxtrans/jmxtrans-all.jar"
export LOG_DIR="/var/log/jmxtrans"
export SECONDS_BETWEEN_RUNS=60
export JSON_DIR="/var/lib/jmxtrans"
export HEAP_SIZE=512
export NEW_SIZE=64
export CPU_CORES=2
export NEW_RATIO=8
export LOG_LEVEL=debug


cd /usr/share/jmxtrans
./jmxtrans.sh
Usage: ./jmxtrans.sh {start|stop|restart|status} [filename.json]


I look into an example.json
{
  "servers" : [ {
    "port" : "1099",
    "host" : "w2",
    "queries" : [ {
      "outputWriters" : [ {
        "@class" : "com.googlecode.jmxtrans.model.output.StdOutWriter",
        "settings" : {
        }
      } ],
      "obj" : "java.lang:type=Memory",
      "attr" : [ "HeapMemoryUsage", "NonHeapMemoryUsage" ]
    }, {
      "outputWriters" : [ {
        "@class" : "com.googlecode.jmxtrans.model.output.StdOutWriter",
        "settings" : {
        }
      } ],
      "obj" : "java.lang:name=CMS Old Gen,type=MemoryPool",
      "attr" : [ "Usage" ]
    }, {
      "outputWriters" : [ {
        "@class" : "com.googlecode.jmxtrans.model.output.StdOutWriter",
        "settings" : {
        }
      } ],
      "obj" : "java.lang:name=ConcurrentMarkSweep,type=GarbageCollector",
      "attr" : [ "LastGcInfo" ]
    } ],
    "numQueryThreads" : 2
  } ]
}

(I still need to decide if I hate more JSON or XML... they both hurt the eye...)

I write a sample Java class to monitor:
vi Sample.java
public class Sample {
        public static void main(String[] args) {
            try {
                Thread.sleep(100000000);
            }
            catch (Exception e) {};
        }
}


javac Sample.java
java -Dcom.sun.management.jmxremote.port=1105 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false Sample

cp example.json sample.json
I edit port number and host to match 1105 and my localhost

./jmxtrans.sh start sample.json

this runs in background :
ps -ef | grep jmxtrans
root 2240 1 6 07:47 pts/1 00:00:15 /usr/bin/java -server -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Djmxtrans.log.level=debug -Djmxtrans.log.dir=. -Xms512M -Xmx512M -XX:+UseConcMarkSweepGC -XX:NewRatio=8 -XX:NewSize=64m -XX:MaxNewSize=64m -XX:MaxTenuringThreshold=16 -XX:GCTimeRatio=9 -XX:PermSize=384m -XX:MaxPermSize=384m -XX:+UseTLAB -XX:CMSInitiatingOccupancyFraction=85 -XX:+CMSIncrementalMode -XX:+CMSIncrementalPacing -XX:ParallelGCThreads=1 -Dsun.rmi.dgc.server.gcInterval=28800000 -Dsun.rmi.dgc.client.gcInterval=28800000 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.port=2101 -jar jmxtrans-all.jar -e -f sample.json -s 60


and if I do
tail -f jmxtrans.log
I get a line per minute:
[02 Nov 2013 07:47:22] [main] 0 INFO (com.googlecode.jmxtrans.JmxTransformer:134) - Starting Jmxtrans on : sample.json
[02 Nov 2013 07:47:23] [main] 1125 DEBUG (com.googlecode.jmxtrans.JmxTransformer:354) - Loaded file: /usr/share/jmxtrans/sample.json
[02 Nov 2013 07:47:23] [main] 1154 DEBUG (com.googlecode.jmxtrans.JmxTransformer:429) - Scheduled job: osb-vagrant.acme.com:1105-1383374843215-0158449004 for server: Server [host=osb-vagrant.acme.com, port=1105, url=null, cronExpression=null, numQueryThreads=2]
[02 Nov 2013 07:47:23] [ServerScheduler_Worker-1] 1167 DEBUG (com.googlecode.jmxtrans.jobs.ServerJob:31) - +++++ Started server job: Server [host=osb-vagrant.acme.com, port=1105, url=null, cronExpression=null, numQueryThreads=2]
[02 Nov 2013 07:47:23] [ServerScheduler_Worker-1] 1690 DEBUG (com.googlecode.jmxtrans.util.JmxUtils:102) - ----- Creating 3 query threads
[02 Nov 2013 07:47:24] [pool-1-thread-1] 1940 DEBUG (com.googlecode.jmxtrans.util.JmxUtils:195) - Executing queryName: java.lang:type=Memory from query: Query [obj=java.lang:type=Memory, resultAlias=null, attr=[HeapMemoryUsage, NonHeapMemoryUsage]]
[02 Nov 2013 07:47:24] [pool-1-thread-1] 2002 DEBUG (com.googlecode.jmxtrans.util.JmxUtils:209) - Finished running outputWriters for query: Query [obj=java.lang:type=Memory, resultAlias=null, attr=[HeapMemoryUsage, NonHeapMemoryUsage]]
[02 Nov 2013 07:47:24] [ServerScheduler_Worker-1] 2006 DEBUG (com.googlecode.jmxtrans.jobs.ServerJob:50) - +++++ Finished server job: Server [host=osb-vagrant.acme.com, port=1105, url=service:jmx:rmi:///jndi/rmi://osb-vagrant.acme.com:1105/jmxrmi, cronExpression=null, numQueryThreads=2]

Next step: install grafite and plot these metrics....