Saturday, February 23, 2013

JSP download file



<%

 response.setContentType("application/xml"); 
 response.setHeader("Content-Disposition", "attachment;filename=myxmlfile.xml"); 

 File file = new File("myxmlfile.xml");
 FileInputStream fileIn = new FileInputStream(file);
 ServletOutputStream outstream = response.getOutputStream();
  
 byte[] outputByte = new byte[4096];
 //copy binary contect to output stream
 int byteRead;
 while( ( byteRead = fileIn.read(outputByte, 0, 4096)) != -1)
 {
  outstream.write(outputByte, 0, byteRead);
 }
 fileIn.close();
 outstream.flush();
 outstream.close();


 %>        



For binary files, use:
response.setContentType("application/x-download");
rather than
response.setContentType("application/xml");


Firefox hanging? Try disabling Flash plugin...

I was literally agonizing, every page making access to googleplus or other "ad" related sites was hanging forever, freezing the entire Firefox (what a silly threading model!!!! Do they retrieve data in the same UI thread???? Bad, bad, bad.....).

Anyway after disabling ALL plugins and extension, and enabling them one by one, I found out that the Flash plugin was the culprit. Now it's like flying....


Friday, February 22, 2013

Nice little script to recursively export from SVN selected projects

I want to export only projects which have the "trunk" folder inside:

svnusername=thesvnuser
svnpassword=thesvnpassword

repositoryLocation=https://yoursvnserver/yourroots

svn --username ${svnusername} --password ${svnpassword} list ${repositoryLocation} | sed 's,/,,g' > projects.txt

while read line ;
do
 svn --username ${svnusername} --password ${svnpassword} list ${repositoryLocation}/${line}/trunk 2>&1 > /dev/null
    echo "processing ${line}"
 if [ $? -gt 0 ]; then
  echo "project " ${line} " has no trunk"
 else
  svn --username ${svnusername} --password ${svnpassword} export ${repositoryLocation}/${line}/trunk allprojects/${line}
 fi
done < projects.txt



The true story of Israel

I grew up in a very pro-Israel family, my father stuffed my head with the usual Zionist myths:
- Palestine was an unoccupied desert land before the Jews arrived, the Jews created jobs for the Arabs and turned the desert into a garden
- Jews bought all the land they occupy now from the Palestinians, paying a fair price
- all Palestinians are Muslim
- all Jews are direct descendant of former (Roman times) occupants of Palestine, while Palestinians have invaded the land in more recent times
- Arabs are evil and they tried to destroy Israel in 1967 by aggressing Israel without notice, but the heroic Jews prevailed because God was on their side and they were fighting for a just cause
- Jews had been persecuted by Hitler, and they are entitled to a Country (nobody ever explains why they didn't return the the Jews the properties confiscated to them in Europe, rather than confiscating the property of innocent palestinians)
- being anti-Zionist is the same as being antisemitic, which in turn is equivalent to being pro-Nazi
I never questioned those myths, coming from an authority - my father - that I thought unquestionable. Besides, all mainstream info reports more or less the same story.

Digging further into non-mainstream information, I discovered that the truth is DRASTICALLY different. This excellent documentary gives a very detailed account of facts.





PS I am from Jewish descent myself, so please don't call me antisemitic :o)

com.bea.wli.sb.transports.TransportException: The configurations for the proxy service is in flux

com.bea.wli.sb.transports.TransportException: The configurations for the proxy service is in flux

There is a Oracle Doc with ID 974538.1:

The error message will come up when you try to update a proxy service while running a load test on the same proxy service or in a system under load. It is not considered a "best practice" to update proxy service under high load. So to avoid the situation please make sure that there is no dynamic update during the load test or under high load.

BEA-382013

Error: The configurations for the proxy service is in flux.

Description

The processing of the message has failed in OSB runtime due to the fact that the configurations for the proxy service is in flux. This proxy is unable to send an outbound message to service "service" until the configuration stabilizes.

Action

Wait until the configuration of OSB server stabilizes and retry sending the request.



Thursday, February 21, 2013

Situations in the life of a programmer (part 4)

I have been rolling on the floor laughing with this post http://helektron.com/situaciones-en-la-vida-de-un-programador/, so with the kind permission of its author I will publish an English version (thank you google translate).

The whole series is here:
http://www.javamonamour.org/2013/02/situations-in-life-of-programmer-part-1.html
http://www.javamonamour.org/2013/02/situations-in-life-of-programmes-part-2.html
http://www.javamonamour.org/2013/02/situations-in-life-of-programmes-part-3.html
http://www.javamonamour.org/2013/02/situations-in-life-of-programmer-part-4.html


When that code that I have not tested in development works perfect in production:


When the commercials announce to the developers what they have sold to the customer


When I apply a new CSS for the first time


When the sysadmin finally gives us access to root:



When I launch my script for the first time after several hours of development:


When I go on the weekend while everyone is still trying to fix bugs:


When the boss is looking for someone to correct a difficult and urgent bug :



When the application goes into beta and the first bug reports arrive:



When the new hire proposes to add a new feature to the project:



When asked to lend a hand on a Friday afternoon:



When the boss announces a bonus if the project is completed before the deadline:



When I realize that I have been blocked for two hours for having forgotten a semicolon:




When the project manager jumps on my screen by storm:



When the client tries to click on the wireframes:



When what was running on Friday no longer works on Monday:



When the customer wants to change specifications 2 days before the go live in production



When I have to do a development without specifications



When I deliver a development of a code that has no comments



When I listen to business trying to sell the project to the customer



When the project manager enters the workroom



When my script finally worked



When a colleague tells me that the test "are for those who can not program":



When I am asked to resume the development of an intern::



When I am told that my program has crashed in production




When a bug goes unnoticed during a presentation


When I am asked to do a redesign


When the customer limits himself to describing the error as "does not work"



When I get to replace the 200 lines of the algorithm by only 10 lines:




Situations in the life of a programmer (part 3)

I have been rolling on the floor laughing with this post http://helektron.com/situaciones-en-la-vida-de-un-programador/, so with the kind permission of its author I will publish an English version (thank you google translate).
The whole series is here:
http://www.javamonamour.org/2013/02/situations-in-life-of-programmer-part-1.html
http://www.javamonamour.org/2013/02/situations-in-life-of-programmes-part-2.html
http://www.javamonamour.org/2013/02/situations-in-life-of-programmes-part-3.html
http://www.javamonamour.org/2013/02/situations-in-life-of-programmer-part-4.html

When I find a solution without searching in google:


When my computer is turned off before having saved all:

When my colleagues propose a coffee break in full development:



When a coworker proposes to make the web pages with Joomla!:



When I realize that the module on which I have worked all week will never be used



When I show the boss that I have finally solved this bug:





Situations in the life of a programmer (part 2)

I have been rolling on the floor laughing with this post http://helektron.com/situaciones-en-la-vida-de-un-programador/, so with the kind permission of its author I will publish an English version (thank you google translate).
The whole series is here:
http://www.javamonamour.org/2013/02/situations-in-life-of-programmer-part-1.html
http://www.javamonamour.org/2013/02/situations-in-life-of-programmes-part-2.html
http://www.javamonamour.org/2013/02/situations-in-life-of-programmes-part-3.html
http://www.javamonamour.org/2013/02/situations-in-life-of-programmer-part-4.html

When the product manager uses developers jargon:


When large refactoring passes all unit tests at once:


When I do a new deployment in production :


When I try to fix a bug at 3 in the morning:


When my regexp returns exactly what expected:





Situations in the life of a programmer (part 1)

I have been rolling on the floor laughing with this post http://helektron.com/situaciones-en-la-vida-de-un-programador/, so with the kind permission of its author I will publish an English version (thank you google translate). The whole series is here:
http://www.javamonamour.org/2013/02/situations-in-life-of-programmer-part-1.html
http://www.javamonamour.org/2013/02/situations-in-life-of-programmes-part-2.html
http://www.javamonamour.org/2013/02/situations-in-life-of-programmes-part-3.html
http://www.javamonamour.org/2013/02/situations-in-life-of-programmer-part-4.html


When a colleague discovered one of my Easter eggs in the project:



When I read a white paper written by the marketing team:


When my web page passes W3C validation :


When the new hire proposes to change the database:


When my SQL query with 17 joins and 23 where clauses returns nothing:


When I have to make a demo for a customer:







Wednesday, February 20, 2013

Typical crontab mistakes for a dummy

3 things have to be born in mind when putting a service in crontab:

- crontab doesn't run .bash_profile, so you should start your script with:
source /home/soa/.bash_profile

- stderr and stdout will vanish, so always redirect both to a file:
/opt/oracle/scripts/mycommand.sh 2>&1 >> /opt/oracle/scripts/mylogfile.log

- at script start, the current directory can be anything, so to be on the safe side start with a cd /opt/oracle/scripts/



OSB: truncating the reporting tables in a PROD environment

One of our services started flooding the reporting db. Deleting records proved to be too slow compared to the production rate, and it would generate too much REDO logs on the Oracle DB.
I had to do this:

- purge the dist_wli.reporting.jmsprovider_error.queue_auto queue to start from a clean position to make sure no reporting messages error out
- stop the deployment JMS Reporting Provider
- disable the FK_WLI_QS_REPORT_DATA constraint
- truncate table WLI_QS_REPORT_DATA;
- truncate table WLI_QS_REPORT_ATTRIBUTE;
- enable the FK_WLI_QS_REPORT_DATA constraint
- restart the deployment JMS Reporting Provider


If you don't suspend JMS Reporting Provider, you get this error while truncating the tables:

SQL Error: ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired 00054. 00000 - "resource busy and acquire with NOWAIT specified"


The DML is here:

ALTER TABLE WLI_QS_REPORT_DATA MODIFY CONSTRAINT FK_WLI_QS_REPORT_DATA DISABLE;

truncate table WLI_QS_REPORT_DATA;

truncate table WLI_QS_REPORT_ATTRIBUTE;

ALTER TABLE WLI_QS_REPORT_DATA MODIFY CONSTRAINT FK_WLI_QS_REPORT_DATA enable;


When trying to disable the FK I got several times:



ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired

but finally it worked.
I tried to detect the SQL holding the lok using




SELECT O.OBJECT_NAME, S.SID, S.SERIAL#, P.SPID, S.PROGRAM,S.USERNAME,
S.MACHINE,S.PORT , S.LOGON_TIME,SQ.SQL_FULLTEXT
FROM V$LOCKED_OBJECT L, DBA_OBJECTS O, V$SESSION S,
V$PROCESS P, V$SQL SQ
WHERE L.OBJECT_ID = O.OBJECT_ID
AND L.SESSION_ID = S.SID AND S.PADDR = P.ADDR
AND S.SQL_ADDRESS = SQ.ADDRESS;
 
but it could not find it.




Monday, February 18, 2013

Bean already exists: "weblogic.j2ee.descriptor.wl.JDBCPropertyBeanImpl JDBCDriverParams/Properties/Properties[user])

I was getting this error while committing changes on a DataSource:


Bean already exists: "weblogic.j2ee.descriptor.wl.JDBCPropertyBeanImpl JDBCDriverParams/Properties
/Properties[user])



