dtolabs / yana2

Yet Another Node Authority ... because you wanted an agile Real-Time Service Model (RTSM)
8 stars 1 forks source link

XML import fails #135

Closed gschueler closed 12 years ago

gschueler commented 12 years ago

xml import fails if the app container is started from a particular directory. the yana.xsd schema file is not loaded properly

sharadr commented 12 years ago

This is because the code defines loading as : Schema schema = factory.newSchema(new File("docs/yana.xsd"));

It should be loaded from the classpath as a resource. Otherwise, the file object takes the root path as the path from where the process was started.

URI /import/savexml Class org.xml.sax.SAXParseException Message schema_reference.4: Failed to read schema document 'file:/data/dad/DEV/runtime/yana2/tomcat/bin/docs/yana.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not xsd:schema. 11:30 Trace Line | Method ->> 594 | newSchema in javax.xml.validation.SchemaFactory


| 610 | newSchema in '' | 59 | savexml . in com.dtolabs.ImportController | 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker | 908 | run . . . in '' ^ 619 | run in java.lang.Thread

orubel commented 12 years ago

How is the controller being called like this to be able to generate this error? Is this being called outside the Grails Application by a script?

sharadr commented 12 years ago

Steps to reproduce:

Application is deployed as a war file on tomcat. (grails prod war) Go to https://localhost:8443/ Login as admin/admin Import any xml file

orubel commented 12 years ago

what is meant by 'particular directory' if you are saying a default install will throw this? Is this a continuation of the tomcat 'context' complaint? You should include that ticket in here if thats related.

sharadr commented 12 years ago

'particular directory' is the directory from where the tomcat instance is started. It is an issue with the default install. It is not related to context. Steps to reproduce are listed above.

orubel commented 12 years ago

Oh wait. Thats right. It needs to be called within the web-app or docs needs to be external. I think I ran into this before.

You can test the WAR and it runs GREAT! But in deploying, only web-app can be seen so you have to put dirs that need to be seen in web-app or just call external dirs like in HOME.

I think this is what is happening. If you move docs to web-app and reference there, it should fix everything or just reference it at HOME/.yana and have them move the file there. Make sure to limit access to docs in your conf.groovy file