GithubHelp home page GithubHelp logo

Filters don't seem to work about jinjava HOT 13 CLOSED

hubspot avatar hubspot commented on July 19, 2024 1
Filters don't seem to work

from jinjava.

Comments (13)

xnaveira avatar xnaveira commented on July 19, 2024 1

I just created an standalone project and get the same output as you.

The problem appears when trying to use jinjava inside a dropwizard project. Let me gather some more data and get back to you.

from jinjava.

zepernick avatar zepernick commented on July 19, 2024 1

The real issue, for me anyway, is that I have this running on Tomcat 9 which provides a 3.0 el-api implementation. JinJava is depending on juel-api-2.2.7 which is an implementation of the 2.2 spec. I removed the el-api.jar from the tomcat lib and replaced it with juel-api-2.2.7 which solved the problem.

Tomcat 7 is the latest release that provides a 2.2 implementation. I have not tested with that version to see if JinJava would run okay without swapping in the juel-api.

from jinjava.

zaycev avatar zaycev commented on July 19, 2024 1

Had a similar issue in dropwizard project. Solved by excluding javassist and javax.el:

<dependency>
    <groupId>io.dropwizard</groupId>
    <artifactId>dropwizard-core</artifactId>
    <version>${io.dropwizard.version}</version>
    <exclusions>
        <!-- Conflicts with jinjava -->
        <exclusion>
            <groupId>org.javassist</groupId>
            <artifactId>javassist</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.glassfish</groupId>
            <artifactId>javax.el</artifactId>
        </exclusion>
    </exclusions>
</dependency>

from jinjava.

jaredstehler avatar jaredstehler commented on July 19, 2024

which version are you using? I wasn't able to reproduce on the main branch.

from jinjava.

xnaveira avatar xnaveira commented on July 19, 2024

We're using 2.1.0 fetched via Maven.

from jinjava.

jaredstehler avatar jaredstehler commented on July 19, 2024

I am still unable to reproduce..

import com.google.common.collect.ImmutableMap;
import com.hubspot.jinjava.Jinjava;
import com.hubspot.jinjava.JinjavaConfig;
import com.hubspot.jinjava.interpret.RenderResult;

public class Issue39 {

  public static void main(String[] args) {
    Jinjava jinjava = new Jinjava(new JinjavaConfig());
    String template = "hello {{ testvar | upper }}";

    RenderResult result = jinjava.renderForResult(template, ImmutableMap.of("testvar", "stranger"));
    System.out.println(result.getErrors());

    System.out.println(jinjava.render(template, ImmutableMap.of("testvar", "stranger")));
  }
}

produces following output:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[]
hello STRANGER

with pom dep:

    <dependency>
      <groupId>com.hubspot.jinjava</groupId>
      <artifactId>jinjava</artifactId>
      <version>2.1.0</version>
    </dependency>

from jinjava.

jaredstehler avatar jaredstehler commented on July 19, 2024

Can you post the output of mvn dependency:tree?

from jinjava.

zepernick avatar zepernick commented on July 19, 2024

I am experiencing the same problem. You can pass a empty parameter to the filter and it resolves it. I opened a report before I realized this was the same thing.

#43

Here is my dependency tree from mvn

[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ StrutsPlay ---
[INFO] com.hs:StrutsPlay:jar:1.0-SNAPSHOT
[INFO] +- org.apache.struts:struts2-core:jar:2.5-BETA2:compile
[INFO] | +- org.freemarker:freemarker:jar:2.3.22:compile
[INFO] | +- ognl:ognl:jar:3.0.11:compile
[INFO] | | - javassist:javassist:jar:3.11.0.GA:compile
[INFO] | +- org.apache.logging.log4j:log4j-api:jar:2.3:compile
[INFO] | +- commons-fileupload:commons-fileupload:jar:1.3.1:compile
[INFO] | +- commons-io:commons-io:jar:2.4:compile
[INFO] | +- org.apache.commons:commons-lang3:jar:3.4:compile
[INFO] | +- asm:asm:jar:3.3:compile
[INFO] | - asm:asm-commons:jar:3.3:compile
[INFO] | - asm:asm-tree:jar:3.3:compile
[INFO] +- org.apache.struts.xwork:xwork-core:jar:2.3.20.1:compile
[INFO] | +- org.ow2.asm:asm:jar:5.0.2:compile
[INFO] | - org.ow2.asm:asm-commons:jar:5.0.2:compile
[INFO] | - org.ow2.asm:asm-tree:jar:5.0.2:compile
[INFO] +- com.hubspot.jinjava:jinjava:jar:2.1.0:compile
[INFO] | +- org.slf4j:slf4j-api:jar:1.7.12:compile
[INFO] | +- com.google.guava:guava:jar:17.0:compile
[INFO] | +- org.javassist:javassist:jar:3.18.2-GA:compile
[INFO] | +- org.jsoup:jsoup:jar:1.8.1:compile
[INFO] | +- de.odysseus.juel:juel-api:jar:2.2.7:compile
[INFO] | +- de.odysseus.juel:juel-impl:jar:2.2.7:compile
[INFO] | +- de.odysseus.juel:juel-spi:jar:2.2.7:runtime
[INFO] | - com.google.code.findbugs:annotations:jar:3.0.0:compile
[INFO] +- commons-beanutils:commons-beanutils:jar:1.9.2:compile
[INFO] | +- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] | - commons-collections:commons-collections:jar:3.2.1:compile
[INFO] +- org.apache.commons:commons-collections4:jar:4.1:compile
[INFO] - javax.servlet:servlet-api:jar:2.3:provided

from jinjava.

jaredstehler avatar jaredstehler commented on July 19, 2024

I don't think its the cause of this issue but there are two conflicting javassist libs on your classpath

from jinjava.

zepernick avatar zepernick commented on July 19, 2024

good catch, thanks for the heads up

from jinjava.

zepernick avatar zepernick commented on July 19, 2024

I created a new java project and was not able to reproduce the error with a test case. It appears to have something to do with the Struts2 project I have it in. I have created a custom Struts 2 result that runs the JinJava Interpreter and outputs the result.

It is just a test project and I have attached it here if you are interested in taking a look. I will keep looking to see if I can figure out the conflict. It is something that Struts is doing and not the mere fact that it is on the classpath. I tried putting it on the classpath of my java project and it still worked okay.
StrutsPlay.zip

from jinjava.

jaredstehler avatar jaredstehler commented on July 19, 2024

Ah, interesting. Wonder if we were to shade-relocate the juel el packages in the jinjava library jar if that would fix the conflict..?

from jinjava.

zepernick avatar zepernick commented on July 19, 2024

very interesting thought. I will check into that, good idea!

from jinjava.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.