Reputation: 59996
When I deploy my web application witch use JDBC Connection pool and JNDI with Netbeans, this both created automaticly in Glassfish.
When I use Maven to create the same application, the JDBC Connection pool and JNDI not create automaticly and show me this error:
Error
Grave: Exception while preparing the app : Invalid resource : moduleJNDI__pm
java.lang.RuntimeException: Invalid resource : moduleJNDI__pm
I know the solution of this error, I just create the JNDI manualy.
My Question is: is there any solution or configuration to create the JNDI automaticly in the server Glassfish like the ordinary application, or is that a problem with Maven.
N.B
I use the server: Glassfish 3.1.2.2, Netbeans 8.1
Thank you.
Upvotes: 1
Views: 737
Reputation: 20208
Create a glassfish-resources.xml
file to define your database connection and make sure it ends up in your WEB-INF
folder. You could just put it there as a static file, but in most projects I work on I need a different connection in development. You could use the Maven WAR plugin to take care of that (handling it as a filterable resource). For example, create the glassfish-resources.xml
in your project at /src/main/resources_WEB-INF
. Now you can put it in your WEB-INF
folder when you build your project. See this pom.xml
fragment:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<webResources>
<resource>
<directory>${basedir}/src/main/resources_WEB-INF</directory>
<filtering>true</filtering>
<targetPath>WEB-INF</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
See also
Upvotes: 1