Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#{...} is not resolved when using Jolokia's Spring configuration #192

Closed
rhuss opened this issue Apr 9, 2015 · 6 comments
Closed

#{...} is not resolved when using Jolokia's Spring configuration #192

rhuss opened this issue Apr 9, 2015 · 6 comments
Milestone

Comments

@rhuss
Copy link
Owner

@rhuss rhuss commented Apr 9, 2015

Although ${...} substitution works fine when using <jolokia:config> in a Spring configuration, the extended EL with #{...} does not.

In addition to fix this, there should be a documentation how the Jolokia agent can be used with the Jolokia specific Spring configuration but with plain beans only.

@LionelCons
Copy link

@LionelCons LionelCons commented Apr 20, 2015

Roland, let me know if I can help you with this one...

@rhuss
Copy link
Owner Author

@rhuss rhuss commented Apr 22, 2015

sorry for the delay, I'm quite busy until May (changing jobs). If you want, you can dive into it. The starting point is here.

@rhuss rhuss added this to the 1.2.4 milestone May 4, 2015
@rhuss
Copy link
Owner Author

@rhuss rhuss commented May 4, 2015

As a workaround you can use the following construct to setup Jolokia without using the joloka spring config syntax:

  <bean name="server" id="jolokia" class="org.jolokia.jvmagent.spring.SpringJolokiaAgent">
    <property name="config">
      <bean class="org.jolokia.jvmagent.spring.SpringJolokiaConfigHolder">
        <property name="config">
          <util:map>
            <entry key="autoStart" value="true"/>
            <entry key="host" value="127.0.0.1"/>
            <entry key="port" value="#{configuration['jmx.jolokiaPort']}"/>
            <entry key="agentContext" value="/jolokia"/>
          </util:map>
        </property>
      </bean>
    </property>
  </bean>

@rhuss
Copy link
Owner Author

@rhuss rhuss commented May 4, 2015

I will add this to the documentation.

@cmoulliard
Copy link

@cmoulliard cmoulliard commented May 4, 2015

I think that the PropertyPlaceHolder should be added after the lookupConfig - https://github.com/cmoulliard/jolokia/blob/master/agent/jvm-spring/src/main/java/org/jolokia/jvmagent/spring/SpringJolokiaAgent.java#L59

Question : Do we have to exclude in the code the situation where a spring xml file will contain the SpringJolokiaConfigHolder AND also a <context:property-placeholder location="classpath:foo.properties" /> ?

@rhuss
Copy link
Owner Author

@rhuss rhuss commented May 4, 2015

Both are orthogonal and note really related. The SpringJolokiaConfigHolder is only a container for map and used as backing bean for the jolokia namespace configuration (therefore this extra indirection which would not be necessary otherwise). The lookupConfig is used for having the possibility to separate configuration and installation of the agent. I.e. one could have a library with an unconfigured agent in the spring context and then only add the configuration in another context file (don't know whether this is really often used).

The problem here is that the Spring EL (#{ ...}) is not resolved before the value is injected into the bean when the jolokia namespace is used. Fix shouldn't be hard as soon as I dived into the Spring rabbit hole (which always takes a bit ;-). ${...} expressions are resolved earlier and are properly injected, though. See also the discussion here.

@rhuss rhuss closed this in 66755a3 May 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants