Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cowardly refuses to write to a non-existent directory - JAXB

I'm getting the following error when trying to generate Java classes from an XSD schema using JAXB. I'm specifying a directory that I want them to be in but I am getting the following error when I try to run the command.

Command:

java -jar /home/Alison/Programs/jaxb-ri-2.2.6/lib/jaxb-xjc.jar xmlSchema.xjb -d com.q1labs.qa.xmlgenerator.model.xmlclasses xmlSchema.xsd

Error:

cowardly refuses to write to a non-existent directory "com.q1labs.qa.xmlgenerator.model.xmlclasses"

I found the following patch http://jira.codehaus.org/browse/MJAXB-2 but from the comments it seems that it no longer works with the current revision.

Is there any way I can specify to create the directory if it does not exist?

like image 458
Colin747 Avatar asked Sep 01 '12 13:09

Colin747


2 Answers

Is there any way I can specify to create the directory if it does not exist?

The simple answer is to create the directory before you run the application. In general, there is no way to get an application to create a directory for you if the application doesn't already have the capability to create directories.

FWIW, it is generally a bad idea for an application to create "missing" directories ... unless the user has indicated that that is what is required; e.g. via a command line option. The reason is that "missing" directories are usually due to the user mistyping a pathname, or due to the current directory being different to what the user thinks it is. In other words, the user usually wouldn't want the application to create the "missing" directories.

like image 98
Stephen C Avatar answered Nov 02 '22 22:11

Stephen C


Manged to get this to work the way I wanted using the following command:

java -jar /home/Alison/Programs/jaxb-ri-2.2.6/lib/jaxb-xjc.jar -b xmlSchema.xjb -d src -p com.q1labs.qa.xmlgenerator.model.xmlclasses xmlSchema.xsd

like image 37
Colin747 Avatar answered Nov 03 '22 00:11

Colin747