<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Sam Alston&#039;s Blog &#187; java wsdl autogen spring xsd maven</title>
	<atom:link href="http://kennelbound.com/tag/java-wsdl-autogen-spring-xsd-maven/feed/" rel="self" type="application/rss+xml" />
	<link>http://kennelbound.com</link>
	<description></description>
	<lastBuildDate>Wed, 07 Sep 2011 17:25:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>WSDL2Java with Maven &#8211; Fixing &#8220;BadCommandLineException: grammar is not specified&#8221;</title>
		<link>http://kennelbound.com/wsdl2java-with-maven-fixing-badcommandlineexception-grammar-is-not-specified/</link>
		<comments>http://kennelbound.com/wsdl2java-with-maven-fixing-badcommandlineexception-grammar-is-not-specified/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 21:49:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[java wsdl autogen spring xsd maven]]></category>

		<guid isPermaLink="false">http://kennelbound.com/?p=8</guid>
		<description><![CDATA[At my job, we use the wsdl2java maven plugin to generate the appropriate classes from the webservices&#8217; wsdl document.  When we received notice that we were to incorporate a new webservice into the system, we thought &#8220;No big deal, we&#8217;ll just use the plugin and be off!&#8221;
Unfortunately, we ran into the dreaded &#8220;com.sun.tools.xjc.BadCommandLineException: grammar <a href="http://kennelbound.com/wsdl2java-with-maven-fixing-badcommandlineexception-grammar-is-not-specified/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>At my job, we use the wsdl2java maven plugin to generate the appropriate classes from the webservices&#8217; wsdl document.  When we received notice that we were to incorporate a new webservice into the system, we thought &#8220;No big deal, we&#8217;ll just use the plugin and be off!&#8221;</p>
<p>Unfortunately, we ran into the dreaded &#8220;com.sun.tools.xjc.BadCommandLineException: grammar is not specified&#8221; error.  After inspecting the code I couldn&#8217;t find any issue.  The wsdl was right there, and it didn&#8217;t reference any outside xsds or anything?  What&#8217;s the problem?</p>
<p>I did a google search.  Found some interesting threads from nabble that had nothing to do with my problem.  Eventually, I found that (with a misleading name) the wsdl2java plugin doesn&#8217;t automatically pickup xsds.  If you are pointed to a directory that has XSDs (usually referenced by the actual wsdl files) it will autogen from those.  But if your xsd are in a subdirectory (or not needed for such a simple webservice) then wsdl2java blows up with the grammar error.</p>
<p>I ended up the following in my pom:</p>
<pre>
<pre class="brush: xml">
&lt;plugin&gt;
    &lt;groupId&gt;com.sun.tools.xjc.maven2&lt;/groupId&gt;
    &lt;artifactId&gt;maven-jaxb-plugin&lt;/artifactId&gt;
    &lt;executions&gt;
        &lt;execution&gt;
            &lt;!-- This one has the xsd&#039;s in the same directory, so it was already working --&gt;
            &lt;id&gt;simple-xsd-wsdl2java&lt;/id&gt;
            &lt;phase&gt;generate-sources&lt;/phase&gt;
            &lt;goals&gt;
                &lt;goal&gt;generate&lt;/goal&gt;
            &lt;/goals&gt;
            &lt;configuration&gt;
                &lt;!-- directory of the wsdls and the xsds --&gt;
                &lt;schemaDirectory&gt;src/main/wsdl/simple&lt;/schemaDirectory&gt;
                &lt;generateDirectory&gt;src/autogen/simple&lt;/generateDirectory&gt;
                &lt;readOnly&gt;true&lt;/readOnly&gt;
            &lt;/configuration&gt;
        &lt;/execution&gt;
        &lt;execution&gt;
            &lt;!-- This one was only the WSDL files, with no external XSDs --&gt;
            &lt;id&gt;wsdlOnly-wsdl2java&lt;/id&gt;
            &lt;phase&gt;generate-sources&lt;/phase&gt;
            &lt;goals&gt;
                &lt;goal&gt;generate&lt;/goal&gt;
            &lt;/goals&gt;
            &lt;configuration&gt;
                &lt;!-- directory of the wsdl files --&gt;
                &lt;schemaDirectory&gt;src/main/wsdl/wsdlOnly&lt;/schemaDirectory&gt;
                &lt;generateDirectory&gt;src/main/autogen/wsdlOnly&lt;/generateDirectory&gt;
                &lt;readOnly&gt;true&lt;/readOnly&gt;
                &lt;includeSchemas&gt;
                    &lt;!-- Each schema has to be spelled out as an includedSchema, or it will be ignored --&gt;
                    &lt;includeSchema&gt;AccountService.wsdl&lt;/includeSchema&gt;
                    &lt;includeSchema&gt;SystemService.wsdl&lt;/includeSchema&gt;
                    &lt;includeSchema&gt;GiftService.wsdl&lt;/includeSchema&gt;
                &lt;/includeSchemas&gt;
                &lt;!-- Indicates to the grammar parser that the schema files are in the wsdl format --&gt;
                &lt;args&gt;-wsdl&lt;/args&gt;
            &lt;/configuration&gt;
        &lt;/execution&gt;
    &lt;/executions&gt;
&lt;/plugin&gt;
</pre>
</pre>
<p>Notice that in the wsdlOnly configuration I have specifed each schema file separately.  I think there is a way to specify a directory/wildcard search, but I didn&#8217;t spend the time figuring it out.  The other immensely important part is adding the args section.  This tells the parser that the files are in wsdl format, not in XSD.</p>
<p>I hope that this helps anyone out there looking for a way to auto generate class files to use with SpringWS from stand-alone wsdl files.</p>
]]></content:encoded>
			<wfw:commentRss>http://kennelbound.com/wsdl2java-with-maven-fixing-badcommandlineexception-grammar-is-not-specified/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

