Erik
Erik

Reputation: 2051

Configuring tomcat7 in Intellij 12 Ultimate

I have a web app using tomcat7 that I want to run from inside IDEA 12.

I've installed tomcat and configured it as app server in idea.
I've created the artifact (exploded war) and created a run configuration using tomcat.

Starting the run configuration works, the application is deployed and starts fine.

The problem is that I have a context file (tomcat-context.xml) that contains a whole bunch of datasources and I can't seem to get the web app to find that context file.

I have added it in META-INF/ (in the artefact window) and when I look in the output directory I can see that the file is there (with the correct contents).
I've tried setting the tomcat context descriptor (in the web facet page), using the application context field Run configuration::Deployment tab and nothing worked.

I've checked the location where idea puts the exploded war and the context file is there albeit with a strange name.

When I run the web app with maven (mvn tomcat7:run) it works perfectly. The pom contains this line:

<contextFile>src/test/config/tomcat-context.xml</contextFile>

and it's this behaviour I want to replicate.

I'm at my wits end here and open for any ideas.

Upvotes: 2

Views: 8886

Answers (1)

longhua
longhua

Reputation: 4242

In Artifacts -> Output Layout, you can rename a file. During deployment, it will copy the file and rename it.

Since usually Context elements should be in META-INF/context.xml, so just add tomcat-context.xml and rename it to context.xml.

Upvotes: 4

Related Questions