configtxgen command doesn't work. How can I resolve? - docker

I'm having a problem running the "configtxgen" command to generate the genesis block.
I'm following this specific guide and in the part where you have to run this command, the following errors come out:
$ configtxgen -profile IstumNetworkProfile -channelID system-channel -configPath ${PWD}/config -outputBlock ./system-genesis-block/genesis.block
2023-01-31 11:38:54.354 CET [common/tools/configtxgen] main -> INFO 001 Loading configuration
2023-01-31 11:38:54.378 CET [common/tools/configtxgen/localconfig] Load -> CRIT 002 Error unmarshaling config into struct: 4 error(s) decoding:
* 'Orderer' has invalid keys: EtcdRaft
* 'Organizations[0]' has invalid keys: OrdererEndpoints
* 'Profiles[IstumNetworkProfile].Orderer' has invalid keys: EtcdRaft
* 'Profiles[IstumNetworkProfile].Orderer.Organizations[0]' has invalid keys: OrdererEndpoints
2023-01-31 11:38:54.379 CET [common/tools/configtxgen] func1 -> CRIT 003 Error unmarshaling config into struct: 4 error(s) decoding:
* 'Orderer' has invalid keys: EtcdRaft
* 'Organizations[0]' has invalid keys: OrdererEndpoints
* 'Profiles[IstumNetworkProfile].Orderer' has invalid keys: EtcdRaft
* 'Profiles[IstumNetworkProfile].Orderer.Organizations[0]' has invalid keys: OrdererEndpoints
panic: Error unmarshaling config into struct: 4 error(s) decoding:
* 'Orderer' has invalid keys: EtcdRaft
* 'Organizations[0]' has invalid keys: OrdererEndpoints
* 'Profiles[IstumNetworkProfile].Orderer' has invalid keys: EtcdRaft
* 'Profiles[IstumNetworkProfile].Orderer.Organizations[0]' has invalid keys: OrdererEndpoints [recovered]
panic: Error unmarshaling config into struct: 4 error(s) decoding:
* 'Orderer' has invalid keys: EtcdRaft
* 'Organizations[0]' has invalid keys: OrdererEndpoints
* 'Profiles[IstumNetworkProfile].Orderer' has invalid keys: EtcdRaft
* 'Profiles[IstumNetworkProfile].Orderer.Organizations[0]' has invalid keys: OrdererEndpoints
My cryptogen version is :
$ cryptogen version
cryptogen:
Version: 1.2.0
Commit SHA: cae2ad4
Go version: go1.10
OS/Arch: linux/amd64
And this is my configtx.yaml file. Can you check if it is correct?
Organizations:
- &OrdererOrg
Name: OrdererOrg
ID: OrdererMSP # Consente agli altri partecipanti alla rete l'identificazione di questa entità.
MSPDir: ../crypto-material/ordererOrganizations/istum.com/msp
Policies: # Configurazione del tipo di ruoli a cui si è autorizzati a fare
Readers:
Type: Signature
Rule: "OR('OrdererMSP.member')"
Writers:
Type: Signature
Rule: "OR('OrdererMSP.member')"
Admins:
Type: Signature
Rule: "OR('OrdererMSP.admin')"
OrdererEndpoints:
- orderer0.istum.com:7050
- &Org1
Name: Org1
ID: Org1MSP # Consente agli altri partecipanti alla rete l'identificazione di questa entità.
MSPDir: ../crypto-material/peerOrganizations/org1.istum.com/msp
Policies: # Configurazione del tipo di ruoli a cui si è autorizzati a fare
Readers:
Type: Signature
Rule: "OR('Org1MSP.member')"
Writers:
Type: Signature
Rule: "OR('Org1MSP.member')"
Admins:
Type: Signature
Rule: "OR('Org1MSP.admin')"
Endorsement:
Type: Signature
Rule: "OR('Org1MSP.member')"
AnchorPeers: # Gateway peer da un'organizzazione all'Anchor Peer di un'altra organizzazione
- Host: peer0.org1.istum.com
Port: 7051
- &Org2
Name: Org2
ID: Org2MSP # Consente agli altri partecipanti alla rete l'identificazione di questa entità.
MSPDir: ../crypto-material/peerOrganizations/org2.istum.com/msp
Policies: # Configurazione del tipo di ruoli a cui si è autorizzati a fare
Readers:
Type: Signature
Rule: "OR('Org2MSP.member')"
Writers:
Type: Signature
Rule: "OR('Org2MSP.member')"
Admins:
Type: Signature
Rule: "OR('Org2MSP.admin')"
Endorsement:
Type: Signature
Rule: "OR('Org2MSP.member')"
AnchorPeers: # Gateway peer da un'organizzazione all'Anchor Peer di un'altra organizzazione
- Host: peer0.org2.istum.com
Port: 8051
- &Org3
Name: Org3
ID: Org3MSP # Consente agli altri partecipanti alla rete l'identificazione di questa entità.
MSPDir: ../crypto-material/peerOrganizations/org3.istum.com/msp
Policies: # Configurazione del tipo di ruoli a cui si è autorizzati a fare
Readers:
Type: Signature
Rule: "OR('Org3MSP.member')"
Writers:
Type: Signature
Rule: "OR('Org3MSP.member')"
Admins:
Type: Signature
Rule: "OR('Org3MSP.admin')"
Endorsement:
Type: Signature
Rule: "OR('Org3MSP.member')"
AnchorPeers: # Gateway peer da un'organizzazione all'Anchor Peer di un'altra organizzazione
- Host: peer0.org2.istum.com
Port: 8052
# Nelle Capabilities *Channel* definisce il set di funzionalità di Hyperledger che viene utilizzato solo dai peer,
# mentre *Orderer* definisce il set di funzionalità che è rilevante (lo indovini) solo per gli ordini.
# L'*applicazione* , d'altra parte, definisce il set di funzionalità, che è rilevante per tutti i peer E tutti gli ordinatori e quindi definisce il minimo comune denominatore per l'intera rete.
Capabilities:
Channel: &ChannelCapabilities
V2_0: true
Orderer: &OrdererCapabilities
V2_0: true
Application: &ApplicationCapabilities
V2_0: true
Application: &ApplicationDefaults
Organizations:
Policies:
Readers:
Type: ImplicitMeta
Rule: "ANY Readers"
Writers:
Type: ImplicitMeta
Rule: "ANY Writers"
Admins:
Type: ImplicitMeta
Rule: "MAJORITY Admins"
LifecycleEndorsement:
Type: ImplicitMeta
Rule: "MAJORITY Endorsement"
Endorsement:
Type: ImplicitMeta
Rule: "MAJORITY Endorsement"
Capabilities:
<<: *ApplicationCapabilities
Orderer: &OrdererDefaults
OrdererType: etcdraft
EtcdRaft:
Options:
TickInterval: 500ms
ElectionTick: 10
HeartbeatTick: 1
MaxInflightBlocks: 5
SnapshotIntervalSize: 20971520
Consenters:
- Host: orderer0.istum.com
Port: 7050
ClientTLSCert: ../crypto-material/ordererOrganizations/istum.com/orderers/orderer0.istum.com/tls/server.crt
ServerTLSCert: ../crypto-material/ordererOrganizations/istum.com/orderers/orderer0.istum.com/tls/server.crt
BatchTimeout: 2s # Definiscono alcune specifiche riguardanti il ​​tempo dopo il quale un blocco dovrebbe essere
BatchSize: # costruito e quante transazioni dovrebbe contenere al massimo
MaxMessageCount: 10
AbsoluteMaxBytes: 99 MB
PreferredMaxBytes: 512 KB
Organizations:
Policies: # Configurazione del tipo di ruoli a cui si è autorizzati a fare (in questo caso per l'intera rete)
Readers:
Type: ImplicitMeta
Rule: "ANY Readers"
Writers:
Type: ImplicitMeta
Rule: "ANY Writers"
Admins:
Type: ImplicitMeta
Rule: "MAJORITY Admins"
BlockValidation:
Type: ImplicitMeta
Rule: "ANY Writers"
Channel: &ChannelDefaults #Si definisce qui quali criteri di canale predefiniti sono impostati per il canale
Policies:
Readers:
Type: ImplicitMeta
Rule: "ANY Readers"
Writers:
Type: ImplicitMeta
Rule: "ANY Writers"
Admins:
Type: ImplicitMeta
Rule: "MAJORITY Admins"
Capabilities:
<<: *ChannelCapabilities
Profiles:
IstumNetworkProfile:
<<: *ChannelDefaults
Orderer:
<<: *OrdererDefaults #definiscono chi sarà in grado di modificare ( Admins ) la nostra rete o semplicemente leggere / scrivere ( Readers / Writers ) sulla nostra rete.
Organizations: # Qui definiamo da quali organizzazioni provengono i nostri ordinatori
- *OrdererOrg
Capabilities:
<<: *OrdererCapabilities
Consortiums:
IstumConsortium:
Organizations: # Quali organizzazioni sono autorizzate a unirsi alla rete e creare canali ecc..?
- *Org1
- *Org2
- *Org3
IstumChannelProfile:
Consortium: IstumConsortium
<<: *ChannelDefaults
Application:
<<: *ApplicationDefaults
Organizations:
- *Org1
- *Org2
- *Org3
Capabilities:
<<: *ApplicationCapabilities
Thanks a lot to whoever will help me!!
EDIT
I resolved by downgrade my Hyperledger Binaries to 1.4.7 version!!

