tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Knute Snortum <kSnor...@catalystitservices.com>
Subject RE: tomcat7-maven-plugin doesn't understand Maven filtering of context files?
Date Tue, 28 Aug 2012 22:57:45 GMT


> -----Original Message-----
> From: Olivier Lamy [mailto:olamy@apache.org]
> Sent: Tuesday, August 28, 2012 2:17 PM
> To: Tomcat Users List
> Subject: Re: tomcat7-maven-plugin doesn't understand Maven filtering of
> context files?
> 
> Hi,
> Inline
> 
> 2012/8/28 Knute Snortum <kSnortum@catalystitservices.com>:
> > If this is the wrong mailing list for tomcat7-maven-plugin, could
> someone direct me to the right place?
> >
> > I'm developing a Vaadin web app in Eclipse Juno on Windows 7 and I'm
> using the tomcat7-maven-plugin 2.0-beta-1 to help in development by
> running the app in Tomcat inside of the IDE -- or I'm trying.  The error
> I'm getting is:
> >
> > org.springframework.beans.factory.BeanDefinitionStoreException:
> > Invalid bean definition with name 'dataSource' defined in
> > ServletContext resource [/WEB-INF/applicationContext.xml]: Could not
> > resolve placeholder 'db.driverClassName' in string value
> > [${db.driverClassName}]
> >
> > "applicationContext.xml" is my Spring context file.  I have
> placeholders in it to point to the correct database based on Maven
> profiles and filtering.  So a piece of applicationContext.xml looks like
> this:
> >
> >         <bean id="dataSource"
> class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
> >                 <property name="driverClassName"
> value="${db.driverClassName}" />
> >                 <property name="url"             value="${db.url}" />
> >                 <property name="username"
> value="${db.username}" />
> >                 <property name="password"
> value="${db.password}" />
> >                 <property name="maxActive"       value="10" />
> >                 <property name="maxIdle"         value="1" />
> >         </bean>
> >
> > As you can see, Tomcat (or Spring?) is finding the dataSource bean
> that does not have the placeholders replaced yet.
> >
> > The odd thing is that in the war file and the directory under target
> that the war file is created from, all the place holders have been
> correctly substituted.  I can see them in an editor.  The context file
> with the placeholders is the one still sitting in my development folder.
> >
> > So my question is, why isn't the Tomcat plugin seeing the context file
> in the war file or folder?  And if it looks in the development folder
> for the file, can Maven filtering work with the plugin?.
> >
> as you are using gwt maven plugin, I'm not sure that works.
> Something you can do is using sys properties in tomcat7/6-maven-plugin
> (spring placeholder resolves against sys props too).
> Add you sys props as it:
> http://tomcat.apache.org/maven-plugin-2.0-SNAPSHOT/tomcat6-maven-
> plugin/examples/add-system-properties.html

Well, I'm using Maven filtering, and the reason for that is my client requires that I use
Maven profiling to set the development and the production environments.  So I'd have to a
Maven Tomcat plugin in each profile -- which maybe I'll do.

I need the GWT plugin because this is a Vaadin project and Vaadin uses GWT.
 
> > Below is part of the messages created by Maven et al in my IDE
> console.  I've left out the clean and testing messages and most of the
> stacktrace, which I think is from Spring anyway:
> >
> > [INFO]
> > [INFO] --- gwt-maven-plugin:2.4.0:compile (default) @ dpt --- [INFO]
> > auto discovered modules
> > [com.catalystitservices.nike.dpt.widgetset.DptWidgetset]
> > [INFO] com.catalystitservices.nike.dpt.widgetset.DptWidgetset is up to
> > date. GWT compilation skipped [INFO] [INFO] ---
> > maven-war-plugin:2.2:war (default-war) @ dpt --- [INFO] Packaging
> > webapp [INFO] Assembling webapp [dpt] in [C:\Projects\DPT\target\dpt]
> > [INFO] Processing war project [INFO] Copying webapp webResources
> > [C:\Projects\DPT\src/main/webapp/] to [C:\Projects\DPT\target\dpt]
> > [INFO] Copying webapp resources [C:\Projects\DPT\src\main\webapp]
> > [INFO] Webapp assembled in [1442 msecs] [INFO] Building war:
> > C:\Projects\DPT\target\dpt.war [INFO] [INFO] ---
> > tomcat7-maven-plugin:2.0-beta-1:exec-war-only (tomcat-run) @ dpt ---
> > [INFO] [INFO] --- maven-install-plugin:2.3.1:install (default-install)
> > @ dpt --- [INFO] Installing C:\Projects\DPT\target\dpt.war to
> > C:\Users\ksnortum\.m2\repository\com\nike\dpt\dpt\1.1-SNAPSHOT\dpt-1.1
> > -SNAPSHOT.war [INFO] Installing C:\Projects\DPT\pom.xml to
> > C:\Users\ksnortum\.m2\repository\com\nike\dpt\dpt\1.1-SNAPSHOT\dpt-1.1
> > -SNAPSHOT.pom [INFO] Installing
> > C:\Projects\DPT\target\dpt-1.1-SNAPSHOT-war-exec.jar to
> > C:\Users\ksnortum\.m2\repository\com\nike\dpt\dpt\1.1-SNAPSHOT\dpt-1.1
> > -SNAPSHOT-exec-war.jar
> > [INFO]
> > [INFO] >>> tomcat-maven-plugin:1.1:run (default-cli) @ dpt >>>
> 
> you are using an old version here ? Don't you have duplicate entries in
> your pom ?

