I use Eclipse with Maven (m2eclipse plugin) and JIBX to (un)marshall XML.
It works if I use the factory like this:
IBindingFactory bindingFactory = BindingDirectory.getFactory(mappedClass);
However I want to create a factory based on the binding file, because this is done by the automatically generated service stub. So I run the following test in TestNG:
@Test
public void testBindingFactory() {
try
{
IBindingFactory factory = BindingDirectory.getFactory("binding", "");
} catch (JiBXException e)
{
e.printStackTrace();
fail(e.getMessage());
}
}
and it fails with the following error message:
Unable to access binding 'binding'
Make sure classes generated by the binding compiler are available at runtime
java.lang.ClassNotFoundException: .JiBX_bindingFactory
The name (filename is binding.xml) is correct, the empty "" means no package, which is also correct, but could be a problem I guess?
The factory is generated under target/classes/JiBX_bindingFactory.class
in my project folder, so it should be found! (Remember everything works if I specify a concrete toplevel binded class)
Any help would be appreciated!
The build section in my pom.xml file:
<build>
<plugins>
<plugin>
<groupId>org.jibx</groupId>
<artifactId>jibx-maven-plugin</artifactId>
<version>1.2.5</version>
<configuration>
<schemaBindingDirectory>src/main/config</schemaBindingDirectory>
<includeSchemaBindings>
<includeSchemaBinding>binding.xml</includeSchemaBinding>
</includeSchemaBindings>
<verbose>true</verbose>
</configuration>
<executions>
<execution>
<goals>
<!-- Do we require other goals? http://jibx.sourceforge.net/maven-jibx-plugin/ -->
<goal>bind</goal>
<!-- goal>test-bind</goal-->
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>