Related

curl: (52) Empty reply from server while calling ejabbered API Commands

My ejabberd server is running in a docker container and I am trying to call ejabberd API commands. Somehow I am always getting "curl: (52) Empty reply from server". I don't know where I am wrong in configuring yml file for ejabbered.
I tried getting the list of vhosts and registered_users. But all I am getting is Empty reply.
Below is my YML file
hosts:
- localhost
loglevel: 4
log_rotate_size: 10485760
log_rotate_date: ""
log_rotate_count: 1
log_rate_limit: 100
certfiles:
- /home/ejabberd/conf/server.pem
ca_file: "/home/ejabberd/conf/cacert.pem"
## When using let's encrypt to generate certificates
##certfiles:
## - /etc/letsencrypt/live/localhost/fullchain.pem
## - /etc/letsencrypt/live/localhost/privkey.pem
##
##ca_file: "/etc/letsencrypt/live/localhost/fullchain.pem"
listen:
-
port: 5222
ip: "::"
module: ejabberd_c2s
max_stanza_size: 262144
shaper: c2s_shaper
access: c2s
starttls_required: true
-
port: 5269
ip: "::"
module: ejabberd_s2s_in
max_stanza_size: 524288
-
port: 5443
ip: 127.0.0.1
module: ejabberd_http
request_handlers:
/: ejabberd_web_admin
"/api": mod_http_api
"/bosh": mod_bosh
"/captcha": ejabberd_captcha
"/upload": mod_http_upload
"/ws": ejabberd_http_ws
"/oauth": ejabberd_oauth
-
port: 5180
ip: "::"
module: ejabberd_http
request_handlers:
/: ejabberd_web_admin
-
port: 1883
ip: "::"
module: mod_mqtt
backlog: 1000
##
## https://docs.ejabberd.im/admin/configuration/#stun-and-turn
## ejabberd_stun: Handles STUN Binding requests
##
##-
## port: 3478
## ip: "0.0.0.0"
## transport: udp
## module: ejabberd_stun
## use_turn: true
## turn_ip: "{{ IP }}"
## auth_type: user
## auth_realm: "example.com"
##-
## port: 3478
## ip: "0.0.0.0"
## module: ejabberd_stun
## use_turn: true
## turn_ip: "{{ IP }}"
## auth_type: user
## auth_realm: "example.com"
##-
## port: 5349
## ip: "0.0.0.0"
## module: ejabberd_stun
## certfile: "/home/ejabberd/conf/server.pem"
## tls: true
## use_turn: true
## turn_ip: "{{ IP }}"
## auth_type: user
## auth_realm: "example.com"
##
## https://docs.ejabberd.im/admin/configuration/#sip
## To handle SIP (VOIP) requests:
##
##-
## port: 5060
## ip: "0.0.0.0"
## transport: udp
## module: ejabberd_sip
##-
## port: 5060
## ip: "0.0.0.0"
## module: ejabberd_sip
##-
## port: 5061
## ip: "0.0.0.0"
## module: ejabberd_sip
## tls: true
s2s_use_starttls: optional
acl:
local:
user_regexp: ""
loopback:
ip:
- 127.0.0.0/8
- ::1/128
- ::FFFF:127.0.0.1/128
admin:
user:
- "admin#localhost"
access_rules:
local:
allow: local
c2s:
deny: blocked
allow: all
announce:
allow: admin
configure:
allow: admin
muc_create:
allow: local
pubsub_createnode:
allow: local
trusted_network:
allow: loopback
api_permissions:
"console commands":
from:
- ejabberd_ctl
- mod_http_api
who: all
what: "*"
"admin access":
who:
access:
allow:
##acl: loopback
acl: admin
oauth:
scope: "ejabberd:admin"
scope: "registered_users"
access:
allow:
##acl: loopback
acl: admin
what:
- "*"
- "!stop"
- "!start"
"public commands":
from:
- mod_http_api
who:
ip: 127.0.0.1/8
what:
- "*"
- "!stop"
- "!start"
shaper:
normal: 1000
fast: 50000
shaper_rules:
max_user_sessions: 10
max_user_offline_messages:
5000: admin
100: all
c2s_shaper:
none: admin
normal: all
s2s_shaper: fast
max_fsm_queue: 10000
acme:
contact: "mailto:example-admin#example.com"
ca_url: "https://acme-staging-v02.api.letsencrypt.org/directory"
modules:
mod_adhoc: {}
mod_admin_extra: {}
mod_announce:
access: announce
mod_avatar: {}
mod_blocking: {}
mod_bosh: {}
mod_caps: {}
mod_carboncopy: {}
mod_client_state: {}
mod_configure: {}
mod_disco: {}
mod_fail2ban: {}
mod_http_api: {}
mod_http_upload:
put_url: https://#HOST#:5443/upload
mod_last: {}
mod_mam:
## Mnesia is limited to 2GB, better to use an SQL backend
## For small servers SQLite is a good fit and is very easy
## to configure. Uncomment this when you have SQL configured:
## db_type: sql
assume_mam_usage: true
default: never
mod_mqtt: {}
mod_muc:
access:
- allow
access_admin:
- allow: admin
access_create: muc_create
access_persistent: muc_create
access_mam:
- allow
default_room_options:
allow_subscription: true # enable MucSub
mam: false
mod_muc_admin: {}
mod_offline:
access_max_user_messages: max_user_offline_messages
mod_ping: {}
mod_privacy: {}
mod_private: {}
mod_proxy65:
access: local
max_connections: 5
mod_pubsub:
access_createnode: pubsub_createnode
plugins:
- flat
- pep
force_node_config:
## Avoid buggy clients to make their bookmarks public
storage:bookmarks:
access_model: whitelist
mod_push: {}
mod_push_keepalive: {}
mod_register:
## Only accept registration requests from the "trusted"
## network (see access_rules section above).
## Think twice before enabling registration from any
## address. See the Jabber SPAM Manifesto for details:
## https://github.com/ge0rg/jabber-spam-fighting-manifesto
ip_access: trusted_network
mod_roster:
versioning: true
mod_sip: {}
mod_s2s_dialback: {}
mod_shared_roster: {}
mod_stream_mgmt:
resend_on_timeout: if_offline
mod_vcard: {}
mod_vcard_xupdate: {}
mod_version:
show_os: false
### Local Variables:
### mode: yaml
### End:
### vim: set filetype=yaml tabstop=8
Assuming a configuration that includes at least those parts:
hosts:
- localhost
listen:
port: 5443
ip: "::"
module: ejabberd_http
tls: true
request_handlers:
"/api": mod_http_api
-
port: 5280
ip: "::"
module: ejabberd_http
request_handlers:
"/api": mod_http_api
api_permissions:
"admin access":
who:
access:
allow: all
what:
- "registered_users"
modules:
...
mod_http_api: {}
All those queries work correctly:
curl -X GET \
http://localhost:5280/api/registered_users?host=localhost
curl -X POST \
http://localhost:5280/api/registered_users \
-d '{"host": "localhost"}'
curl -X GET \
--insecure \
https://localhost:5443/api/registered_users?host=localhost
curl -X POST \
--insecure \
https://localhost:5443/api/registered_users \
-d '{"host": "localhost"}'
All them report the same result:
["admin"]
In the ejabberd log file you should view something like:
2022-02-14 20:13:41.686208+00:00 [info] (<0.758.0>)
Accepted connection [::ffff:172.18.0.1]:50040 -> [::ffff:172.18.0.2]:5443
2022-02-14 20:13:41.696906+00:00 [info]
API call registered_users [{<<"host">>,<<"localhost">>}] from ::ffff:172.18.0.1:50040