There's no duplicate.  The one I have looks like this:

	<plugin>
		<groupId>org.apache.tomcat.maven</groupId>
		<artifactId>tomcat7-maven-plugin</artifactId>
		<version>${tomcat7MavenPlugin}</version>
		...

And my properties look like:

	<tomcat7MavenPlugin>2.0-beta-1</tomcat7MavenPlugin>

> 
> > [INFO]
> > [INFO] --- maven-resources-plugin:2.5:resources (default-resources) @
> > dpt --- [debug] execute contextualize [INFO] Using 'UTF-8' encoding to
> > copy filtered resources.
> > [INFO] Copying 3 resources
> > [INFO] Copying 3 resources
> > [INFO]
> > [INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ dpt
> > --- [INFO] Nothing to compile - all classes are up to date [INFO]
> > [INFO] <<< tomcat-maven-plugin:1.1:run (default-cli) @ dpt <<<
[INFO]
> > [INFO] --- tomcat-maven-plugin:1.1:run (default-cli) @ dpt --- [INFO]
> > Running war on http://localhost:8080/dpt [INFO] Creating Tomcat server
> > configuration at C:\Projects\DPT\target\tomcat Aug 28, 2012 10:13:59
> > AM org.apache.catalina.startup.Embedded start
> > INFO: Starting tomcat server
> > Aug 28, 2012 10:14:00 AM org.apache.catalina.core.StandardEngine start
> > INFO: Starting Servlet Engine: Apache Tomcat/6.0.29 Aug 28, 2012
> > 10:14:00 AM org.apache.catalina.core.ApplicationContext log
> > INFO: Set web app root system property: 'webapp.root' =
> > [C:\Projects\DPT\src\main\webapp\]
> > Aug 28, 2012 10:14:00 AM org.apache.catalina.core.ApplicationContext
> > log
> > INFO: Initializing log4j from [classpath:log4j.properties] Aug 28,
> > 2012 10:14:00 AM org.apache.catalina.core.ApplicationContext log
> > INFO: Initializing Spring root WebApplicationContext
> > 28.08.2012 10:14:00 INFO  (ContextLoader.java:272) - Root
> > WebApplicationContext: initialization started
> > 28.08.2012 10:14:00 INFO  (AbstractApplicationContext.java:500) -
> > Refreshing Root WebApplicationContext: startup date [Tue Aug 28
> > 10:14:00 PDT 2012]; root of context hierarchy
> > 28.08.2012 10:14:00 INFO  (XmlBeanDefinitionReader.java:315) - Loading
> > XML bean definitions from ServletContext resource
> > [/WEB-INF/applicationContext.xml]
> > 28.08.2012 10:14:01 INFO  (XmlBeanDefinitionReader.java:315) - Loading
> > XML bean definitions from ServletContext resource
> > [/WEB-INF/applicationContext-security.xml]
> > 28.08.2012 10:14:01 INFO  (SpringSecurityCoreVersion.java:33) - You
> > are running with Spring Security Core 3.1.0.RELEASE
> > 28.08.2012 10:14:01 INFO  (SecurityNamespaceHandler.java:57) - Spring
> > Security 'config' module version is 3.1.0.RELEASE
> > 28.08.2012 10:14:01 INFO  (HttpSecurityBeanDefinitionParser.java:229)
> > - Checking sorted filter chain: [Root bean: class
> > [org.springframework.security.web.context.SecurityContextPersistenceFi
> > lter]; scope=; abstract=false; lazyInit=false; autowireMode=0;
> > dependencyCheck=0; autowireCandidate=true; primary=false;
> > factoryBeanName=null; factoryMethodName=null; initMethodName=null;
> > destroyMethodName=null, order = 300, Root bean: class
> > [org.springframework.security.web.authentication.logout.LogoutFilter];
> > scope=; abstract=false; lazyInit=false; autowireMode=0;
> > dependencyCheck=0; autowireCandidate=true; primary=false;
> > factoryBeanName=null; factoryMethodName=null; initMethodName=null;
> > destroyMethodName=null, order = 400,
> > <org.springframework.security.web.authentication.UsernamePasswordAuthe
> > nticationFilter#0>, order = 800, Root bean: class
> > [org.springframework.security.web.authentication.www.BasicAuthenticati
> > onFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0;
> > dependencyCheck=0; autowireCandidate=true; primary=false;
> > factoryBeanName=null; factoryMethodName=null; initMethodName=null;
> > destroyMethodName=null, order = 1200, Root bean: class
> > [org.springframework.security.web.savedrequest.RequestCacheAwareFilter
> > ]; scope=; abstract=false; lazyInit=false; autowireMode=0;
> > dependencyCheck=0; autowireCandidate=true; primary=false;
> > factoryBeanName=null; factoryMethodName=null; initMethodName=null;
> > destroyMethodName=null, order = 1300, Root bean: class
> > [org.springframework.security.web.servletapi.SecurityContextHolderAwar
> > eRequestFilter]; scope=; abstract=false; lazyInit=false;
> > autowireMode=0; dependencyCheck=0; autowireCandidate=true;
> > primary=false; factoryBeanName=null; factoryMethodName=null;
> > initMethodName=null; destroyMethodName=null, order = 1400, Root bean:
> > class
> > [org.springframework.security.web.authentication.AnonymousAuthenticati
> > onFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0;
> > dependencyCheck=0; autowireCandidate=true; primary=false;
> > factoryBeanName=null; factoryMethodName=null; initMethodName=null;
> > destroyMethodName=null, order = 1700, Root bean: class
> > [org.springframework.security.web.session.SessionManagementFilter];
> > scope=; abstract=false; lazyInit=false; autowireMode=0;
> > dependencyCheck=0; autowireCandidate=true; primary=false;
> > factoryBeanName=null; factoryMethodName=null; initMethodName=null;
> > destroyMethodName=null, order = 1800, Root bean: class
> > [org.springframework.security.web.access.ExceptionTranslationFilter];
> > scope=; abstract=false; lazyInit=false; autowireMode=0;
> > dependencyCheck=0; autowireCandidate=true; primary=false;
> > factoryBeanName=null; factoryMethodName=null; initMethodName=null;
> > destroyMethodName=null, order = 1900,
> > <org.springframework.security.web.access.intercept.FilterSecurityInter
> > ceptor#0>, order = 2000]
> > 28.08.2012 10:14:01 INFO  (PropertiesLoaderSupport.java:177) - Loading
> > properties file from file
> > [C:\Projects\DPT\target\classes\log4j.properties]
> > 28.08.2012 10:14:01 INFO  (DefaultSingletonBeanRegistry.java:433) -
> > Destroying singletons in
> > org.springframework.beans.factory.support.DefaultListableBeanFactory@3
> > 78c3efb: defining beans
> > [org.springframework.context.support.PropertySourcesPlaceholderConfigu
> > rer#0,<long list of beans removed>]; root of factory hierarchy
> > 28.08.2012 10:14:01 ERROR (ContextLoader.java:307) - Context
> > initialization failed
> > org.springframework.beans.factory.BeanDefinitionStoreException:
> > Invalid bean definition with name 'dataSource' defined in
> > ServletContext resource [/WEB-INF/applicationContext.xml]: Could not
> > resolve placeholder 'db.driverClassName' in string value
> > [${db.driverClassName}]
> >
> > ---
> > Knute Snortum
> > Developer
> > Catalyst IT Services
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> 
> 
> 
> --
> Olivier Lamy
> Talend: http://coders.talend.com
> http://twitter.com/olamy | http://linkedin.com/in/olamy
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message