Tuesday, July 19, 2022

How to disable Apache CXF policy engine on CXF client side (Notes to myself)

Recently I came across a case where a JAX-WS service provided WSDL with lots of Policies but didn't actually enforce them. 
This was causing API to be consumed correctly via Postman but not from Apache CXF wsclient as it was trying to enforce the policies. 
After doing lot of efforts I ended up creating the dummy server for testing using WSDL2Java and recreate the scenario as the external service wasn't in my control. 

Once I did this and tested against the Dummy service first thing I got was behavior change where even the pure HTTP request from postman started failing with same policy related soap fault. 

After log of searching and trial and error found out on server side turning off policy engine gave me the same behavior as external Service which is passing on Postman and failing with Apache CXF wsclient. To Switch off the server side policy engine I added :
<beans xmlns="http://www.springframework.org/schema/beans"
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
http://cxf.apache.org/policy http://cxf.apache.org/schemas/policy.xsd
    <p:engine enabled="false" ignoreUnknownAssertions="true"/>
Once this is done I tried searching way to disable the client side policy assertion as I was using the full wsdl with policy assertions. 

I wanted to control it at per http conduit level however, I didn't find anything clearly in docs or anywhere so I resorted to the last option of disabling it for the whole default bus for all the services/api's for now. 

 For disabling client side I had configure cxf.xml with following :
<!-- This is a Configuration File For Configuring Client Properties -->
<beans xmlns="http://www.springframework.org/schema/beans"
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
<p:policies enabled="false" />

 <!--Following configuration states that client will wait for response for 1 hour-->
      <http-conf:client ReceiveTimeout="3600000" />
This solved my immediate issue of consuming the API but I still need to understand and find a way to do it selectively as my app may have multiple clients in same JVM consuming multiple services and underneath using same CXF bus. Also, currently I don't have the option of having separate bus for each client/invocation.

Monday, September 30, 2013

Quick Note on How to enable ExFAT partition support in Ubuntu.

I recently had to reformat my USB 3 drive to ExFAT for accessing it properly on Mac for Backup. Everything was fine as long as I used it on Mac and Windows.  Once I have lost access to Mac and shifted to my favorite Ubuntu machine I was surprised by having similar issue that I had on Mac but with ExFAT this time. After searching a bit I found that ExFAT partition type isn't supported out-of-box. To enable this one need to add the support separately.

Here is what is needed to enable ExFAT support.

$sudo -s
$apt-add-repository ppa:relan/exfat
$apt-get update
$apt-get install fuse-exfat

This will install the ExFat support and the drive got mounted automatically.

In case you want to mount the drive manually you can do something like:

mount -t exfat /dev/sdb1 /media/exfatdir

Thursday, July 18, 2013

Brought back power dead mac with following tip from Apple support.

I got a sudden power dead laptop overnight when left in sleep mode as usual. I couldn't get it start by any means and power connector was fine, battery was full etc.
I was pretty sure it was some hardware failure and was about to search Apple Service Centre however, while looking for address online found a toll free Apple support number and thought of giving a call to them.
To my surprise the call was picked up quickly and upon providing serial number and doing some rudimentary checks person on phone quickly asked me try 2 things first didn't work but second work like charm and it came back to life.  a 4-5 min call saved me a 2 hour trip to Apple Service centre and above all all this time I didn't have to hear the recorded sentences with unnecessary "Thank you", "Sorry", "Bare with me" and most importantly I wasn't made to feel like a dumb terminal on the other end.

Anyhow, apart from Rants here is the main purpose of the post to note down the tips.

Tip 1 :
Press   cmd+option+P+R and while pressed use Power  button to switch on Mac which in my case didn't work.

Tip 2 :
Press Right ctrl+options+space and then power button at same time, This worked in my case and my Mac came back on and started properly.

Upon asking what was the issue, I was told it was due to being a full memory and a software bug in OS that may cause it sometimes to appear power dead.  I didn't bother exploring technical details at that stage since I had other things to worry about.

I hope this helps me in future and some one else on the net to try it out first in such case.

Tuesday, March 26, 2013

Switching ubuntu boot from graphics to text mode.

This one has always puzzled me and make me go round and round few times now on all my new VM's, so I decided to note down what I did this time.

To Change the Graphic boot to Text mode on startup all you need to do is modify your /etc/init/.cfg file.

In my case I was trying to do this with gdm.cfg based on many google results however, I missed a crucial point that I had selected another Display Manager lightdm. After trying few things I finally realized the mistake. So here is the snippet from /etc/init/lightdm.cfg (This should be same for gdm as well in gdm.cfg):
start on ((filesystem
           and runlevel [!026]
           and started dbus
           and (drm-device-added card0 PRIMARY_DEVICE_FOR_DISPLAY=1
                or stopped udev-fallback-graphics))
          or runlevel PREVLEVEL=S)

stop on runlevel [016]
You can change the runlevel in
stop on runlevel [016]
but I didn't find it necessary, just changing it in start on section did the job.

Monday, April 16, 2012

Quick Note on How to remove/change /cxf from context path of CXF OSGi service.

By Default, when a CXF servlet endpoint is deployed in Servicemix OSGi container the context path for the endpoint address contains "/cxf".
This causes resulting endpoint URL being something like http://localhost:9090/cxf/myservice . This is not always a desirable URL and many times needed to change to more generic (technology neutral) URL for publishing the endpoint.

This default context can be changed in one of the two ways as follows:

1. It can be changed by adding org.apache.cxf.servlet.context=/myservice to etc/org.apache.cxf.osgi.cfg.

2. By running following commands to alter configuration in container using configuration management service in Servicemix container.
       config:edit org.apache.cxf.osgi
       config:propset org.apache.cxf.servlet.context /myservice

Monday, November 14, 2011

ActiveMQ prefetch and Spring DMLC advice from Torsten

A piece of advice on ActiveMQ prefetch and Spring DMLC from my colleague Torsten.

I just remembered a lesson learned about prefetch and Spring DMLC:
If you configure DMLC to use CACHE_SESSION or below (i.e. CACHE_CONNECTION or CACHE_NONE) *and* when you don't use a CachingConnectionFactory (e.g SingleConnectionFactory), then you should set the prefetch for the Spring consumer to only 1 or 0.
That is because when not caching the consumer, a new JMS consumer is recreated for every msg that Spring will ask the broker for.
And if there are many msgs on the queue, the broker will prefetch e.g. 1000 msgs to the consumer although the consumer will only process one msg.
Spring DMLC then recycles the JMS consumer with 999 unprocessed msgs. This obviously causes to much and unnecessary load on the network.

So possible solutions in this case:
1) prefetch=0 or 1,
2) configure DMLC to use CACHE_CONSUMER, or
3) use Springs CachingConnectionFactory