Reputation: 644
Thorntail using project-defaults.yaml
Using the below command line arguments to start the application.
Trying to pass location of a Java .properties file to use as system properties.
java -jar application-thorntail.jar -P ../config/application.properties -P ../config/application-dev.properties -s ../config/project-defaults.yaml
Property key value in application.properties
mail.smtp.password=testpass
tds.username=username
In yaml i want to evaluate the value as below
mail:
mail-sessions:
default:
smtp-server:
username: ${mail.smtp.user}
password: ${mail.smtp.password}
outbound-socket-binding-ref: mail-smtp
jndi-name: java:jboss/mail/Default
However, on a statup values are not getting evaluated
Error getting subresources for ConnectionDefinitions
java.lang.RuntimeException: Failed to adopt value java.lang.String
at org.wildfly.swarm.config.runtime.invocation.EntityAdapter.fromEntity(EntityAdapter.java:346)
at org.wildfly.swarm.config.runtime.invocation.Marshaller.appendNode(Marshaller.java:33)
at org.wildfly.swarm.config.runtime.invocation.Marshaller.marshalSubresources(Marshaller.java:129)
at org.wildfly.swarm.config.runtime.invocation.Marshaller.appendNode(Marshaller.java:38)
at org.wildfly.swarm.config.runtime.invocation.Marshaller.marshalSubresources(Marshaller.java:129)
at org.wildfly.swarm.config.runtime.invocation.Marshaller.appendNode(Marshaller.java:38)
at org.wildfly.swarm.config.runtime.invocation.Marshaller.marshalSubresources(Marshaller.java:129)
at org.wildfly.swarm.config.runtime.invocation.Marshaller.appendNode(Marshaller.java:38)
at org.wildfly.swarm.config.runtime.invocation.Marshaller.marshal(Marshaller.java:23)
at org.wildfly.swarm.container.runtime.marshal.SubsystemMarshaller.marshal(SubsystemMarshaller.java:59)
at org.wildfly.swarm.container.runtime.marshal.SubsystemMarshaller$Proxy$_$$_WeldClientProxy.marshal(Unknown Source)
at org.wildfly.swarm.container.runtime.marshal.DMRMarshaller.marshal(DMRMarshaller.java:70)
at org.wildfly.swarm.container.runtime.marshal.DMRMarshaller$Proxy$_$$_WeldClientProxy.marshal(Unknown Source)
at org.wildfly.swarm.container.runtime.RuntimeServer.start(RuntimeServer.java:194)
at org.wildfly.swarm.container.runtime.RuntimeServer$Proxy$_$$_WeldClientProxy.start(Unknown Source)
at org.wildfly.swarm.container.runtime.ServerBootstrapImpl.lambda$bootstrap$1(ServerBootstrapImpl.java:159)
at org.wildfly.swarm.spi.api.ClassLoading.withTCCL(ClassLoading.java:43)
at org.wildfly.swarm.container.runtime.ServerBootstrapImpl.bootstrap(ServerBootstrapImpl.java:113)
at org.wildfly.swarm.Swarm.start(Swarm.java:401)
at org.wildfly.swarm.Swarm.main(Swarm.java:745)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.wildfly.swarm.bootstrap.MainInvoker.invoke(MainInvoker.java:57)
at org.wildfly.swarm.bootstrap.Main.run(Main.java:134)
at org.wildfly.swarm.bootstrap.Main.main(Main.java:87)
Caused by: java.lang.IllegalStateException: Failed to resolve expression: ${tds.username}
at org.jboss.dmr.ValueExpressionResolver.resolve(ValueExpressionResolver.java:128)
at org.jboss.dmr.ValueExpression.resolveString(ValueExpression.java:163)
at org.jboss.dmr.ValueExpression.resolveString(ValueExpression.java:153)
at org.wildfly.swarm.config.runtime.invocation.SimpleTypeAdapter.toDmr(SimpleTypeAdapter.java:22)
at org.wildfly.swarm.config.runtime.invocation.EntityAdapter.fromEntity(EntityAdapter.java:343)
... 26 more
Upvotes: 0
Views: 444
Reputation: 329
Well, first of all you defined your property as tds.username
, but you are tring to access it as mail.smtp.user
.
If this was just a mistake when writing the example, maybe you could try using ${env.XXX}.
Change your property file from mail.smtp.user
to MAIL_SMTP_USER
and then, on project-defaults, use username: ${env.MAIL_SMTP_USER}.
If this works, you could even propose a default value (in the example below, "defaultusername"): username: ${env.MAIL_SMTP_USER:defaultusername}
Important to note that I don't have the tools to test it.
Upvotes: 0