users@glassfish.java.net

glassfish:run - Context initialization failed - class path resource

From: <glassfish_at_javadesktop.org>
Date: Thu, 18 Jun 2009 06:37:39 PDT

i got glassfish:run to work great on a simple project, but i have problem loading classpath resources with my maven2 spring/jpa project

my question is regarding where glassfish embedded server picks up configuration files. i use maven filters to enable different build environments for our application and use f.eks mvn glassfish:run -Denv=development and then apply filters in pom.xml like so:

in my src/main/filters/environment/development.properties i define variables like f.ex:
db.initialSize=2

in my pom.xml i use this to filter the resources in src/main/resources
<filter>src/main/filters/environment/${environment}.properties</filter>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>

and my properties in f.ex src/main/resources/myapp-dao-beans.xml are defined like this:
                <property name="initialSize" value="${db.initialSize}" />

This works great with jetty:run and tomcat:run, but with glassfish:run i get

org.springframework.web.context.ContextLoader initWebApplicationContext
SEVERE: Context initialization failed
exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [myapp-dao-beans.xml]: [java.lang.String] to required type [int] for property 'initialSize'; nested exception is java.lang.NumberFormatException: For input string: "${db.initialSize}"

So it seems like glassfish:run tries to load my properties from src/main/resources directly instead of loading the filtered resources from target/classes. Does anyone know how to configure glassfish embeddable to load the correct class path resources when initializing the webapplication context?

In my web.xml i use a org.springframework.web.context.ContextLoaderListener and the contextConfigLocation uses classpath:psk-dao-beans.xml

Any feedback is appreciated.

-+petrusnilsen+-
[Message sent by forum member 'petrusnilsen' (petrusnilsen)]

http://forums.java.net/jive/thread.jspa?messageID=351829