Deleting the DataSource didn't help.

I tried editing manually config.xml, and I discovered that there was a swap file for vi to recover. I deleted it:

mv .config.xml.swp config.xml.swpORI

Then I discovered that in the config/jdbc folder there was still a xml file with the preexisting DataSource, although I had deleted it. So I removed it:

rm jdbc/AcmeDataSourceUS-0327-jdbc.xml

At this point I managed to recreate the DataSource.

Wow. What a fight.

Sunday, February 17, 2013

Poor man's Puppet implementation

I have 3 Linux users: soa, soa2 and soa3, and several hosts to manage which to copy files etc.

Simplest thing is to create a common shared folder with NFS or similar.

The alternative is to setup .ssh trust between all machines, and use a centralized place from which to ssh and scp stuff around. This script allows you to loop over all users and machines and perform any command:

getOptHome(){
 local user="$1"
 local path="opt"

 if [ "soa" == "$user"  ]; then
  optpath="opt"
 elif [ "soa2" == "$user" ]; then 
  optpath="opt2"
 elif [ "soa3" == "$user" ]; then 
  optpath="opt3"
 else 
  echo "User must be either soa, soa2 or soa3.  Exiting"
  exit 1
 fi
}

distributionListPPRD="acme103 acme105 acme106 acme112"
distributionListPROD="acme107 acme108 acme110 acme111"
usersList="soa soa2 soa3"

fileToCopy='showWebLogic.sh'

distributionList=$distributionListPPRD

for host in $distributionList
do

 for user in $usersList 
 do
  getOptHome "$user"
  ssh "$user"@"$host" mkdir -p /${optpath}/oracle/usr
  #scp $fileToCopy "$user"@"$host":/${optpath}/oracle/usr
 done

done

 



Saturday, February 16, 2013

How to Configure WebLogic Server to Send a Notification When Its Configuration is Changed [ID 1377733.1]

I have decided to implement this article in the Oracle Knowledge Base: "How to Configure WebLogic Server to Send a Notification When Its Configuration is Changed [ID 1377733.1]"

This reference will be useful http://docs.oracle.com/cd/E21764_01/web.1111/e13714/config_watch_notif.htm

domain -> Configuration -> General -> Advanced settings and set the Configuration Audit Type to "Change Log":

WLST
 
cd('/')
cmo.setConfigurationAuditType('log')


Create a Diagnostic Module, of type "Log Watch"
Log Watch Severity will need to be set to "Info"
cmo.createWLDFSystemResource('ConfigurationAuditModule')

cd('/SystemResources/ConfigurationAuditModule')
cmo.setDescription('')

cd('/WLDFSystemResources/ConfigurationAuditModule/WLDFResource/ConfigurationAuditModule/WatchNotification/ConfigurationAuditModule')
cmo.setLogWatchSeverity('Info')
cmo.createWatch('ConfigurationAuditRule')

cd('/WLDFSystemResources/ConfigurationAuditModule/WLDFResource/ConfigurationAuditModule/WatchNotification/ConfigurationAuditModule/Watches/ConfigurationAuditRule')
cmo.setRuleType('Log')
cmo.setEnabled(true)
cmo.setRuleExpression('(MESSAGE LIKE \'%MODIFIED%\' OR MESSAGE LIKE \'%CREATED%\' OR MESSAGE LIKE \'%REMOVED%\') AND (SUBSYSTEM = \'Configuration Audit\')')
cmo.setAlarmType('None')

activate()



and create a Mail Session

cd('/')
cmo.createMailSession('MailSessionAdmin')

cd('/MailSessions/MailSessionAdmin')
cmo.setJNDIName('MailSessionAdmin')
prop = Properties()
prop.setProperty('mail.smtp.host', 'smtp.acme.com')
cmo.setProperties(prop)

set('Targets',jarray.array([ObjectName('com.bea:Name=osbpl1as,Type=Server'), ObjectName('com.bea:Name=osbpl1cl,Type=Cluster')], ObjectName))



and assign an email notification to our Watch:

cd('/WLDFSystemResources/ConfigurationAuditModule/WLDFResource/ConfigurationAuditModule/WatchNotification/ConfigurationAuditModule')
cmo.createSMTPNotification('EmailAdmin')

cd('/WLDFSystemResources/ConfigurationAuditModule/WLDFResource/ConfigurationAuditModule/WatchNotification/ConfigurationAuditModule/SMTPNotifications/EmailAdmin')
cmo.setEnabled(true)
cmo.setMailSessionJNDIName('MailSessionAdmin')
set('Recipients',jarray.array([String('pierluigi.vernetto@acme.com')], String))
cmo.setSubject(None)
cmo.setBody(None)



and don't forget to assign the email notification to the watch:

cd('/WLDFSystemResources/ConfigurationAuditModule/WLDFResource/ConfigurationAuditModule/WatchNotification/ConfigurationAuditModule/Watches/ConfigurationAuditRule')
set('Notifications',jarray.array([ObjectName('com.bea:Name=EmailAdmin,Type=weblogic.diagnostics.descriptor.WLDFSMTPNotificationBean,Parent=[osbpl1do]/WLDFSystemResources[ConfigurationAuditModule],Path=WLDFResource[ConfigurationAuditModule]/WatchNotification[ConfigurationAuditModule]/SMTPNotifications[EmailAdmin]')], ObjectName))



Remember to target the WLDF module , if you had already the default Module-FMWDFW, you should untarget it.

If all is set up correctly, whey you change the log file size from 10000 to 10001 you should get this email:
WatchTime: Feb 16, 2013 5:44:11 AM CET 
WatchDomainName: osbpl1do 
WatchServerName: osbpl1as 
WatchSeverityLevel: Notice 
WatchName: ConfigurationAuditRule 
WatchRuleType: Log 
WatchRule: (MESSAGE LIKE '%MODIFIED%' OR MESSAGE LIKE '%CREATED%' OR MESSAGE LIKE '%REMOVED%') AND (SUBSYSTEM = 'Configuration Audit') 
WatchData: DATE = Feb 16, 2013 5:44:11 AM CET SERVER = osbpl1as MESSAGE = USER Pierluigi MODIFIED com.bea:Name=osbpl1as,Type=Log,Server=osbpl1as ATTRIBUTE FileMinSize FROM 10000 TO 10001 SUBSYSTEM = Configuration Audit USERID = Pierluigi SEVERITY = Info THREAD = [ACTIVE] ExecuteThread: '3' for queue: 'weblogic.kernel.Default (self-tuning)' MSGID = BEA-159904 MACHINE = hqchnesoa200 TXID =  CONTEXTID = 80c3be353c83ac6e:3a272057:13ccf23ffee:-8000-0000000000002cef TIMESTAMP = 1360989851820  
WatchAlarmType: None 
WatchAlarmResetPeriod: 60000 
SMTPNotificationName: EmailAdmin 



The entire script is here, I had to exclude user WLS Kernel to avoid false positives:


domain='osbp1do'
adminName='osbpl1as'  
clusterName='osbpl1cl'

print "connecting to ", adminURL
connect(adminUserName, adminPassword, adminURL)



print "clusterName, adminName", clusterName, adminName

edit()
startEdit()
cd('/')
cmo.setConfigurationAuditType('log')
theModuleName='ConfigurationAuditModule'

myMbean = getMBean('/WLDFSystemResources/' + theModuleName)
if (myMbean == None):
    cmo.createWLDFSystemResource(theModuleName)
else:
    print "module", theModuleName, "already exists" 
    
cd('/SystemResources/' + theModuleName)
cmo.setDescription('Monitor configuration changes')

cd('/WLDFSystemResources/' + theModuleName + '/WLDFResource/' + theModuleName + '/WatchNotification/' + theModuleName)
cmo.setLogWatchSeverity('Info')

auditRuleName='ConfigurationAuditRule'
myMbean = getMBean('/WLDFSystemResources/' + theModuleName + '/WLDFResource/' + theModuleName + '/WatchNotification/' + theModuleName + '/Watches/' + auditRuleName)
if (myMbean == None):
    cmo.createWatch(auditRuleName)
else:
    print "audit rule", auditRuleName, "already exists"    

cd('/WLDFSystemResources/' + theModuleName + '/WLDFResource/' + theModuleName + '/WatchNotification/' + theModuleName + '/Watches/' + auditRuleName)
cmo.setRuleType('Log')
cmo.setEnabled(true)
cmo.setRuleExpression('(USERID != \'\') AND (MESSAGE LIKE \'%MODIFIED%\' OR MESSAGE LIKE \'%CREATED%\' OR MESSAGE LIKE \'%REMOVED%\') AND (SUBSYSTEM = \'Configuration Audit\')')
cmo.setAlarmType('None')

