- This topic has 5 replies, 2 voices, and was last updated 14 years, 5 months ago by Stephen Wick.
-
AuthorPosts
-
Stephen WickMemberI am using MyEclipse 8.5 on Windows XP SP3.
It’s a new, stock installation – I only added the Subclipse 1.6 project.
I checked my maven webapp out from subversion.
I right clicked on my project and selected Enable Dependency Management.
My project’s /src/main/resources folder contains unfiltered property files. They must be filtered with the process-resources goal before they are usable.Problem(s)
1) Eclipse adds /src/main/resources as a source folder. This cannot happen, because the files contain tokens (${variableName}) that must be filtered before being deployed to an application server (tomcat 5.5) for testing.
2) I manually removed /src/main/resources from the Source Folder list, ran Project > Clean, and then clicked on Run As > Maven Build (I set the goals field to process-resources), and it still does not copy the filtered files to the outputDirectory /src/main/webapp/WEB-INF/classes. It copies the unfiltered files there. I have no idea how it is doing this.It would be really nice if MyEclipse would not add /src/main/resources to the Source folder list, but instead it would run process-resources after every internal build. That would put all the classes and filtered resources into the WEB-INF/classes folder, so that when we deploy the project to a Tomcat 5.5 server, MyEclipse will copy all of the files needed for the webapp to run.
Please let me know if there is a way to work around this problem, or if you will fix it. We could really use your help getting maven web projects with filtered resources to deploy to a local tomcat server.
Oh, btw, Spring is here!
Cheers!
+Stephen
Stephen WickMemberAlso, I have tried using the embedded Maven 3.0-SNAPSHOT, and our own external 2.2.1. No change.
Brian FernandesModeratorStephen,
Are you able to do this if you run Maven outside MyEclipse? I’m not a Maven expert so am wondering if this is either a bug in Maven or in the way your process-resources goal?
I will also get our Maven dev to take a look at this problem, if you can post your pom.xml or any Maven components that are specific to your project here, that would help a great deal.
Stephen WickMemberYes. when I run ‘mvn clean compile process-resources’ it places the class files and the filtered property files into /src/main/webapp/WEB-INF/classes. Then when I deploy the project to a tomcat 5.5 server, using eclipse, all the right files get deployed and the application starts up nicely.
Our pom.xml (some details have been removed to protect the privacy and security of our client)
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.WEBSITE</groupId> <artifactId>www</artifactId> <packaging>war</packaging> <version>2.9-SNAPSHOT</version> <name>com.WEBSITE.www</name> <url>http://www.WEBSITE.com</url> <prerequisites> <maven>2.0.0</maven> </prerequisites> <scm> <connection>scm:svn:https://svn.SHOP.com/svn/root/CLIENT/com.WEBSITE/trunk/</connection> <developerConnection>scm:svn:https://svn.SHOP.com/svn/root/CLIENT/com.WEBSITE/trunk/</developerConnection> </scm> <ciManagement> <system>continuum</system> <url>http://continuum.SHOP.com/continuum</url> <notifiers> <notifier> <type>mail</type> <sendOnError>true</sendOnError> <sendOnFailure>true</sendOnFailure> <sendOnSuccess>true</sendOnSuccess> <sendOnWarning>false</sendOnWarning> <configuration> <address> USER@SHOP.com </address> </configuration> </notifier> </notifiers> </ciManagement> <issueManagement> <system>JIRA</system> <url>http://jira.SHOP.com/browse/CLIENT_WEBSITE</url> </issueManagement> <developers> <developer> <id>USERNAME</id> <name>FULL_NAME</name> <email>USER@SHOP.com</email> </developer> </developers> <build> <defaultGoal>install</defaultGoal> <!-- Set the outputDirectory below, so that the 'process-resources' goal will put the resources into the webapp, so that MyEclipse can autodeploy them to Tomcat. --> <outputDirectory>src/main/webapp/WEB-INF/classes</outputDirectory> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> </resource> </resources> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>2.0.2</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> <plugin> <artifactId>maven-eclipse-plugin</artifactId> <version>2.5.1</version> <configuration> <additionalProjectnatures> <projectnature>org.maven.ide.eclipse.maven2Nature</projectnature> <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature> <projectnature>com.genuitec.eclipse.j2eedt.core.webnature</projectnature> <projectnature>org.eclipse.wst.jsdt.core.jsNature</projectnature> </additionalProjectnatures> <additionalBuildcommands> <buildcommand>org.maven.ide.eclipse.maven2Builder</buildcommand> <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand> <buildcommand>com.genuitec.eclipse.j2eedt.core.WebClasspathBuilder</buildcommand> <buildcommand>org.eclipse.wst.jsdt.core.javascriptValidator</buildcommand> <buildcommand>com.genuitec.eclipse.j2eedt.core.DeploymentDescriptorValidator</buildcommand> <buildcommand>com.genuitec.eclipse.j2eedt.core.J2EEProjectValidator</buildcommand> </additionalBuildcommands> <additionalConfig> <file> <name>.mymetadata</name> <content><![CDATA[<?xml version="1.0" encoding="UTF-8"?> <project-module type="WEB" name="com.SHOP" id="myeclipse.1252947228693" context-root="/ROOT" j2ee-spec="5.0" archive="ROOT.war"> <attributes> <attribute name="webrootdir" value="src/main/webapp" /> </attributes> </project-module>]]></content> </file> </additionalConfig> <downloadSources>true</downloadSources> <downloadJavadocs>true</downloadJavadocs> <wtpversion>1.5</wtpversion> </configuration> </plugin> <plugin> <artifactId>maven-idea-plugin</artifactId> <version>2.1</version> <configuration> <downloadSources>true</downloadSources> <downloadJavadocs>true</downloadJavadocs> <dependenciesAsLibraries>true</dependenciesAsLibraries> <useFullNames>false</useFullNames> </configuration> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>cobertura-maven-plugin</artifactId> <version>2.3</version> </plugin> <plugin> <groupId>org.codehaus.cargo</groupId> <artifactId>cargo-maven2-plugin</artifactId> <configuration> <container> <containerId>tomcat5x</containerId> <type>remote</type> </container> <configuration> <type>runtime</type> <properties> <cargo.tomcat.manager.url> http://localhost:9080/manager </cargo.tomcat.manager.url> <cargo.remote.username> admin </cargo.remote.username> <cargo.remote.password> admin </cargo.remote.password> </properties> </configuration> <deployer> <type>remote</type> <deployables> <deployable> <groupId> CLIENT.WEBSITE </groupId> <artifactId> webapp </artifactId> <type>war</type> </deployable> </deployables> </deployer> </configuration> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>tomcat-maven-plugin</artifactId> <version>1.0-beta-1</version> <configuration> <server>tomcat</server> <path>/</path> </configuration> </plugin> <plugin> <artifactId>maven-release-plugin</artifactId> <version>2.0-beta-9</version> <configuration> <!-- During release:perform, enable the "release" profile --> <releaseProfiles>release</releaseProfiles> </configuration> </plugin> </plugins> </build> <repositories> <repository> <id>central</id> <url>http://repo1.maven.org/maven2</url> </repository> <repository> <id>NK</id> <url>http://maven.SHOP.com</url> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>NK</id> <url>http://maven.SHOP.com</url> </pluginRepository> </pluginRepositories> <dependencies> <dependency> <groupId>bouncycastle</groupId> <artifactId>bcprov-jdk15</artifactId> <version>133</version> </dependency> <dependency> <groupId>com.lowagie</groupId> <artifactId>itext</artifactId> <version>1.4.8</version> </dependency> <dependency> <groupId>com.nkics</groupId> <artifactId>CLIENT.platform</artifactId> <version>1.19</version> <exclusions> <exclusion> <groupId>aopalliance</groupId> <artifactId>aopalliance</artifactId> </exclusion> <exclusion> <groupId>asm</groupId> <artifactId>asm</artifactId> </exclusion> <exclusion> <groupId>asm</groupId> <artifactId>asm-attrs</artifactId> </exclusion> <exclusion> <groupId>cglib</groupId> <artifactId>cglib</artifactId> </exclusion> <exclusion> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-impl</artifactId> </exclusion> <exclusion> <groupId>commons-csv</groupId> <artifactId>commons-csv</artifactId> </exclusion> <exclusion> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> </exclusion> <exclusion> <groupId>javax.xml.bind</groupId> <artifactId>jsr173_api</artifactId> </exclusion> <exclusion> <groupId>junit</groupId> <artifactId>junit</artifactId> </exclusion> <exclusion> <groupId>net.sf.ehcache</groupId> <artifactId>ehcache</artifactId> </exclusion> <exclusion> <groupId>tomcat</groupId> <artifactId>catalina</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.octo.captcha</groupId> <artifactId>jcaptcha-all</artifactId> <version>1.0-RC6</version> <exclusions> <exclusion> <groupId>net.sf.ehcache</groupId> <artifactId>ehcache</artifactId> </exclusion> <exclusion> <groupId>hsqldb</groupId> <artifactId>hsqldb</artifactId> </exclusion> <exclusion> <groupId>quartz</groupId> <artifactId>quartz</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.whirlycott</groupId> <artifactId>whirlycache</artifactId> <version>0.7.1</version> </dependency> <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>1.1.1</version> <exclusions> <exclusion> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> <version>2.1</version> </dependency> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>1.1.1</version> </dependency> <dependency> <groupId>dom4j</groupId> <artifactId>dom4j</artifactId> <version>1.6.1</version> </dependency> <dependency> <groupId>jakarta-regexp</groupId> <artifactId>jakarta-regexp</artifactId> <version>1.4</version> </dependency> <dependency> <groupId>javax.activation</groupId> <artifactId>activation</artifactId> <version>1.1</version> </dependency> <dependency> <groupId>javax.mail</groupId> <artifactId>mail</artifactId> <version>1.4.1</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.4</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.transaction</groupId> <artifactId>jta</artifactId> <version>1.1</version> </dependency> <dependency> <groupId>javax.xml</groupId> <artifactId>jaxrpc-api</artifactId> <version>1.1</version> </dependency> <dependency> <groupId>javax.xml.soap</groupId> <artifactId>saaj-api</artifactId> <version>1.3</version> </dependency> <dependency> <groupId>jstl</groupId> <artifactId>jstl</artifactId> <version>1.1.2</version> </dependency> <dependency> <groupId>jsptags</groupId> <artifactId>pager-taglib</artifactId> <version>2.0</version> </dependency> <dependency> <groupId>jzonic</groupId> <artifactId>jzonic</artifactId> <version>1.0</version> </dependency> <dependency> <groupId>lucene</groupId> <artifactId>lucene</artifactId> <version>1.4.3</version> </dependency> <dependency> <groupId>mvnforum</groupId> <artifactId>myvietnam</artifactId> <version>2.0.1</version> </dependency> <dependency> <groupId>net.sourceforge.jtds</groupId> <artifactId>jtds</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>org.acegisecurity</groupId> <artifactId>acegi-security</artifactId> <version>1.0.4</version> <exclusions> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring-remoting</artifactId> </exclusion> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> </exclusion> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring-support</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-io</artifactId> <version>1.3.2</version> </dependency> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts-tiles</artifactId> <version>1.3.8</version> <exclusions> <exclusion> <groupId>commons-chain</groupId> <artifactId>commons-chain</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>oro</groupId> <artifactId>oro</artifactId> <version>2.0.8</version> </dependency> <dependency> <groupId>taglibs</groupId> <artifactId>standard</artifactId> <version>1.1.2</version> </dependency> <dependency> <groupId>xml-security</groupId> <artifactId>xmlsec</artifactId> <version>1.3.0</version> </dependency> <dependency> <groupId>wsdl4j</groupId> <artifactId>wsdl4j</artifactId> <version>1.5.1</version> </dependency> <dependency> <groupId>wss4j</groupId> <artifactId>wss4j</artifactId> <version>1.5.1</version> </dependency> </dependencies> <!-- You can override these properties with your IDE if you need different behavior when developing. --> <properties> <continuum.project.nextBuild.number /> <jmock.version>2.4.0</jmock.version> <junit.version>4.4</junit.version> <log4j.version>1.2.13</log4j.version> <spring.version>2.0.7</spring.version> <wiser.version>1.2</wiser.version> <log4j.rootLogger>ERROR, default</log4j.rootLogger> <log4j.logger.com.mchange.v2.c3p0>ERROR</log4j.logger.com.mchange.v2.c3p0> <log4j.logger.org.apache.commons>ERROR</log4j.logger.org.apache.commons> <log4j.logger.org.hibernate>ERROR</log4j.logger.org.hibernate> <log4j.logger.org.hibernate.SQL>ERROR</log4j.logger.org.hibernate.SQL> <log4j.logger.net.sf.ehcache>ERROR</log4j.logger.net.sf.ehcache> <log4j.logger.org.springframework>ERROR</log4j.logger.org.springframework> <log4j.logger.org.apache.velocity.app.VelocityEngine>ERROR</log4j.logger.org.apache.velocity.app.VelocityEngine> <log4j.logger.org.apache.jasper>ERROR</log4j.logger.org.apache.jasper> <log4j.logger.org.apache.catalina>ERROR</log4j.logger.org.apache.catalina> <log4j.logger.org.apache.struts.tiles>ERROR</log4j.logger.org.apache.struts.tiles> <log4j.logger.org.acegisecurity>ERROR</log4j.logger.org.acegisecurity> <log4j.logger.org.jgroups>ERROR</log4j.logger.org.jgroups> <log4j.logger.com.opensymphony.oscache.plugins.clustersupport>ERROR</log4j.logger.com.opensymphony.oscache.plugins.clustersupport> <hibernate.format_sql>true</hibernate.format_sql> </properties> <distributionManagement> <repository> <id>continuum</id> <name>continuum</name> <url>file:///home/continuum/.m2/repository</url> <layout>default</layout> </repository> </distributionManagement> </project>
And here is the file /src/main/resources/log4j.properties
# # Log4j Configuration # # WARNING! Be Careful with this file. Setting the log level to DEBUG for the XML, SOAP and WebService libraries # can degrade performance dramatically!!! # log4j.rootLogger=${log4j.rootLogger} log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console.layout=org.apache.log4j.PatternLayout log4j.appender.console.layout.ConversionPattern=%d %p [%c] - %m%n log4j.appender.default=org.apache.log4j.DailyRollingFileAppender log4j.appender.default.File=/var/log/tomcat/CLIENT/CLIENT-WEBSITE.log log4j.appender.default.DatePattern='.'yyyy-MM-dd'.log' log4j.appender.default.layout=org.apache.log4j.PatternLayout log4j.appender.default.layout.ConversionPattern=%d %p [%c] - %m%n log4j.logger.com.mchange.v2.c3p0=${log4j.logger.com.mchange.v2.c3p0} log4j.logger.org.apache.commons=${log4j.logger.org.apache.commons} log4j.logger.org.hibernate=${log4j.logger.org.hibernate} log4j.logger.org.hibernate.SQL=${log4j.logger.org.hibernate.SQL} log4j.logger.net.sf.ehcache=${log4j.logger.net.sf.ehcache} log4j.logger.org.springframework=${log4j.logger.org.springframework} log4j.logger.org.apache.velocity.app.VelocityEngine=${log4j.logger.org.apache.velocity.app.VelocityEngine} log4j.logger.org.apache.jasper=${log4j.logger.org.apache.jasper} log4j.logger.org.apache.catalina=${log4j.logger.org.apache.catalina} log4j.logger.org.apache.struts.tiles=${log4j.logger.org.apache.struts.tiles} log4j.logger.org.acegisecurity=${log4j.logger.org.acegisecurity} log4j.logger.org.jgroups=${log4j.logger.org.jgroups} log4j.logger.com.opensymphony.oscache.plugins.clustersupport=${log4j.logger.com.opensymphony.oscache.plugins.clustersupport}
As you can see, log4j.properties cannot be used directly, because it contains variables (i.e. ${log4j.rootLogger}) which need to be replaced with actual values before the file can be used by tomcat to start the web application.
Let me know if you need any more information. I am glad to assist!
Cheers!
Brian FernandesModeratorStephen,
I believe you need to leave the src/main/resources folder as a source folder, not remove it as you have done.
When you run process-resources, the contents of that folder will be processed (variables will be substituted) and placed in the output classes folder; this is managed by a special builder in the project.
I hope this helps, please let us know how this goes.
Stephen WickMemberBrian,
I right-clicked on my Maven Web Project, and selected Maven4MyEclipse > Update Project Configuration. MyEclipse added /src/main/resources as a source folder, and then rebuilt the project. The output folder /src/main/webapp/WEB-INF/classes did not contain the files from /src/main/resources. So, I selected “Project > Clean…” from the menu at the top of the window, I checked the box next to my Web Maven Project, and then clicked “OK”. MyEclipse rebuilt the project, and placed the filtered text files from /src/main/resources into the output folder /src/main/webapp/WEB-INF/classes. My original issue is resolved. Thanks so much!
I wonder, is there any way to configure MyEclipse, so that it runs the process-resources goal without having to click on “Project > Clean…”?
-
AuthorPosts