Igor Kromin |   Consultant. Coder. Blogger. Tinkerer. Gamer.

I've been a fan of using the Oracle WebLogic Maven Plugin to build web services from JWS files for a long time now. Even though the plugin has its quirks, it does a great job and simplifies the whole web service build process. So...it was with shock and horror that I've recently discovered just how slow using this plugin can get.

I use a quite fast MacBook Pro for all my work...completely oblivious to the fact that not all developers that I interact with have access to the same category of hardware. Where I would usually see a service built in under 7 seconds, others were waiting over 4 minutes!

Something had to be done.

I started having a look at what we do exactly with the wsgen goal. Its configuration was very simple...
 pom.xml
<configuration>
<keep>false</keep>
<protocol>Xsoap1.2</protocol>
<sei>${jws.impl}</sei>
<genWsdl>false</genWsdl>
<args>
<arg>-J-source=${java.sourceVersion}</arg>
<arg>-J-target=${java.sourceVersion}</arg>
</args>
</configuration>


Throw away the generated sources, build SOAP 1.2 artifacts and don't generate any WSDL. It's pretty much stock standard. The only function the plugin was performing in this case was generating the Java class files required for the web service interface. It didn't need to do this for every build! What I wanted to do now was to see the kind of difference I would get if this whole step was skipped.

However, skipping this step would mean that I'd get a web service that failed to deploy. I needed to preserve the generated Java files and compile them with the rest of the web service implementation classes. The first part was easy, I changed the keep configuration parameter to true and reran the build.
 pom.xml
<configuration>
<keep>true</keep>
...
</configuration>


Great, my target directory now contained the generated-sources directory, which had the wsgen directory. All of the generated packages and Java files were now within that.
wsgen.png




I took all of the contents of the wsgen directory and put them in the web service module's src/main/generated directory. This was done on purpose to keep the generated sources away from the implementation sources. All I had to do now was add this directory to the list of directories that the Java compiler plugin used and for that I used the Build Helper Maven Plugin. The configuration for it was very boiler plate...
 pom.xml
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/main/generated</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>


The web service built exactly the same way as before now and deployed without problems. Functionally nothing changed. What about build times? On my Mac it went down to 4 seconds, a 3 second reduction, but almost a 60% improvement. On the lesser performing machines that I wanted to have this issue addressed on I saw a much more worthwhile improvement however. Down to just around a minute and 45 seconds, an over 2 minute improvement. Again a 60% improvement in build time.

So are these improvements worth it? In my case when I work on web service changes it is not uncommon to build and deploy at least 10 times a day. In my case that's only a 30 second improvement and not a big deal. For the other developers I work with however, the improvement inflates out to well over 20 minutes for a single day and comes close to 2 hours for a week. That's a whole lot of extra coding time! So I think depending on your hardware, this could be a very worthwhile change.

There is the added complexity of maintaining a separate location for generated sources and making sure that the classes here are updated every time the JWS file changes, however that's a small price to pay.

-i

A quick disclaimer...

Although I put in a great effort into researching all the topics I cover, mistakes can happen. Use of any information from my blog posts should be at own risk and I do not hold any liability towards any information misuse or damages caused by following any of my posts.

All content and opinions expressed on this Blog are my own and do not represent the opinions of my employer (Oracle). Use of any information contained in this blog post/article is subject to this disclaimer.
Hi! You can search my blog here ⤵
NOTE: (2022) This Blog is no longer maintained and I will not be answering any emails or comments.

I am now focusing on Atari Gamer.