theMailSessionName='MailSessionAdmin'
cd('/')
myMbean = getMBean('/MailSessions/' + theMailSessionName)
if (myMbean == None):
    cmo.createMailSession(theMailSessionName)
else:
    print "mailSession", theMailSessionName, "already exists"

cd('/MailSessions/' + theMailSessionName)
cmo.setJNDIName(theMailSessionName)
prop = Properties()
prop.setProperty('mail.smtp.host', 'smtp.acme.com')
cmo.setProperties(prop)
set('Targets',jarray.array([ObjectName('com.bea:Name=' + adminName + ',Type=Server'), ObjectName('com.bea:Name=' + clusterName +',Type=Cluster')], ObjectName))


cd('/WLDFSystemResources/' + theModuleName + '/WLDFResource/' + theModuleName + '/WatchNotification/' + theModuleName)

theEmailNotificationName='EmailAdmin'
myMbean = getMBean('/WLDFSystemResources/' + theModuleName + '/WLDFResource/' + theModuleName + '/WatchNotification/' + theModuleName + '/SMTPNotifications/' + theEmailNotificationName)
if (myMbean == None):
    cmo.createSMTPNotification(theEmailNotificationName)
else:
    print "SMTPNotification", theEmailNotificationName, "already exists"    

cd('/WLDFSystemResources/' + theModuleName + '/WLDFResource/' + theModuleName + '/WatchNotification/' + theModuleName + '/SMTPNotifications/' + theEmailNotificationName)
cmo.setEnabled(true)
cmo.setMailSessionJNDIName(theMailSessionName)
set('Recipients',jarray.array([String('pierluigi.vernetto@acme.com')], String))
cmo.setSubject("audit weblogic configuration change domain=" + domain)
cmo.setBody(None)

cd('/SystemResources/' + theModuleName)
set('Targets',jarray.array([ObjectName('com.bea:Name=' + adminName + ',Type=Server'), ObjectName('com.bea:Name=' + clusterName +',Type=Cluster')], ObjectName))


cd('/WLDFSystemResources/' + theModuleName + '/WLDFResource/' + theModuleName + '/WatchNotification/' + theModuleName + '/Watches/' + auditRuleName)
set('Notifications',jarray.array([ObjectName('com.bea:Name=EmailAdmin,Type=weblogic.diagnostics.descriptor.WLDFSMTPNotificationBean,Parent=[' + domain + ']/WLDFSystemResources[' + theModuleName + '],Path=WLDFResource[' + theModuleName + ']/WatchNotification[' + theModuleName + ']/SMTPNotifications[EmailAdmin]')], ObjectName))

save()
validate()
activate()




See also http://www.javamonamour.org/2012/05/weblogic-configuration-audit-type.html

Thursday, February 14, 2013

Tuesday, February 12, 2013

Saga pattern and reservation pattern

Saga pattern http://kellabyte.com/2012/05/30/clarifying-the-saga-pattern/ : each transaction has a compensation - but this doesn't guarantee any integrity

Reservation pattern http://soa.dzone.com/news/httpwwwrgoarchitectscomnblog20 it mimicks a 2-phase commit, by having a reservation message followed by a confirmation message




Monday, February 11, 2013

WebLogic server hanging on startup

This is so typical...

Thread Dump shows:


"[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'" daemon prio=10 tid=0x000000004c6cf800 nid=0x3e47 in Object.wait() [0x00000000426a8000]
   java.lang.Thread.State: WAITING (on object monitor)
 at java.lang.Object.wait(Native Method)
 - waiting on <0x00000007e40ca438> (a com.octetstring.vde.backend.standard.TransactionProcessor)
 at java.lang.Object.wait(Object.java:485)
 at com.octetstring.vde.backend.standard.TransactionProcessor.waitTransactionsCompleted(TransactionProcessor.java:353)
 - locked <0x00000007e40ca438> (a com.octetstring.vde.backend.standard.TransactionProcessor)
 at com.octetstring.vde.backend.standard.BackendStandard.<init>(BackendStandard.java:275)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
 at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
 at com.octetstring.vde.backend.BackendHandler.<init>(BackendHandler.java:248)
 at com.octetstring.vde.backend.BackendHandler.getInstance(BackendHandler.java:344)
 at weblogic.ldap.EmbeddedLDAP.start(EmbeddedLDAP.java:299)
 at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)
 at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
 at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)



Delete the $DOMAIN_HOME/servers/myservername/data/ldap folder and the $DOMAIN_HOME/servers/myservername/security/boot.properties file.

cd $DOMAIN_HOME/bin

./startManagedWeblogic.sh myservername

enter weblogic username and password

If some OSB (ALSB) deployments fail, make sure you remove all configuration files with 0 size from the admin host:

cd $DOMAIN_HOME/config

find . -size -1 -exec ls -l {} \;

find . -size -1 -exec rm {} \;



Sunday, February 10, 2013

Saturday, February 9, 2013

Book review: oracle weblogic server 12 first look

This is a small book (net of introduction and blablabla, it's 100 pages) with a short description of new features available in WebLogic 12. Useful reading, the ebook is really cheap.


 


Topics being dealth with:

Java 7

JEE 6

JAX-RS http://en.wikipedia.org/wiki/Java_API_for_RESTful_Web_Services

oracle traffic director http://www.oracle.com/us/products/middleware/application-server/oracle-traffic-director-ds-1389582.pdf

Virtual Assembly Builder , Oracle Virtual Assembly (OVA)


CDI Context Dependency INjection

EJB Lite

JAX-RS
Bean Validation
JCA
JACC

EAJ packaged in WAR
Portable Global JNDI Names

FastSwap
wlx
Oracle Public Cloud Web Projects

WLS CAT (classloader analysis tool)

JASPIC http://docs.oracle.com/cd/E19226-01/820-7627/girgp/index.html

JDBC Transaction Log Store

Partitioned Distributed Topics http://docs.oracle.com/cd/E17904_01/web.1111/e15493/dist_topic_scenarios.htm#WLMDB10054

JSSE http://en.wikipedia.org/wiki/Java_Secure_Socket_Extension

Oracle Virtual Assembly Builder http://www.oracle.com/us/products/middleware/application-server/virtual-assembly-builder-067878.html

 

Friday, February 8, 2013

SOAPUI MockServices and Groovy Response

Suppose you have a request like this:


<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header/>
   <soapenv:Body>
      <IdentifyCustomer>
         <WebIdentification>
            <Email>vernetto@yahoo.com</Email>
            <Password>ciao</Password>
         </WebIdentification>
      </IdentifyCustomer>
   </soapenv:Body>
</soapenv:Envelope>



and you must return this response whenever the email contains "@yahoo.com":

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header/>
   <soapenv:Body>
      <IdentifyCustomerResponse>
         <!--You have a CHOICE of the next 2 items at this level-->
         <IdentificationSuccessful>
            <MarketID>2</MarketID>
            <CustomerID>123456</CustomerID>
         </IdentificationSuccessful>
      </IdentifyCustomerResponse>
   </soapenv:Body>
</soapenv:Envelope>   


and this response whenever the email contains "@gmail.com":

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header/>
   <soapenv:Body>
      <IdentifyCustomerResponse>
         <IdentificationFailed>
            <ErrorCode>CUSTOMER_NOT_FOUND</ErrorCode>
            <ErrorDescription>we cannot find this customer</ErrorDescription>
         </IdentificationFailed>
      </IdentifyCustomerResponse>
   </soapenv:Body>
</soapenv:Envelope>


You can create a MockService and customize the MockResponse http://www.soapui.org/Getting-Started/mock-services/4-Customizing-a-MockResponse.html

this is the script:


def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def holder = groovyUtils.getXmlHolder( mockRequest.requestContent ) 
def email = holder.getNodeValue("//Email")

if (email.contains("@yahoo.com")) {
 context.setProperty( "myresponse", "<IdentificationSuccessful><MarketID>2</MarketID><CustomerID>123456</CustomerID></IdentificationSuccessful>" )
}
else {
 context.setProperty( "myresponse", "<IdentificationFailed><ErrorCode>CUSTOMER_NOT_FOUND</ErrorCode><ErrorDescription>we cannot find this customer</ErrorDescription></IdentificationFailed>" )
}



and this the Groovy Response


<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header/>
   <soapenv:Body>
      <IdentifyCustomerResponse>
  ${myresponse}
      </IdentifyCustomerResponse>
   </soapenv:Body>
</soapenv:Envelope>


Thursday, February 7, 2013

Management:141190, The commit phase of the configuration update failed with an exception

We had regularly this exception when activatin a WebLogic session with ANY changes. Rebooting the admin fixed the problem.

An error occurred during activation of changes, please see the log for details.
[Management:141190]The commit phase of the configuration update failed with an exception:
3



About the use of Shell Scripts and Java/Python scripts

A former consultant was very fond of shell scripts - probably because they are so cryptic that they give their author a comfortable job security.
Those scripts, being build/deployment scripts, make several calls to Python/WLST scripts and to Java classes. Each call entails starting a JVM, which even on a robust machine takes time, say 5 seconds.
Also, each time you need to pass parameters around, which can quickly become a nightmare.
The overall result is having scripts which are slow, hard to debug and difficult to maintain.
My personal decision is: NEVER AGAIN SHELL SCRIPT. Do all in Python and FORGET SHELLS.

Wednesday, February 6, 2013

Crash Recovery with NodeManager

http://docs.oracle.com/cd/E12839_01/web.1111/e13740/overview.htm

Node Manager and System Crash Recovery

To ensure that Node Manager properly restarts servers after a system crash, you must perform the following:

    Ensure that CrashRecoveryEnabled is set to true.

    The CrashRecoveryEnabled configuration property allows Node Manager to restart servers after a system crash. The property is not enabled by default.
    You should start the Administration Server via Node Manager.
    All managed servers should be started via the Administration Server. You can accomplish this via WLST or the Administration Console.

After the system is restarted, Node Manager checks each managed domain specified in the nodemanager.domains file to determine if there are any server instances that were not cleanly shutdown. This is determined by the presence of any lock files which are created by Node Manager when a WebLogic Server process is created. This lock file contains the process identifier for WebLogic Server startup script. If the lock file exists, but the process ID is not running, Node Manager will attempt to automatically restart the server.

If the process is running, Node Manager performs an additional check to access the management servlet running in the process to verify that the process corresponding to the process ID is a WebLogic Server instance.
Note:  When Node Manager performs a check to access the management servlet, an alert may appear in the server log regarding improper credentials.


When you run startNodeManager.sh you will see "Automatically restarting server process as part of crash recovery"
and then it fails with:
Fatal error in node manager server
java.lang.NullPointerException
        at weblogic.nodemanager.server.ServerManager.getStartCallbacks(ServerManager.java:187)
        at weblogic.nodemanager.server.AbstractServerManager.startServer(AbstractServerManager.java:211)
        at weblogic.nodemanager.server.ServerManager.isCrashRecoveryNeeded(ServerManager.java:157)
        at weblogic.nodemanager.server.AbstractServerManager.initialize(AbstractServerManager.java:99)
        at weblogic.nodemanager.server.AbstractServerManager.(AbstractServerManager.java:63)
        at weblogic.nodemanager.server.ServerManager.(ServerManager.java:38)
        at weblogic.nodemanager.server.DomainManager.initialize(DomainManager.java:96)
        at weblogic.nodemanager.server.DomainManager.(DomainManager.java:60)
        at weblogic.nodemanager.server.NMServer.initDomains(NMServer.java:220)
        at weblogic.nodemanager.server.NMServer.start(NMServer.java:197)
        at weblogic.nodemanager.server.NMServer.main(NMServer.java:377)
        at weblogic.NodeManager.main(NodeManager.java:31)



Possibly the status of a server is determined by the servername.state (not sure):

cd /opt/oracle/domains/osbpr1do/servers/osbpr1ms2/data/nodemanager
cat osbpr1ms2.state
FORCE_SHUTTING_DOWN:Y:N


cat osbpr1ms2.pid
24767