Sunday, February 26, 2012

I use a launcher called SlickRun to quickly pull up commonly used applications and websites while I'm working. I recently installed the FoxyProxy plug-in which has since plagued me with strange errors about "DDE" whenever I sometimes open a web address:
The MagicWord eng is broken.
DDE Error.
Would you like to edit the MagicWord?
This only happens if Firefox is not already open. It was more of nuisance than a major issue so I've been ignoring it for a couple of weeks. Today, with the help of a blog post, I was able to solve my issue. Using regedit, I changed the "(Default)" value of key HKEY_CLASSES_ROOT\FirefoxURL\shell\open\ddeexec from "%1",,0,0,,,, to an empty string.

I still wanted to know the root cause, but after more searching I couldn't find much. There are bugs filed with Mozilla and the general idea I get from the comments is that it has to do with Windows' mapping of an HTTP, HTTPS, or FTP requests to a system default application. Some applications require a DDE request and the fix I've listed above just turns it off.

Wednesday, August 31, 2011

Customizing Namespace Prefixes

Changing the namespace prefix on XML elements sent to a web service seemed like a simple task. I wasn't intimately familiar with the granular customization details of JAXB or JAX-WS; but how hard could it be? After spending over a week with XSL, JAX-WS filters, endorsed packages, classpath ordering, and other fun hacks; I've developed a bit of hatred for JAXB. I thought I'd document my findings and hopefully save some other poor soul from its torment.

Start by enabling logging:
Flipping this property on will print all of the sent and received SOAP messages to standard output.

Next, annotate the namespace's generated package with a prefix directive:
    namespace = "",
    elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED,
    xmlns = {
            prefix = "addr",
            namespaceURI = "")
package org.tempuri.address;
This is the file generated by wsimport. Ideally, a bindings file should have wsimport create the XmlNs annotation but I couldn't find any documentation on how to do that. It'll be overwritten each time but there's a hack for that. (More details below.)

Strangely, the prefix would not work for me at this point and I had to upgrade to JAX-WS 2.2.1. This, in turn, forced me to move the JAX-WS 2.2.1 libraries higher up in the order of my Eclipse project classpath. My deployment package also now required the java.endorsed.dirs JVM property to be set and pointed at the 2.2.1 jars.

With the namespace prefix now working and no documentation on generating an XmlNs annotation, the package-info changes need to be automated. For my hacked solution, I moved into my static source tree and added an Ant task to remove the file after generation:
<wsimport ... />
<delete file="${gen-src}/" />

This produces a new issue. The wsimport task will generate and compile the package-info. When a full build executes later, the class file is already up to date and will be skipped. There are two solutions to this:
  1. Add a delete task to remove the class file as well.
  2. Add the -npa option to the wsimport task to suppress the generation of package-info files:
<wsimport ...>
  <xjcarg value="-npa" />
<delete file="${gen-src}/" />

It's awful, it's hideous, it keeps me awake at night, but it works. If you're reading this article looking for help and now you're just shaking your head in disgust, try Harald Wellmann's blog post. He does a great job of presenting two solutions I wish I had found much earlier in my research.

Saturday, August 20, 2011

wsimport depends/produces

Working with the wsimport Ant task, you may come across this warning:

Consider using <depends>/<produces> so that wsimport won't do unnecessary compilation

For whatever reason these nested elements were left out of the documentation.  I borrowed some wording from the JAXB documentation and wrote this amendment:

Files specified with this nested element will be taken into account when the task does a modification date check.  For proper syntax, see <fileset>.

Files specified with this nested element will be taken into account when the task does a modification date check.  For proper syntax, see <fileset>.

    <depends file="${local-wsdl-path}"/>
    <produces dir="${src.generated.dir}"/>

This wsimport example specifies a depends/produces relationship between a local WSDL file and the generated source directory. If the WSDL file has a modification date more recent than the generated directory, the wsimport task will regenerate and recompile the source code.

Tuesday, February 1, 2011

Dynamic Java Classpath in UNIX

I've been playing "guess the dependency" with some Axis2 Java code all morning.  After encountering three or four NoClassDefFound exceptions, I'm rewriting my java command to dynamically list all of the jar libraries on the classpath.  Here's what I compiled from browsing some forums and blogs:

find /opt/axis2/lib -type f -name *.jar | \
sed ':a;N;$!ba;s/\n/:/g'

Wednesday, September 29, 2010

Encrypting a .NET Configuration Section

If you don't want your database connection string information hanging around in the configuration file as plain text, you can encrypt it with the aspnet_regiis utility.  Here's how:

Unfortunately the utility is hard coded to modify web.config, so you'll have to rename your file first.
move MyApplication.exe.config web.config
Run the aspnet_regiis utility and tell it you want to encrypt the connectionStrings configuration section:
aspnet_regiis -pef connectionStrings . -prov DataProtectionConfigurationProvider
Restore your original filename:
move web.config MyApplication.exe.config

If you're getting a "command not found" error, you'll have to add the framework binaries to your path.  The aspnet_regiis utility is usually located here:

Thursday, September 9, 2010

When to Use Slashes in PL/SQL Scripts

I had a PL/SQL script defect today because I left out a slash.  It seemed Toad may have been a little more forgiving than SQL*Plus when I was doing my testing.  This isn't the first time I've been caught by this subtlety.  Asking my colleagues for an explanation yielded various opinions rather than fact, so I decided to try my luck in the mountains of Oracle documentation.  Surprisingly, it didn't take much effort to find this:
SQL*Plus treats PL/SQL subprograms in the same manner as SQL commands, except that a semicolon (;) or a blank line does not terminate and execute a block. Terminate PL/SQL subprograms by entering a period (.) by itself on a new line. You can also terminate and execute a PL/SQL subprogram by entering a slash (/) by itself on a new line.
 I had been treating my PL/SQL blocks like SQL statements and terminating them with a semicolon.  Doesn't  DECLARE-BEGIN-END; appear to compose a complete and terminated statement?  Regardless; this will be at the forefront of my mind when writing my next script.