preslavrachev / maven-play-plugin

Automatically exported from code.google.com/p/maven-play-plugin
0 stars 0 forks source link

maven build error, while using log4j.properties file in svn controlled env. #108

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. build war file using the below command
mvn clean play:clean play:initialize play:precompile play:war ( by the way, 
should i need to specify everytime play:initialze play:precompile)
2.war will be created, but in the process, it would spit out the below error 
message
3. log configuration in application.conf
# Log level
# ~~~~~
# Specify log level for your application.
# If you want a very customized log, create a log4j.properties file in the conf 
directory
application.log=DEBUG
application.log.recordCaller=true
#
# More logging configuration

application.log.path=/log4j.properties
application.log.system.out=on

What is the expected output? What do you see instead?
Error free creation of war file.

What version of the product are you using? On what operating system?
Play 1.2.4, maven 2.2.1, linux

Please provide any additional information below.
Error message thrown
t java.io.FileOutputStream?.openAppend(Native Method) at 
java.io.FileOutputStream?.<init>(FileOutputStream?.java:177) at 
java.io.FileOutputStream?.<init>(FileOutputStream?.java:102) at 
org.apache.log4j.FileAppender?.setFile(FileAppender?.java:294) at 
org.apache.log4j.RollingFileAppender?.setFile(RollingFileAppender?.java:207) at 
org.apache.log4j.FileAppender?.activateOptions(FileAppender?.java:165) at 
org.apache.log4j.config.PropertySetter?.activate(PropertySetter?.java:307) at 
org.apache.log4j.config.PropertySetter?.setProperties(PropertySetter?.java:172) 
at 
org.apache.log4j.config.PropertySetter?.setProperties(PropertySetter?.java:104) 
at 
org.apache.log4j.PropertyConfigurator?.parseAppender(PropertyConfigurator?.java:
809) at 
org.apache.log4j.PropertyConfigurator?.parseCategory(PropertyConfigurator?.java:
735) at 
org.apache.log4j.PropertyConfigurator?.configureRootCategory(PropertyConfigurato
r?.java:615) at 
org.apache.log4j.PropertyConfigurator?.doConfigure(PropertyConfigurator?.java:50
2) at 
org.apache.log4j.PropertyConfigurator?.doConfigure(PropertyConfigurator?.java:54
7) at 
org.apache.log4j.helpers.OptionConverter?.selectAndConfigure(OptionConverter?.ja
va:483) at org.apache.log4j.LogManager?.<clinit>(LogManager?.java:127) at 
org.apache.log4j.PropertyConfigurator?.configure(PropertyConfigurator?.java:415)
 at play.Logger.init(Logger.java:79) at play.Play.init(Play.java:206) at 
play.server.Server.main(Server.java:159) at 
com.google.code.play.PlayServerBooter?.main(PlayServerBooter?.java:70) at 
sun.reflect.NativeMethodAccessorImpl?.invoke0(Native Method) at 
sun.reflect.NativeMethodAccessorImpl?.invoke(NativeMethodAccessorImpl?.java:39) 
at 
sun.reflect.DelegatingMethodAccessorImpl?.invoke(DelegatingMethodAccessorImpl?.j
ava:25) at java.lang.reflect.Method.invoke(Method.java:597) at 
org.apache.tools.ant.taskdefs.ExecuteJava?.run(ExecuteJava?.java:217) at 
org.apache.tools.ant.taskdefs.ExecuteJava?.execute(ExecuteJava?.java:152) at 
org.apache.tools.ant.taskdefs.Java.run(Java.java:771) at 
org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:221) at 
org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:135) at 
org.apache.tools.ant.taskdefs.Java.execute(Java.java:108) at 
com.google.code.play.AbstractAntJavaBasedPlayMojo?$JavaRunnable?.run(AbstractAnt
JavaBasedPlayMojo?.java:77) at java.lang.Thread.run(Thread.java:619)
log4j:ERROR setFile(null,true) call failed.

Original issue reported on code.google.com by martin.j...@gmail.com on 19 Jul 2012 at 8:37

Attachments:

GoogleCodeExporter commented 9 years ago
I reproduced your problem. I think you have file system permissions problem. 
Check it please.
"org.apache.log4j.RollingFileAppender" tries to open a file for writing, it 
fails with an IOException (in my case FileNotFoundException, in your case I 
don't know the exact exception class because you haven't pasted the beginning 
of the stack trace :) ).
This exception is caugth in "org.apache.log4j.FileAppender.activeteOptions()" 
method (see 
http://javasourcecode.org/html/open-source/log4j/log4j-1.2.16/org/apache/log4j/F
ileAppender.java.html line 167), stack trace is printed and the exception is 
not thrown again so neither Play! nor Maven plugin know anything about it.

This is not a bug in the plugin.