Set Request Validator of API Gateway by serverless

I want to set Request Validator of API Gateway by serverless. I tried two different settings for the Request Validator. But, both methods have failed. I have summarized what I did, so please let me know if there is something wrong.
I write the API specification in swagger(OAS3.0). Therefore I tried to realize the setting of Request Validator using OAS extension. After I did sls deploy using below swagger.yaml and serverless.yml, None of the validate patterns described in x-amazon-apigateway-request-validators were added to the Request Validator options.
https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-request-validator.html
swagger.yaml is below:
openapi: 3.0.0
info:
description: xxx
version: '0.1'
title: xxx API
x-amazon-apigateway-request-validators:
body-only:
validateRequestBody: true,
validateRequestParameters: false
except-body:
validateRequestBody: false,
validateRequestParameters: true
all:
validateRequestBody: true,
validateRequestParameters: true
tags:
- name: auth
description: xxx
paths:
/login:
post:
tags:
- auth
summary: xxx
description: ''
x-amazon-apigateway-request-validator: all
responses:
'200':
description: success
content:
application/json:
schema:
$ref: '#/components/schemas/AuthResponse'
'400':
description: fail
content:
application/json
'401':
description: fail
content:
application/json
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/AuthRequest'
required: true
x-amazon-apigateway-integration:
responses:
default:
statusCode: "200"
uri: "arn:aws:apigateway:ap-northeast-1:lambda:path/2015-03-31/functions/arn:aws:lambda:ap-northeast-1:xxxxxxxxxxxx:function:xxx-api-dev-login/invocations"
passthroughBehavior: "when_no_match"
httpMethod: "POST"
contentHandling: "CONVERT_TO_TEXT"
type: "aws_proxy"
My serverless.yml is below:
resources:
Resources:
RestApi :
Type : AWS::ApiGateway::RestApi
Properties :
Body : ${file(./swagger.yaml)}
LoginApiToInvokeLambda:
Type: AWS::Lambda::Permission
DependsOn: LoginLambdaFunction
Properties:
FunctionName: xxx-ext-api-dev-login
Action: lambda:InvokeFunction
Principal: apigateway.amazonaws.com
I tried to realize the setting of Request Validator using AWS::ApiGateway::RequestValidator. After I did sls deploy using above swagger.yaml and below serverless.yml, the all described in RequestValidatorAll in severless.yml were added to the Request Validator options. But the default value of Request Validator was still NONE.
resources:
Resources:
RestApi :
Type : AWS::ApiGateway::RestApi
Properties :
Body : ${file(./swagger.yaml)}
LoginApiToInvokeLambda:
Type: AWS::Lambda::Permission
DependsOn: LoginLambdaFunction
Properties:
FunctionName: xxx-ext-api-dev-login
Action: lambda:InvokeFunction
Principal: apigateway.amazonaws.com
RequestValidatorAll:
Type: AWS::ApiGateway::RequestValidator
Properties:
Name: all
RestApiId:
Ref: RestApi
ValidateRequestBody: true
ValidateRequestParameters: true
You need to remove the commas in your YAML.
i.e
x-amazon-apigateway-request-validators:
body-only:
validateRequestBody: true,
validateRequestParameters: false
except-body:
validateRequestBody: false,
validateRequestParameters: true
all:
validateRequestBody: true,
validateRequestParameters: true
should be
x-amazon-apigateway-request-validators:
body-only:
validateRequestBody: true
validateRequestParameters: false
except-body:
validateRequestBody: false
validateRequestParameters: true
all:
validateRequestBody: true
validateRequestParameters: true
Once you do this the YAML will be valid and it should work.

