Comments (13)
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.
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.
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.
which version are you using? I wasn't able to reproduce on the main branch.
from jinjava.
We're using 2.1.0 fetched via Maven.
from jinjava.
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.
Can you post the output of mvn dependency:tree
?
from jinjava.
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.
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.
I don't think its the cause of this issue but there are two conflicting javassist
libs on your classpath
from jinjava.
good catch, thanks for the heads up
from jinjava.
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.
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.
very interesting thought. I will check into that, good idea!
from jinjava.
Related Issues (20)
- Can Dict key be an integer? HOT 2
- CVEs in current version: 2.7.0
- time for 2.7.1 / 2.8.0 ?
- Unexpected behavior comparing empty strings to 0
- Is the expression interpolation recursive? HOT 1
- Problem with using the function in nested interpretation HOT 2
- SnakeYAML 1.27 vulnerability in Jinjava 2.7.1 HOT 1
- Add {% hubl %} tag
- Maps in string representation in Сontext
- Support for "with" statement
- Resolve function with map like contructs HOT 1
- Mixing include and extends does not work
- Fix CVEs in version 2.7.1
- Inconsistent implementation with jinja2 HOT 1
- trouble with coercision in test
- Add support for java records HOT 1
- Rendering template with custom function in Scala throws NullPointerException HOT 4
- [question] receiving fixes flow // GHSA-h75v-3vvj-5mfj CVE-2024-34064 HOT 2
- upgrade commons-net to 3.10.0
- Fix eager execution handling of `{% print foo|render %}`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jinjava.