Mapping a JMS JNDI Entries with Thorntail - thorntail

I need to map the following JMS configuration I currently run in WildFly with Thorntail:
<jms-queue name="ExampleQueue" entries="queue/exampleQueue java:/jboss/exported/jms/queue/exampleQueue"/>
I haven't found any example which defines "entries" but I need it for remote JMS Clients. So I have come up with this configuration which, however doesn't work:
thorntail:
management:
security-realms:
ApplicationRealm:
in-memory-authentication:
users:
bob:
password: Password1!
in-memory-authorization:
users:
jmsuser:
roles:
- guest
messaging-activemq:
servers:
default:
jms-queues:
exampleQueue: {}
entries: queue/exampleQueue java:/jboss/exported/jms/queue/exampleQueue
Which causes:
Caused by: java.lang.RuntimeException: while parsing a block mapping
in 'reader', line 18, column 11:
exampleQueue: {}
^
expected <block end>, but found BlockMappingStart
in 'reader', line 19, column 13:
entries: queue/exampleQueue java ...
I'm a bit lost. Can you help me to fix it?
Thanks!

You've got it almost correct. What you need is (only showing the Messaging part):
messaging-activemq:
servers:
default:
jms-queues:
exampleQueue:
entries:
- queue/exampleQueue
- java:/jboss/exported/jms/queue/exampleQueue
(I think queue/exampleQueue should perhaps be jms/queue/exampleQueue, but not totally sure.)
For a complete working example, you can see e.g. https://github.com/rhoar-qe/thorntail-test-suite/tree/master/javaee/messaging-remote

Related

Spring Boot- Profile setting Through YML file is not working

In Spring Boot program, profile setting using application.yml is not working whereas the same program is working using applicaiton.properties. the following actions has been performed but it ended up in vain
In Eclipse ide Project-Clean has been done
Maven project updated
Spaces in YML file removed and corrected
YML file is deleted and recreated.
applicaiton.yml
spring:
profiles:
active: dev
applicaiton-dev.yml
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql:///ntspbms616db
username: root
password: root
dbcp2:
max-total: 100
initial-size: 10
max-conn-lifetime-millis: 10000000
type: org.apache.commons.dbcp2.BasicDataSource
The error i got after running the program is
Enter the Employee Name
Raja
Enter the Employee Designation
Manager
Enter the Basic Salary
9898999
12:28:40.622 [main] ERROR org.springframework.boot.SpringApplication - Application run failed
org.yaml.snakeyaml.scanner.ScannerException: while scanning for the next token
found character '\t(TAB)' that cannot start any token. (Do not use \t(TAB) for indentation)
in 'reader', line 4, column 2:
How to resolve the issue?
This error means literally what is says.
The "tab" is not permitted by the YAML specs:
To maintain portability, tab characters must not be used in
indentation, since different systems treat tabs differently. Note that
most modern editors may be configured so that pressing the tab key
results in the insertion of an appropriate number of spaces.
So, you should double check for the tab characters in your yaml files and if exist, replace them by double space.
Also, just to add, I can see incorrect formatting of dbcp2 section, without any intendation, so, it should look like this:
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql:///ntspbms616db
username: root
password: root
dbcp2:
max-total: 100
initial-size: 10
max-conn-lifetime-millis: 10000000
type: org.apache.commons.dbcp2.BasicDataSource

Invalid Yaml: mapping values are not allowed here

Can anyone help me to figure out the following error while deploying react app on AWS elastic beanstalk -
2019-08-01 04:37:21 ERROR The configuration file .ebextensions/nodecommand.
config in application version app-5466-190801_100700 contains invalid YAML or JS
ON. YAML exception: Invalid Yaml: mapping values are not allowed here
in "<reader>", line 3, column 16:
option_settings:
^
, JSON exception: Invalid JSON: Unexpected character (/) at position 0.. Update
the configuration file.
2019-08-01 04:37:21 ERROR Failed to deploy application.
Following is my nodecommand.config file -
option_settings:
aws: elasticbeanstalk:container:nodejs:
NodeCommand: "node server.compiled.js"
Update -
I followed this link to deploy React app on AWS elastic beanstalk and stuck on above error -
https://medium.com/#wlto/how-to-deploy-an-express-application-with-react-front-end-on-aws-elastic-beanstalk-880ff7245008
This is what's shown in the linked tutorial:
option_settings:
aws:elasticbeanstalk:container:nodejs:
NodeCommand: "node server.compiled.js"
This is the YAML in your question:
option_settings:
aws: elasticbeanstalk:container:nodejs:
NodeCommand: "node server.compiled.js"
Can you spot the difference?
Spoiler: You've put a space after aws:. This causes the YAML parser to assume aws: is a mapping key with the value "elasticbeanstalk:container:nodejs:". However, the next line, which also starts with a mapping key (NodeCommand), is indented more, which would only be allowed if the previous line was a mapping key without a value.
If you remove the space, it correctly parses aws:elasticbeanstalk:container:nodejs as a mapping key and the following line as its value.
I was not actually had the problem fixed. I found this document[1] that says because my environment is using Amazon Linux 2, the ebextensions is not recommended. (But some of my ebextensions are still working. I have no idea about that). Instead, Buildfile, Procfile, and platform hooks are recommended. Therefore, I created a Procfile with the following content to make the Node server run with the command node index.js.
Procfile
web: node index.js
[1] https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.html

Failed to bind properties under 'server' to org.springframework.boot.autoconfigure.web.ServerProperties:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-09-04 12:23:24.383 ERROR 12320 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to bind properties under 'server' to org.springframework.boot.autoconfigure.web.ServerProperties:
Property: server
Value:
Origin: class path resource [application.properties]:2:0
Reason: No converter found capable of converting from type [java.lang.String] to type [#org.springframework.boot.context.properties.ConfigurationProperties org.springframework.boot.autoconfigure.web.ServerProperties]
Action:
Update your application's configuration
My application.properties file look like this:
server:
port: ${PORT:9191}
spring:
datasource:
url: jdbc:sqlserver://PC382682:1433;databaseName=imvenkat
username: imvenkat
password: imvenkat
driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
I know the issue is related to Spring boot, but how should I change my application.properties file to address this issue?
The problem is that you're using YAML format within a properties file. The properties are being parsed line by line, so the properties parser reads server:, and doesn't know how to bind to server directly, which causes the error you see.
Either rename your file to application.yml or change the properties:
server.port=${PORT:9191}
spring.datasource.url=jdbc:sqlserver://PC382682:1433;databaseName=imvenkat
spring.datasource.username=imvenkat
spring.datasource.password=imvenkat
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
This Error can occur when there is mis match between parent version and your spring-boot-devtools dependency.
Remove the version from spring-boot-devtools dependency, that will solve the issue.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
This error can also occur if your config file is in yaml format but you have an error in your yaml so one line looks like a property. Happened to me, previous this was just a broken configuration line, now it breaks the application.
So if you have something broken (look at the url=) like:
server:
port: ${PORT:9191}
spring:
datasource:
url=jdbc:sqlserver://PC382682:1433;databaseName=imvenkat
the same cryptic error can occur. Fixing the config line fixes this error.

Yaml error - mapping values are not allowed here

I'm trying to use a yaml file but whenever I try to read from it I get:
Exception in thread "main" mapping values are not allowed here in "<reader>", line 7, column 19
The yaml file:
topology:
- name: teststormsignals
jar: storm-signals-0.2.1-SNAPSHOT.jar
topologyclass: backtype.storm.contrib.signals.test.SignalTopology
packaging: mvn package
repository: https://github.com/ptgoetz/storm-signals.git
I ran it through a yaml parser but it says it's valid.
Try this (double quoted):
repository: "https://github.com/ptgoetz/storm-signals.git"

Load nested yaml properties using spring-boot

I have the following application-errors.yml file defined in src/main/resources of my Java spring-boot application:
client:
badrequest: {code: 001, message: 'Malformed request', status: 400}
configuration: {code: 002, message: 'Invalid EC2 VPC configuration', status: 400}
server:
unexpected.error:
code: 004
message: 'Unexpected error occurred. Please try again'
status: 500
Note that I've tried two different formats for specifying the properties.
I load that property file via the following Bean from a #Configuration annotated class:
#Bean
public static YamlPropertiesFactoryBean getYamlProperties() {
YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
yaml.setResources(new ClassPathResource("application-errors.yml"));
return yaml;
}
I see that the properties are loaded via the Spring Environment variable, but not in the pattern that I would expect. When debugging through, I can see that the source of the loaded property file contains the following values:
{client.badrequest=code:001 message:'Malformed request' status:400, client.configuration=code:002 message:'Invalid EC2 VPC configuration' status:400, server.unexpected.error=code:004 message:'Unexpected error occurred. Please try again' status:500}
It looks like the yaml file was flattened partially (only two levels deep). Instead, I was expecting each end property to be flattened on its own. The format that I was expecting would have been something like this:
{client.badrequest.code=001, client.badrequest.message='Malformed request', client.badrequest.status=400, client.configuration.code=002, client.configuration.message='Invalid EC2 VPC configuration', client.configuration.status=400, server.unexpected.error.code=004, server.unexpected.error.message='Unexpected error occurred. Please try again', server.unexpected.error.status=500}
What do I need to change in order to ensure Spring flattens the properties the entire way? If I'm not understanding either yaml formatting patterns or the pattern that Spring follows to flatten yaml files correctly, please correct my understanding.
I've found the multiple errors I made when arriving at this question this morning:
1) My code was not actually loading any custom named yml property files. Instead, it was picking up the default application.yml file that I also had in my project.
2) That default application.yml file had yml formatted code with the wrong syntax. Specifically, I had omitted the required space after each property identifier:
client:
badrequest:
code:001
message:'Malformed request'
status:400
configuration
code:002
message:'Invalid EC2 VPC configuration'
status:400
server:
unexpected.error
code:004
message:'Unexpected error occurred. Please try again'
status:500
After understanding those two issues, I was able to correctly load properties from application.yml.
The final syntax I landed on for my properties is the following:
# Error Properties
client:
badrequest: {code: 001, message: 'Malformed request', status: 400}
configuration: {code: 002, message: 'Invalid EC2 VPC configuration', status: 400}
server:
unexpected.error: {code: 004, message: 'Unexpected error occurred. Please try again', status: 500}

Resources