how to add content type in Swagger yaml file?

I tried CRUD Operation in Swagger api using Node js. I tried PUT method using Swagger api, it's Successfully updated in db but it's throwing content type error. I tried many ways. I added application/json, application/xml, text/plain but it's still throwing same error. How to fix it can give me any solution.
Swagger.yaml
swagger: "2.0"
info:
version: "0.0.1"
title: Movie DB
# during dev, should point to your local machine
host: localhost:8000
# basePath prefixes all resource paths
basePath: /
#
schemes:
# tip: remove http to make production-grade
- http
- https
# format of bodies a client can send (Content-Type)
securityDefinitions:
Bearer:
type: apiKey
name: Authorization
in: header
consumes:
- application/json
# format of the responses to the client (Accepts)
produces:
- application/json
paths:
/movies:
# binds a127 app logic to a route
x-swagger-router-controller: movies
post:
description: Creates a new movie entry
operationId: create
security:
- Bearer: []
parameters:
- name: movie
required: true
in: body
description: a new movie details
schema:
$ref: "#/definitions/MovieBody"
responses:
"200":
description: a successfully stored movie details
schema:
$ref: "#/definitions/MovieBody"
default:
description: Error
schema:
$ref: "#/definitions/ErrorResponse"
/movies/{id}:
x-swagger-router-controller: movies
get:
description: get movie
operationId: show
security:
- Bearer: []
parameters:
- name: id
required: true
in: path
description: get particular movie details
type: string
responses:
"200":
description: Sucess
schema:
$ref: "#/definitions/MovieBody"
default:
description: Error
schema:
$ref: "#/definitions/ErrorResponse"
put:
produces:
- '*/*'
description: Update Movie
operationId: update
security:
- Bearer: []
parameters:
- name: id
required: true
in: path
type: string
- name: movie
required: true
in: body
description: an updated movie details
schema:
$ref: "#/definitions/MovieBody"
responses:
"200":
description: Sucess
default:
description: Error
schema:
$ref: "#/definitions/ErrorResponse"
delete:
description: Delete Single Record
operationId: deleted
security:
- Bearer: []
parameters:
- name: id
required: true
in: path
description: remove single record in db
type: string
responses:
"200":
description: Sucess
schema:
$ref: "#/definitions/MovieBody"
default:
description: Error
schema:
$ref: "#/definitions/ErrorResponse"
/login:
x-swagger-router-controller: movies
post:
description: Get Jwt Authentication Token
operationId: login
produces:
- application/json
- application/xml
parameters:
- name: Userdetails
required: true
in: body
description: Jwt Auth token
schema:
$ref: "#/definitions/LoginBody"
responses:
"200":
description: Sucess
schema:
$ref: "#/definitions/LoginBody"
default:
description: Error
schema:
$ref: "#/definitions/ErrorResponse"
/get:
x-swagger-router-controller: movies
get:
description: Get all Data
operationId: get
security:
- Bearer: []
parameters:
- name: name
in: query
description: The name of the person to whom to say hello
required: false
type: string
responses:
"200":
description: Success
schema:
# a pointer to a definition
$ref: "#/definitions/MovieListBody"
# responses may fall through to errors
default:
description: Error
schema:
$ref: "#/definitions/ErrorResponse"
definitions:
MovieListBody:
required:
- id
- movies
properties:
id:
type: integer
movies:
type: array
items:
$ref: "#/definitions/Movie"
Movie:
required:
- title
- gener
- year
properties:
title:
type: string
gener:
type: string
year:
type: integer
Login:
required:
- id
- name
- company
properties:
id:
type: integer
name:
type: string
company:
type: string
MovieBody:
required:
- movies
properties:
movies:
$ref: "#/definitions/Movie"
LoginBody:
required:
- details
properties:
details:
$ref: "#/definitions/Login"
ErrorResponse:
required:
- message
properties:
message:
type: string
Facing Issue
Error: Response validation failed: invalid content type (text/html). These are valid: application/json, */*

Grails 3.2.6 with spring security. In memory h2 database is not created when saving users

I didn't find a solution from other postings although this seems a problems that others have encountered.
This is my application.yml
---
grails:
profile: web-plugin
codegen:
defaultPackage: bioprofile
spring:
transactionManagement:
proxies: false
info:
app:
name: '#info.app.name#'
version: '#info.app.version#'
grailsVersion: '#info.app.grailsVersion#'
spring:
main:
banner-mode: "off"
groovy:
template:
check-template-location: false
# Spring Actuator Endpoints are Disabled by Default
endpoints:
enabled: false
jmx:
enabled: true
---
grails:
mime:
disable:
accept:
header:
userAgents:
- Gecko
- WebKit
- Presto
- Trident
types:
all: '*/*'
atom: application/atom+xml
css: text/css
csv: text/csv
form: application/x-www-form-urlencoded
html:
- text/html
- application/xhtml+xml
js: text/javascript
json:
- application/json
- text/json
multipartForm: multipart/form-data
pdf: application/pdf
rss: application/rss+xml
text: text/plain
hal:
- application/hal+json
- application/hal+xml
xml:
- text/xml
- application/xml
urlmapping:
cache:
maxsize: 1000
controllers:
defaultScope: singleton
converters:
encoding: UTF-8
views:
default:
codec: html
gsp:
encoding: UTF-8
htmlcodec: xml
codecs:
expression: html
scriptlets: html
taglib: none
staticparts: none
endpoints:
jmx:
unique-names: true
---
hibernate:
cache:
queries: false
use_second_level_cache: true
use_query_cache: false
region.factory_class: org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory
dataSources:
dataSource:
pooled: true
jmxExport: true
driverClassName: org.h2.Driver
username: sa
password:
dbCreate: create-drop
dialect : com.hp.opr.hibernate.dialect.H2Dialect
url: jdbc:h2:mem:blogDB;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
master:
pooled: true
jmxExport: true
driverClassName: org.h2.Driver
username: sa
password:
dbCreate: create-drop
url: jdbc:h2:mem:masterDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
but when the application starts and in the bootstrap I try to add some users:
User admin = new User(username: 'admin', password: 'password')
admin.save(flush: true)
User user = new User(username: 'user', password: 'user')
user.save(flsuh:true)
Role adminRole = new Role(authority: Role.ROLE_ADMIN)
adminRole.save(flush:true)
Role userRole = new Role(authority: Role.ROLE_USER)
userRole.save(flush:true)
UserRole.create(admin, adminRole)
UserRole.create(admin, userRole)
UserRole.create(user, userRole)
no database is created.
However if I open the console from the url: http://localhost:8080/dbconsole than a database is created.
Any idea why ?
You are using the in-memory configuration of H2 in your grails config, so no database file is created. But when you open the dbconsole, there problably is a connection string with a file instead of in-memory configuration, so a db file is created. Change the config in the dbconsole configuration.

