If you’ve ever seen this exception it can be mighty frustrating.:
org.jboss.ws.WSException: arg0 is not a valid property on class com.whatever.your.Class
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getElementPropertyAccessor(JAXBContextImpl.java:926)
at org.jboss.ws.metadata.accessor.JAXBAccessorFactory.create(JAXBAccessorFactory.java:51)
According to the JBoss wiki, you should be careful to add annotations to your web service methods, such as
@javax.xml.ws.RequestWrapper(className="package.UniqueClassName")
@javax.xml.ws.ResponseWrapper(className="package.UniqueClassNameResponse")
But what if you already did that? You used JBoss’ wsconsume utility to generate my Java classes from WSDL. The tool generated all the necessary class, method, and field-level annotations. Why are you STILL getting that terrible exception when you deploy your web application?
What I found out is that you need to check to make sure all relevant package.name.package-info ‘classes’ were compiled and added into your WAR. Without these class files, JAXB has problems mapping packages to namespaces and resolving any naming conflicts.
If you are using Apache Ant version > 1.7, you run the risk of this small-but-very-important class file being omitted from your WAR. These versions of Ant only conditionally compile this class to avoid multiple compilations. If you do a typical clean/build/package type of deployment using Ant1.7.1, chances are you’ll see no package-info.class file in your finished WAR.
That happened to me, and I was almost pulling my hair out wondering why I couldn’t cleanly deploy a WAR file that another developer on the project could. It turned out he was using Ant 1.7.0 and didn’t have this issue.
According to the Ant javac docs, Ant >1.7.1 will compile java files named ‘package-info.java’ if:
- If a package-info.class file exists and is older than the package-info.java file.
- If the directory for the package-info.class file does not exist.
- If the directory for the package-info.class file exists, and has an older modification time than the the package-info.java file. In this case will touch the corresponding .class directory on successful compilation.
So I chose to solve this problem by making sure the output directory where a newly-compiled package-info.class file would exist, then touch the timestamp on that directory to be very old. Then, the third condition in the above list is satisfied, and Ant would be forced to compile package-info.java. My build.xml snippet looks like this:
<target name="build" description="Compile main source tree java files">
<mkdir dir="${classes.dir}" />
<touch datetime="09/10/1974 4:30 pm" file="${classes.dir}/package/name/with/package-info.class"
mkdirs="true"/>
<javac destdir="${classes.dir}" >
<src path="${src.dir}" />
<classpath refid="master-classpath" />
</javac>
</target>
Another solution to the issue is posted here. I didn’t use this because in my environment it touched an actual source file, making cvs think it needed a commit.