Serve Modules without publishing not working in Helios
Asked Answered
G

1

4

I have recently moved a webapp I have been developing to a new machine running 64bit Eclipse Helios (Service Release 2) and I am using Maven plugin M2Eclipse.

I have deployed on a local tomcat install through Eclipse and everything is ok (more or less), but I want to select the option "Serve Modules without publishing", but when I select this option I get errors:

log4j:ERROR Could not read configuration file from URL [file:/C:/butterfly/svn/trunk/micro/src/main/webapp/WEB-INF/classes/log4j.properties].
java.io.FileNotFoundException: C:\butterfly\svn\trunk\micro\src\main\webapp\WEB-INF\classes\log4j.properties (The system cannot find the file specified)

The log4j.properties file is not there, as in my source directories in lives in src/main/resources - at build it then gets copied over to target/WEB-INF/classes/..

Eclipse seems to be mixing the expected target directory with the src directory so not finding it.

Im not sure if this is happening for just the properties file or if the same problem will occur looking for all built resources.

I have seen these issues:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=318449

http://www.eclipse.org/forums/index.php?t=msg&goto=661045&S=25bafd85b11e042c169ecf1752bfa479

but they seem to be slightly different or already fixed (My Helios is a new download from last weekend)

Anyone experience this or know how to resolve?

Glycol answered 7/5, 2011 at 23:35 Comment(1)
What version of Tomcat are you using? I noticed this broke in my version of Eclipse when I moved to Tomcat 7, which seems to be confirmed by eclipse.org/forums/… . Apparently that was not fixed in Helios, as the last few comments indicate. So the workaround appears to be to go back to Tomcat 6...Ketchan
P
1

From here: "The Serve modules without publishing option does what it says. Web content will be served directly from the "WebContent" folder of the Dynamic Web Project. A customized context is used to make the project's dependencies available in the Web application's classloader". I would expect eclipse to emulate serving every class / resource file (including log4j.properties) from WEB-INF/classes after you build the project. As a workaround, what about creating a "classes" folder inside WebContent, copy log4j.properties file here and see if the classloader gets happy?

Picco answered 8/5, 2011 at 0:7 Comment(6)
Thanks for the response - unfortunately, none of the compiled classes are in the web content folder (as maven convention builds to /target/.. and all the source folders are /src/.. Also, prior to moving to Helios this worked fine in Galileo and I have worked with several maven projects selecting "serve modules without publishing" and eclipse has run them from the maven /target/.. directory - so do you know if this is just broken/removed or do I need an additional config step?Glycol
@Glycol I'm pretty sure it is something specific to your project that isn't playing nice with this feature custom classloader. You shouldn't need any extra config step. But, as i said before, try creating a classes folder inside WEB-INF and copying log4j.properties there.Picco
@Anthony, I created the classes folder inside src/main/webapp/WEB-INF and copied the log4j file, it then complained about persistence.xml, so I copied that over - it then works. Its very strange as there are other Spring XML config files in the same src folder (src/main/resources) as log4j but they were correctly being used from the target output folder.. any ideas?Glycol
@rhinds. Eclipse uses a custom ClassLoader do pull the "Serve Modules without publishing" trick. A lot of frameworks use their own ClassLoaders. Having them playing nice (even for things as simples as getting some classpath resource) is not a simple task. Since you are all set, I would go about opening / up voting bug and see if you are able to get enough quorum. Besides, there are other ways to achieve something similar. For example, you can create a custom context.xml to fit your needs.Picco
And since you are using maven, there are plugins that can do inplace deployment for Tomcat. Is there any reason you can't let maven manage deployment?Picco
Thanks Anthony, voting this as correct for the alternative options provided to achieve. Was hoping that it would just have worked as it did using Galileo rather than Helios, but nevermindGlycol

© 2022 - 2024 — McMap. All rights reserved.