By the way:
1. don't run "mvn clean play:clean" goal if you have "play" packaging in your 
project. "play:clean" mojo it's bound to "clean" lifecycle, so "mvn clean" will 
execute "play:clean" internally.
2. add "play:precompile" and "play:war" to your pom.xml file instead of running 
them explicitely. "play:initialize" is already bound to the life cycle of 
"play" packaging. Look at this example 
http://maven-play-plugin.googlecode.com/svn/trunk/test-projects/packagings/war/u
sing-play-war/no-dependencies/pom.xml (I have created a profile for war 
packaging because I don't need it all the time).

Check your file system permissions again, please and report back here if I war 
right.

Original comment by gslowiko...@gmail.com on 30 Jul 2012 at 6:46

GoogleCodeExporter commented 9 years ago
This is the below error, i recieve.

War is build on staging box. Staging box doesn't have such path.  When
compiled war is moved to dev/qa env. It looks good.

log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: /home/mantis/logs/visualmetadata.log (No
such file or directory)
        at java.io.FileOutputStream.openAppend(Native Method)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:177)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:102)
        at org.apache.log4j.FileAppender.setFile(FileAppender.java:294)
        at
org.apache.log4j.RollingFileAppender.setFile(RollingFileAppender.java:207)
        at
org.apache.log4j.FileAppender.activateOptions(FileAppender.java:165)
        at
org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:307)
        at
org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:172)
        at
org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:104)
        at
org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:80
9)
        at
org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:73
5)
        at
org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator
.java:615)
        at
org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:502)
        at
org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:547)
        at
org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java
:483)
        at org.apache.log4j.LogManager.<clinit>(LogManager.java:127)
        at
org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:415)
        at play.Logger.init(Logger.java:79)
        at play.Play.init(Play.java:206)
        at play.server.Server.main(Server.java:159)
        at
com.google.code.play.PlayServerBooter.main(PlayServerBooter.java:70)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at
org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:217)
        at
org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:152)
        at org.apache.tools.ant.taskdefs.Java.run(Java.java:771)
        at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:221)
        at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:135)
        at org.apache.tools.ant.taskdefs.Java.execute(Java.java:108)
        at
com.google.code.play.AbstractAntJavaBasedPlayMojo$JavaRunnable.run(AbstractAntJa
vaBasedPlayMojo.java:77)
        at java.lang.Thread.run(Thread.java:619)
log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: /home/mantis/logs/visualmetadata.log (No
such file or directory)
        at java.io.FileOutputStream.openAppend(Native Method)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:177)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:102)
        at org.apache.log4j.FileAppender.setFile(FileAppender.java:294)
        at
org.apache.log4j.RollingFileAppender.setFile(RollingFileAppender.java:207)
        at
org.apache.log4j.FileAppender.activateOptions(FileAppender.java:165)
        at
org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:307)
        at
org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:172)
        at
org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:104)
        at
org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:80
9)
        at
org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:73
5)
        at
org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator
.java:615)
        at
org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:502)
        at
org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:547)
        at
org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:415)
        at play.Logger.init(Logger.java:79)
        at play.Play.init(Play.java:206)
        at play.server.Server.main(Server.java:159)
        at
com.google.code.play.PlayServerBooter.main(PlayServerBooter.java:70)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at
org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:217)
        at
org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:152)
        at org.apache.tools.ant.taskdefs.Java.run(Java.java:771)
        at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:221)
        at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:135)
        at org.apache.tools.ant.taskdefs.Java.execute(Java.java:108)
        at
com.google.code.play.AbstractAntJavaBasedPlayMojo$JavaRunnable.run(AbstractAntJa
vaBasedPlayMojo.java:77)
        at java.lang.Thread.run(Thread.java:619)
[INFO] [play:war {execution: default-cli}]

Original comment by martin.j...@gmail.com on 31 Jul 2012 at 1:43

GoogleCodeExporter commented 9 years ago
If I use profiles, I should create profile for each environment, is that
correct??

Original comment by martin.j...@gmail.com on 31 Jul 2012 at 1:45

GoogleCodeExporter commented 9 years ago
"War is build on staging box. Staging box doesn't have such path. When compiled 
war is moved to dev/qa env. It looks good."

Your above comment explains all. "play:precompile" starts Play!, Play! 
initializes Log4J, Log4J finds problem with nonexisting directory, reports it 
and goes on (this stacktrace is just a warning, not a real exception). This 
problem is not critical, war distribution is prepared properly.
When run in dev/qa environment with existing "/home/mantis/logs" directory 
everything works as expected.

Original comment by gslowiko...@gmail.com on 1 Aug 2012 at 7:53

GoogleCodeExporter commented 9 years ago
Answering to your question about profiles.

Create Maven profile if you think it makes sense. There is no golden rule.

1.
Define default profiles in properties:
<properties>
  <play.id>foo</play.id>
  <play.testId>test-foo</play.testId>
</properties>
or in plugin's configuration:
<build>
  <plugins>
    <plugin>
      <groupId>com.google.code.maven-play-plugin</groupId>
      <artifactId>play-maven-plugin</artifactId>
      <extensions>true</extensions>
      <configuration>
        <playId>foo</playId> <!-- plugin's default is empty -->
        <playTestId>test-foo</playTestId> <!-- plugin's default is "test" -->
      </configuration>
    </plugin>
  </plugins>
</build>
Both methods are proper.

You can change them dynamically with "-Dplay.id=bar" or 
"-Dplay.testId=test-bar" arguments in Maven invocation without defining Maven 
profiles.

Command line would look like "mvn <your commands here> -Dplay.id=bar 
-Dplay.testId=test-bar".

2.
You can create Maven profile for Play! profiles too:
<profiles>
  <profile>
    <id>bar</id>
    <build>
      <plugins>
        <plugin>
          <groupId>com.google.code.maven-play-plugin</groupId>
          <artifactId>play-maven-plugin</artifactId>
          <configuration>
            <playId>bar</playId>
            <playTestId>test-bar</playTestId>
          </configuration>
        </plugin>
      </plugins>
    </build>
  </profile>
</profiles>

Command line "mvn <your commands here> -Pbar" is simpler, but we have the same 
profiles defined in two files: pom.xml and conf/application.conf, and they have 
to be in sync.

3.
I often create Maven profiles for optional tasks, like war packaging. This has 
nothing to do with Play! profiles. Instead of calling "mvn clean 
play:initialize play:precompile play:war" I call "mvn clean package -Pdist" for 
example in 
http://maven-play-plugin.googlecode.com/svn/trunk/test-projects/packagings/war/u
sing-play-war/no-dependencies/pom.xml test project (in "dist" profile I have 
all mojos I need). I have a profile for this because I don't want war file to 
be created every time I call "mvn package".

4.
My another case - different profiles for different databases (Oracle in my 
case).
I have "ora" and "test-ora" Play! profiles defined (in conf/application.conf" 
file) with "db.[driver|url|user|pass]" properties and Maven "ora" profile 
defined like this:
<profiles>
  <profile>
    <id>ora</id>
    <properties>
      <play.id>ora</play.id>
      <play.testId>test-ora</play.testId>
    </properties>
    <dependencies>
      <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc14</artifactId>
        <version>10.2.0.3.0</version>
      </dependency>
    </dependencies>
  </profile>
</profiles>
In this case Oracle driver dependency and Play! profiles ("ora" and "test-ora") 
are defined in one place. Oracle driver dependency is used only if I use Oracle 
database. I need only add "-Pora" to Maven invocation. Because I use my Oracle 
database very often it's simplifies my life a lot.

Original comment by gslowiko...@gmail.com on 1 Aug 2012 at 8:31

GoogleCodeExporter commented 9 years ago
Do we agree that this issue is not a bug in a plugin? If so, I will close it.

Original comment by gslowiko...@gmail.com on 1 Aug 2012 at 8:33

GoogleCodeExporter commented 9 years ago
That's true, it's not a ciritical issue.  it works as expected but throws
up an unnecessary error.
But this error is not thrown when project is build in a windows environment.

Original comment by martin.j...@gmail.com on 1 Aug 2012 at 10:34

GoogleCodeExporter commented 9 years ago
I mean this is NOT plugin's issue, BUT your project's logging configuration 
issue.

Original comment by gslowiko...@gmail.com on 1 Aug 2012 at 2:06

GoogleCodeExporter commented 9 years ago
hmm.... staging env. can't mimic the where prod env.
Staging env. is where project is coded and built.  It can't have the same
file structure as in prod/qa.

Let's consider any webapp like restlet, struts.  Building them thr' maven
wouldn't throw such errors while building(like FileNotFoundException for
absence of log file).  Plugin shouldn't consider the presence of log file.

I still believe it's a plugin issue.

Original comment by martin.j...@gmail.com on 2 Aug 2012 at 1:37

GoogleCodeExporter commented 9 years ago
Don't you have the same problem if you run "play precompile" (pure Play!, 
without Maven)? I have. This means that this problem is not plugin, but Play! 
specific.

Original comment by gslowiko...@gmail.com on 2 Aug 2012 at 7:13

GoogleCodeExporter commented 9 years ago
One more info. For precompilation Play! initializes the whole engine (does not 
start http server), initializing logging is a part of this initialization.
My plugin runs precompilation in exactly the same way as Play!'s Python scripts 
do. If there are any problems with pure Play! precompilation ("play 
precompile"), they will be present in Maven plugin too ("mvn play:precompile").

Original comment by gslowiko...@gmail.com on 2 Aug 2012 at 7:30

GoogleCodeExporter commented 9 years ago
Got it, makes sense.  Thanks for the info.

Martin

Original comment by martin.j...@gmail.com on 2 Aug 2012 at 1:57

GoogleCodeExporter commented 9 years ago
Closing issue because it's not a plugin specific problem.

Original comment by gslowiko...@gmail.com on 3 Aug 2012 at 7:34