[Mifos-developer] remove freemarker-2.3.8.jar from target folder so as to ensure freemarker-2.3.16.jar is being used

78 views
Skip to first unread message

Jasmine sandhu

unread,
Oct 21, 2010, 3:34:41 AM10/21/10
to Mifos software development
Hi,

I'm getting a strange error from freemarker when trying to do a spring bind. I think the problem I'm seeing maybe because we have two versions of freemaker in the mifos-webapp and I think it may not be using the latest version.

target/mifos-webapp/WEB-INF/lib/freemarker-2.3.16.jar
target/mifos-webapp/WEB-INF/lib/freemarker-2.3.8.jar

How does SpringMVC know which freemarker jar file to use? I wanted to test this theory by removing freemarker-2.3.8.jar but every time I build it, it automatically gets freemarker-2.3.8.jar. I looked for this in the pom files but could not find any reference to 2.3.8. Do we want this older version of freemarker? How can I make it so this older version is not downloaded to ensure that the mifos application is in fact using the 2.3.16 version of freemarker?

Thank you,
Jasmine


Here's the actual problem I'm seeing:
========================================
I'm getting a strange error from freemarker when trying to do a spring bind.

Here's my freemarker code:
[@spring.bind "formBean.showStatus"/]
${spring.status.expression} <br />
${spring.status.value}

${spring.status.expression} should display showStatus and this works as expected.
${spring.status.value} and ${spring.status.value?default([""])} should display the data contained in the showStatus field for the form backed object and this is obtained via the getshowStatus method that is defined for this object. Here I get the following error:

Error on line 103, column 35 in editAdminDocs.ftl. Expecting a string, date or number here, Expression spring.status.value is instead a freemarker.template.SimpleSequence

Now my showStatus field is defined as a list:
List<String> showStatus = new ArrayList<String>();

However, I expect freemarker to still display the quantities contained in the list as a string separated by commas. I have a separate sandbox (learnspringftl application) in which I play around with SpringMVC/Freemarker and it executes the same code and freemarker displays the contents as a string just fine.

I've narrowed my problem down to the fact that in the learnspringftl application, after compilation, I only have freemarker-2.3.16.jar so
target/learnsprinftl/WEB-INF/lib/freemarker-2.3.16.jar

where as the mifos application contains:
target/mifos-webapp/WEB-INF/lib/freemarker-2.3.16.jar and
target/mifos-webapp/WEB-INF/lib/freemarker-2.3.8.jar

How does SpringMVC know which freemarker jar file to use? I wanted to test this theory by removing freemarker-2.3.8.jar but everytime I build it, it automatically gets freemarker-2.3.8.jar. I looked for this in the pom files but could not find any reference to 2.3.8. Do we want this older version of freemarker? How can I make it so it does not download everytime.


--
Jasmine
------------------------------------------------------------

Adam Feuer

unread,
Oct 21, 2010, 5:25:33 AM10/21/10
to Mifos software development
On Thu, Oct 21, 2010 at 12:34 AM, Jasmine sandhu
<sandhu....@gmail.com> wrote:
> I'm getting a strange error from freemarker when trying to do a spring bind.
> I think the problem I'm seeing maybe because we have two versions of
> freemaker in the mifos-webapp and I think it may not be using the latest
> version.
> target/mifos-webapp/WEB-INF/lib/freemarker-2.3.16.jar
> target/mifos-webapp/WEB-INF/lib/freemarker-2.3.8.jar
>
> How does SpringMVC know which freemarker jar file to use?

Jasmine,

Do a 'mvn dependency:tree' from the command line. You will see a
generated dependency tree of the artifacts used by Mifos.

http://maven.apache.org/plugins/maven-dependency-plugin/usage.html

If there are conflicts like the ones listed above, you may get
inconsistent or buggy behavior. You can examine the tree to find out
which artifacts are pulling in the conflicting jars. Then, you can
edit the pom.xml to include specific jars and exclude others. See the
pom.xmls for examples.

Does this help?

cheers
adam
--
Adam Feuer <adamf at pobox dot com>

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev

Jasmine sandhu

unread,
Oct 22, 2010, 4:11:32 PM10/22/10
to Mifos software development
Thank you Adam. That does help.

I used the following to find that freemarker-2.3.8 was being downloaded by the hibernate-envers artifact (defined in application/pom.xml). I added the exclusion tags to hibernate-envers so it no longer downloads freemarker-2.3.8.

mvn dependency:tree -Dincludes=freemarker:freemarker
and the result:
[INFO] [dependency:tree {execution: default-cli}]
[INFO] org.mifos:mifos-webapp:war:1.7-SNAPSHOT
[INFO] \- org.hibernate:hibernate-envers:jar:3.5.2-Final:compile
[INFO]    \- org.hibernate:hibernate-tools:jar:3.2.0.ga:compile
[INFO]       \- freemarker:freemarker:jar:2.3.8:compile


Of course, this did not fix the original problem I had that got me thinking that we were perhaps using the wrong freemarker version. However, if we don't want to download freemarker-2.3.8.jar, since we are downloading the latest freemarker-2.3.16 as defined in the mifos/pom.xml, then feel free to apply the attached patch.

Jasmine
--
Jasmine
------------------------------------------------------------
0002-excludes-freemarker-from-hibernate-envers.patch

Udai Gupta

unread,
Oct 23, 2010, 12:36:24 PM10/23/10
to Mifos software development
Hi Jasmine,

Thanks for the patch, It has been applied on head-master and head-1.7.x.

Udai

Reply all
Reply to author
Forward
0 new messages