Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't find Vaadin ClassResource
    primarykey
    data
    text
    <p>I'm trying to use the Vaadin ClassResource class to load my database connection properties from a file that will be deployed with the WAR, but I can't seem to find the file. I am using Vaadin 6.5.2, Tomcat 7.0.6, and I've placed my "app.properties" file in the same package as my Application main file.</p> <p>My code is in Scala. Here's what I try:</p> <pre><code>val cr = new ClassResource("app.properties",this) // "this" is the application debug("resource mimeType = {}",cr.getMIMEType) debug("resource bufferSize = {}", cr.getBufferSize) debug("resource cacheTime = {}",cr.getCacheTime) debug("resource fileName = {}", cr.getFilename) val ds = cr.getStream if (ds != null) { debug("download stream bufferSize = {}", ds.getBufferSize) debug("download stream cacheTime = {}",ds.getCacheTime) val is = ds.getStream // get InputStream if (is != null) { val props = new Properties props.load(is) val dbHost = props.get("db.host").asInstanceOf[String] val dbName = props.get("db.name").asInstanceOf[String] val dbPort = props.get("db.port").asInstanceOf[String] val dbUser = props.get("db.user").asInstanceOf[String] val dbPass = props.get("db.pass").asInstanceOf[String] val dbUri = props.get("db.uri").asInstanceOf[String] } else { debug("Input stream was null") } } else { debug("Download stream was null") } </code></pre> <p>And here is the result:</p> <pre><code>08:51:59.617 ["http-bio-8084"-exec-11] DEBUG c.sentientswarm.propdesk.AppConfig$ - resource mimeType = application/octet-stream 08:51:59.620 ["http-bio-8084"-exec-11] DEBUG c.sentientswarm.propdesk.AppConfig$ - resource bufferSize = 0 08:51:59.621 ["http-bio-8084"-exec-11] DEBUG c.sentientswarm.propdesk.AppConfig$ - resource cacheTime = 86400000 08:51:59.621 ["http-bio-8084"-exec-11] DEBUG c.sentientswarm.propdesk.AppConfig$ - resource fileName = app.properties 08:51:59.621 ["http-bio-8084"-exec-11] DEBUG c.sentientswarm.propdesk.AppConfig$ - download stream bufferSize = 0 08:51:59.621 ["http-bio-8084"-exec-11] DEBUG c.sentientswarm.propdesk.AppConfig$ - download stream cacheTime = 86400000 08:51:59.621 ["http-bio-8084"-exec-11] DEBUG c.sentientswarm.propdesk.AppConfig$ - Input stream was null </code></pre> <p>I've tried placing the config file in various locations including the top of src, inside the top of the VAADIN folder that holds themes, and where it currently is (in the same package as the main Application), but the results are always the same. Can anyone tell me what I'm doing wrong???</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload