How to return soapFault in a jax ws web service in JavaEE

The code below is an example of how you can throw a soapFault exception when an error is encountered in your web service  call.

There are basically 2 things 2 take note, see comments in code.


//#1 - inject WebServiceContext
@Resource
private WebServiceContext webServiceContext;

//#2 get the soapMessage, add a soapFault in body and throw the soapFault exception.
SOAPMessageContext jaxwsContext = (SOAPMessageContext) webServiceContext.getMessageContext();
SOAPMessage soapMsg = jaxwsContext.getMessage();
try {
SOAPFault soapFault = soapMsg.getSOAPBody().addFault();
soapFault.setFaultString("ERROR");
Name qname = soapMsg.getSOAPPart().getEnvelope().createName("Client", null, SOAPConstants.URI_NS_SOAP_ENVELOPE);
soapFault.setFaultCode(qname);
throw new SOAPFaultException(soapFault);
} catch (SOAPException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

Lesser-known features of afl-fuzz


AFL is designed to be simple to use, but there are quite a few advanced, time-saving features that may be easy to overlook. So, here are several useful tricks that aren't covered in README:





  • Test case postprocessing: need to fix up checksums or length fields in a particular file format? AFL supports modular postprocessors that can take care of this for you. See experimental/post_library/ for sample code and other tips.



  • Deferred forkserver: stuck with a binary that initializes a lot of stuff before actually getting to the input data? When using clang, you can avoid this CPU overhead by instructing AFL to clone the process from an already-initialized image. It's simpler than it sounds - have a look at llvm_mode/README.llvm for advice.



  • Helpful stats: in addition to using afl-plot to generate pretty progress graphs, you can also directly parse <out_dir>/fuzzer_stats for machine-readable statistics on any background tasks. The afl-whatsup script is a simple demo of that.



  • Faster resume: if you don't care about detecting non-deterministic behavior in tested binaries, set AFL_NO_VAR_CHECK=1 before resuming afl-fuzz jobs. It can speed things up by a factor of ten. While you're at it, be sure to see docs/perf_tips.txt for other performance tips.



  • Heterogeneous parallelization: the parallelization mechanism described in docs/parallel_fuzzing.txt can be very easily used to co-fuzz several different parsers using a shared corpus, or to seamlessly couple afl-fuzz to any other guided tools - say, symbolic execution frameworks.



  • Third-party tools: have a look at docs/sister_projects.txt for a collection of third-party tools that help you manage multiple instances of AFL, simplify crash triage, allow you to fuzz network servers or clients, and add support for languages such as Python or Go.



  • Minimizing stuff: when you have a crashing test case, afl-tmin will work even with non-instrumented binaries - so you can use it to shrink and simplify almost anything, even if it has nothing to do with AFL.






Enjoy!


Oh, the places you won't go: Polonia in the United States


This is the third article in a short series about Poland, Europe, and the United States. To explore the entire series, start here.




Naming the largest diasporas in the United States may seem like an easy task. For one, we have the deeply-assimilated families of German, Irish, Italian, and British immigrants. There is also a large Mexican community, unique for having a much higher percentage of members who were foreign-born.




Most people would venture a guess that India or China should come next; some may also suggest France, Denmark, or the Netherlands. They would be all wrong: the next spot on the list belongs to the massive Polish diaspora, estimated to be almost ten million strong.




Given its sheer size, the cultural influences of the Polish-American community are uncharacteristically subdued. There are precious few Poland-originating holiday traditions or ethnic foods. Outside a couple rapidly shrinking enclaves such as Avondale in Chicago or Greenpoint in New York City, you are unlikely to bump into posh Polish diners, pricey grocery stores, or flamboyant street parades. Children born to Polish immigrants in the US are seldom taught to read or write in their parents' language - and will probably know very little about their familial lineage or common ancestry.




Perhaps there just aren't that many bits of Polish culture to build on against the backdrop of Germanic, British, Italian, and Dutch influences that shaped the American life. Much like its German counterpart, the traditional Polish cuisine is obsessed chiefly with potatoes and meat. Today, we take pride in our pączki, but when pressed, we will sooner or later confess that they are just doughnuts by some other name. We can offer you some pierogi, but they will truly impress you only if you never had any ravioli or tortellini. We can also hook you up with some sausage, sauerkraut, pickles, ribs, or beer. On your way out, take a bite of our cheesecake or apple pie.




The holiday traditions run into the same challenge, perhaps with the exception of the infamous but niche Dyngus Day. Other than that, the most commonly observed practice is that in line with much of Central Europe, Polish children may get their gifts in the evening on Christmas Eve, not in the morning on Christmas Day. Our traditional clothing looks distinctive - but it is ornate and archaic, making it compare unfavorably with the beautiful simplicity of wearing green on St. Patrick's Day, or getting hammered in suspenders come Oktoberfest.




Humor aside, a more powerful clue to the invisibility of the Polish diaspora may lie in its very history. In the twentieth century, the immigrants from Poland ended up occupying three isolated social strata, with relatively few opportunities for working together and developing any form of a shared cultural identity.




The first and most populous stratum of contemporary immigration were the common folk, displaced by the horrors of the war and the crippling poverty that followed under communist rule. Many of them worked menial jobs, spoke little or no English, and clustered around many of the traditionally Polish enclaves that offered them a degree of familiarity and support. For many years, they and their children faced blatant discrimination, epitomized by the popular "Polish jokes" in the 1960s and 1970s. The demeaning stereotypes that followed them everywhere prompted many Poles to adopt Americanized names, intermarry, and keep their origins a private affair.




The second stratum were the dissidents and the disillusioned intellectuals leaving Poland to escape the dysfunctional regime. Usually better-educated and more confident, they helped build the first proper Polish-American institutions, including local newspapers, community organizations, churches, shipping and travel companies, or banks. The members of this group felt much stronger national identity and perceived themselves as the guarantors of Polish interests abroad. With the fall of communism in Europe, many of them were incredulous that the former dignitaries were allowed to walk free and play a role in business and politics - a sentiment that still shapes their political views.




The big change in immigration trends came with the accession of Poland to the European Union. The unhappy and the disenfranchised would now overwhelmingly favor moving to Germany or to the UK, where they could take up residence without having to deal with restrictive immigration laws. The remaining US-bound migration shifted toward skilled, university-trained engineers and IT workers, many of whom gravitated toward tech hubs such as SF Bay Area, Seattle, or NYC. Having been born in the 1970s and 1980s, most of them remembered Poland as a thriving capitalist democracy; they were driven not by despair, but by the prospects of better pay or more interesting work.




All this nuance is easily lost on the people back home. Many of the left-wing and centrist pundits in Poland demonize the expats in hopes of mobilizing the more moderate domestic electorate. They paint a picture of a frighteningly powerful voting block that will prop up any fringe, conservative candidate, as long as they promise to rid Polish politics of the Soviet sleeper agents and other increasingly fictitious communist legacy.




Of course, for most part, such reputation is bunk; although a good percentage of Polish-Americans are very distrustful of left-leaning politicians in their country of origin, only a tiny percentage of them ever turns up to actually cast a ballot, and their overall influence on the results of Polish elections is slim. Contrary to how they are perceived, they also do not blindly cling on to social conservatism; in American elections, they usually vote for Democrats.




That said, repeated over and over again, the catchy narrative about dimwitted compatriots can take a life of its own. Several weeks ago, Longin Pastusiak, an eminent Polish publicist and polician, penned a piece characterizing Polish-Americans as simpletons who only have a very shallow appreciation for the Polish heritage and who meekly submit to the supposedly powerful influences of the Roman Catholic church. He is not alone in his views; many go even further and call for the diaspora's voting rights to be taken away.




Having overcome discrimination in the States only to face bureaucratic hurdles and prejudiced, vitriolic nonsense back home, it's no wonder that most of the Polish immigrants just want to blend in and move on. In the long haul, it's probably a big loss - not necessarily for them, but for their former home.






Crowds at Polish Days in San Francisco (2010)




For the next article in the series, click here.


Oh, the places you won't go: The politics of Poland


This is the second article in a short series about Poland, Europe, and the United States. To explore the entire series, start here.




Growing up in Poland in the 90s, I never cared much for politics. Back then, you wouldn't want to get overly attached to any political movement anyway: when a country of 38 million emerges from half a century of communist rule, you know there will be some kinks to iron out.




Sitting on the sidelines, I saw the views of others solidified by what seemed like happenstance. My mother, a promising white-collar worker cast aside by the new reality, leaned sharply to the left; she would sometimes wax lyrical about the good old days of socialism. My wife's father, a one-time Party member turned opposition activist, found himself playing a role for the increasingly polarizing right. My aunt, a mild-mannered professor of ethics, rose to prominence in the liberal Warsaw elites - and became one of the most outspoken voices of feminism and anticlericalism in the country. She had an uneasy but fruitful relationship with the centrist movement.




At the turn of the twentieth century, no matter which side you took, keeping up with the political landscape must have been a full-time job. The bitterly divided communist-era dissident circles splintered into dozens of ephemeral movements, with many familiar faces gravitating toward two camps: the economically liberal centrist party that flirted with the teachings of Margaret Thatcher; and the Christian nationalist movement that somewhat confusingly co-opted the notions of social solidarity with the underprivileged, then served that dish with a side of social conservatism and a hint of distrust toward the EU.




On the other side of the political spectrum, many of the former Party dignitaries joined forces and reinvented themselves as modern-day, pro-European social democrats. Despite the branding, the post-communist camp adopted a set of conservative economic policies seldom distinguishable from the direction taken by the centrist bloc. They brandished secular, progressive social attitudes - but in a deeply-religious country where catechesis has a largely uncontested place in public schools, they never dared to experiment with them to any real extent.




In many ways, I found it easier to pinpoint what these political movements had in common, not what set them apart. Their old-school leaders, by and large raised and educated in the communist era, had little experience with good governance or true statesmanship. Looking back at it, I think that the dissident camp was driven to some extent by an innate sense of entitlement to the spoils of overthrowing the communist rule. Their years at the helm were punctuated by unsportsmanlike cronyism, by shady deals around the sale of state-owned enterprises, and by attempts to cling on to power by entering absurd and ultimately self-destructive alliances with populist agrarian or nationalist movements.




The former communists played a different card. They saw themselves as the qualified, level-headed alternative to the argumentative and erratic right. They nurtured an image of proven leaders, even if their experience amounted to running a dysfunctional Soviet satellite state into the ground and then skillfully changing their views. For many years, they fared well in elections, but eventually, the mainstream left ended with a bang: the boldest of the many political scandals in the 2000s - afera Rywina - exposed an attempt to extort $17M from a newspaper publisher in exchange for striking down an antitrust provision in the proposed Polish media law.




Many stable democracies can afford a period of government dysfunction. For a time, this was certainly true for Poland: every modern-day democratic government to date had enough common sense to keep pushing for the integration with NATO and the European Union, worked to strike down or at least superficially modernize many of the communist-era laws, and never refused a penny of foreign aid. The unstoppable influx of capital did the rest, ushering a period of unprecedented stability and growth. The cracks would show only when you interacted with the state bureaucracy: with many levels of government permeated by centrally-appointed and disinterested ruling-party loyalists, getting a pothole fixed or a stop sign installed could very well prove to be an insurmountable task.




In some ways, that period of insensitivity to bad governance may be coming to an end. Driven away by a decade of stagnant wages coupled with the rapidly growing costs of living, some 2-3 million mostly young Poles decided to leave the country and seek a better life in the UK, in Germany, and in other parts of the EU. This, combined with sub-replacement fertility rates, must have put tremendous strain on the already-inadequate social security system - a safety net where the net retirement benefits hover somewhere around $400 a month.




In the most recent presidential elections in Poland, the centrist incumbent, Bronisław Komorowski, was so sure of his victory that he shunned televised debate. The voters not only turned up in droves to give his conservative opponent a healthy lead, but some 20% of them opted for a fringe anti-establishment candidate - a former punk rock singer with a knack for catchy lyrics but no experience in politics. The future is unknowable, but in the runoff elections, the punk rock aficionados are unlikely to vote for status quo.




Many of the moral authorities in Poland share the same dissident roots with the current president and are sympathetic to Mr. Komorowski's plight. One professor of political sciences prayed for the "radicalized youth" to leave the country, apparently unaware of how radical and divisive his own words may sound. The incumbent president was quick to note that he always supported the few scattered policy proposals that can be attributed to the anti-establishment candidate. He went on to meet with the voters and rebuked a young person asking how to get by on $550 a month. The president's answer: get a loan or find a better job.




For the next article in the series, click here.


Derfor er Nordeas produkt komplisert

Nordeas produkt, som jeg kommenterte i DN i dag, er et meget komplisert produkt, og jeg måtte bruke noen minutter på å forstå hva produktet egentlig lover. For amatører, som i sin tid hadde problemer nok med å forstå «garanterte» spareprodukter, vil nok den oppgaven være vanskelig. Men jeg skjønte nå etter hvert hva som var ideen, og den er illustrert i figuren under.

Det som virkelig er vanskelig med dette produktet, selv med en doktorgrad i Finans, er å forstå hvordan Nordea skal klare å genere den kontantstrømmen de lover utelukkende med opsjoner og en swap-avtale. Som en ser av figuren (grønn linje), gjør kontantstrømmen (verdien) som produktet lover et hopp når aksjenes verdi blir høyere enn 0,7, og et nytt hopp skjer på 1 (1=dagens kurs).

Slike hopp er vanskelig å konstruere med opsjoner, etter det jeg kan se. Det beste jeg klarte er den blå linjen. For enkelte verdier vil dermed lovet utbetaling (kontanstrøm) være forskjellig fra den en faktisk kan oppnå med opsjoner, etter det jeg kan skjønne. Selve arbeidsboken med beregningene finner du her.

Men det er naturligvis fullt mulig at det er noe jeg har misforstått her – så komplisert er altså produktet – så Nordea må gjerne forklare oss hvordan de får til denne kontantstrømmen.



Austerity in the UK

I just finished reading this piece by Brad DeLong: Optimal Control, Fiscal Austerity, and Monetary Policy. He begins in the following way:
I find myself perseverating over the awful macroeconomic policy record of the Conservative-Liberal Democrat government of the past five years in Britain, and the unconvincing excuses of those who claim that the austerity policies it implemented were not a disaster–and that the austerity policies it ran on would not have come close to or actually broken the back of the economy.
Then he presents us with the following picture:


The red line is supposed to show us how real GDP would have behaved in the UK if it wasn't for austerity. It must feel good to be so self-assured in one's diagnosis of an ailment. But Dr. Brad, forgive me, I do have some questions to ask of you.

First, I find it interesting that when you want to focus on the "depression" in the U.S., you point to the labor market performance there, not the GDP performance. You present pictures like this (source):


Which is fair enough, I think (I offer my own thoughts on your post here). But then, when you want to focus on the "depression" in the U.K., in and odd about-face, you ignore their labor market performance and focus solely on GDP. Why might this be? I think we should also take a look at the labor market data. If the effects of austerity are going to show up anywhere, I would think we should find them there (this is what our textbook models tell us, at least).

Here's the unemployment rate.  



Hmm...not what I would have expected, to be honest. Here's the employment to population ratio:



Yeah, I'm still not seeing it. How about participation rates?



Nope. Sorry. What if we focus on employment-to-population for prime-age workers?



Gee, the UK is actually looking pretty good against the US here. Remind me again, it was the U.S. that had the stimulus, right? How about the prime-age part rates?

 

Interesting, no? What about inflation? Here it is:

 

If anything, the UK had a higher rate of inflation over its period of austerity. Well. OK, let's go back to GDP.



Ah, so there it is. And in terms of real GDP per capita:




Ah  yes, there you have it. Austerity evidently killed GDP, but not the labor market. That's a very interesting hypothesis, but I'm wondering which textbook theory is consistent with it?

One story that makes sense is one in which austerity is somehow influences the productivity (or measured productivity) of workers. Classic Keynesian demand-stimulus measures are not typically thought to work through their effects on labor productivity (though, they could if government spending was in the form of infrastructure, for example.) The usual prediction is that an increase in G increases employment and reduces the average product of labor, where the effect on labor productivity is incidental (expansion of labor + diminishing returns to labor).

Interestingly, a neoclassical model with heterogeneous (high/low skill workers) could be consistent with these observations. Suppose that austerity takes the form of cuts to transfers (which may not have been the case). Then a standard wealth-effect motive induces workers to increase their labor supply (lower their reservation wages when searching for work), to make up for the loss in their after-tax wealth. To the extent that this wealth-effect is stronger for lower-skilled workers, the average quality of labor (measured labor productivity) declines. This is just a classic composition effect. I'm not suggesting that this is what happened. It's just interesting to note that it is theoretically possible from a neoclassical perspective and not so obvious from a Keynesian one.

Anyway, this post was meant more in the way of asking questions. In particular, I am not criticizing nor defending actual UK policy. I just want to know which textbook macro model (the model proposed by Krugman as all we need to know about macro) is consistent with DeLong's austerity story. Someone please do tell.

Postscript May 11, 2015
I asked my RA Michael Varley to provide some UK data on government spending, transfers and tax revenue. The data is plotted as a ratio of the working age population.