grails incompatible with neo4j

I am trying to develop a sample application using grails and neo4j. I am using grails 3.0.8. I have installed the neo4j plugin and have followed the instructions as mentioned in the documentation. I have updated application.yml to include neo4j credentials. My application.yml looks something like this.
---
grails:
profile: web
codegen:
defaultPackage: sftwitter
info:
app:
name: '#info.app.name#'
version: '#info.app.version#'
grailsVersion: '#info.app.grailsVersion#'
spring:
groovy:
template:
check-template-location: false
---
grails:
mime:
disable:
accept:
header:
userAgents:
- Gecko
- WebKit
- Presto
- Trident
types:
all: '*/*'
atom: application/atom+xml
css: text/css
csv: text/csv
form: application/x-www-form-urlencoded
html:
- text/html
- application/xhtml+xml
js: text/javascript
json:
- application/json
- text/json
multipartForm: multipart/form-data
pdf: application/pdf
rss: application/rss+xml
text: text/plain
hal:
- application/hal+json
- application/hal+xml
xml:
- text/xml
- application/xml
urlmapping:
cache:
maxsize: 1000
controllers:
defaultScope: singleton
converters:
encoding: UTF-8
views:
default:
codec: html
gsp:
encoding: UTF-8
htmlcodec: xml
codecs:
expression: html
scriptlets: html
taglib: none
staticparts: none
---
grails:
neo4j:
type: rest
location: http://localhost:7474/db/data/
username: neo4j
password: welcome123
hibernate:
cache:
queries: false
use_second_level_cache: true
use_query_cache: false
region.factory_class: 'org.hibernate.cache.ehcache.EhCacheRegionFactory'
endpoints:
jmx:
unique-names: true
dataSource:
pooled: true
jmxExport: true
driverClassName: org.h2.Driver
username: sa
password:
environments:
development:
dataSource:
username: neo4j
password: welcome123
dbCreate: create-drop
url: jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
test:
dataSource:
dbCreate: update
url: jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
production:
dataSource:
dbCreate: update
url: jdbc:h2:./prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
properties:
jmxEnabled: true
initialSize: 5
maxActive: 50
minIdle: 5
maxIdle: 25
maxWait: 10000
maxAge: 600000
timeBetweenEvictionRunsMillis: 5000
minEvictableIdleTimeMillis: 60000
validationQuery: SELECT 1
validationQueryTimeout: 3
validationInterval: 15000
testOnBorrow: true
testWhileIdle: true
testOnReturn: false
jdbcInterceptors: ConnectionState
defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED
The code executes fine, but when I try to create the instance of a domain I get an error like this.
ERROR org.grails.web.errors.GrailsExceptionResolver - IllegalStateException occurred when processing request: [GET] /person/index
Method on class [neo4j.Person] was used outside of a Grails application. If running in the context of a test using the mocking API or bootstrap Grails correctly.. Stacktrace follows:
java.lang.reflect.InvocationTargetException: null
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_60]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0_60]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_60]
Caused by: java.lang.IllegalStateException: Method on class [neo4j.Person] was used outside of a Grails application. If running in the context of a test using the mocking API or bootstrap Grails correctly.
at neo4j.PersonController.index(PersonController.groovy:13) ~[main/:na]
at grails.transaction.GrailsTransactionTemplate$2.doInTransaction(GrailsTransactionTemplate.groovy:93) ~[grails-core-3.0.8.jar:3.0.8]
at grails.transaction.GrailsTransactionTemplate.execute(GrailsTransactionTemplate.groovy:90) ~[grails-core-3.0.8.jar:3.0.8]
... 3 common frames omitted
I have done this configuration completely as per the documentation, then why am I getting this error. Is it that the newer versions of grails are having compatibility issues with neo4j or is it that I have made some mistake in the configuration.

Resources