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

Unable save data into Micro Service using Gateway UI #7018

Closed
1 task done
pavankjadda opened this issue Jan 19, 2018 · 13 comments
Closed
1 task done

Unable save data into Micro Service using Gateway UI #7018

pavankjadda opened this issue Jan 19, 2018 · 13 comments

Comments

@pavankjadda
Copy link

pavankjadda commented Jan 19, 2018

I set up my micro-services application with one microservice and one gateway. I generated micro service entities using jhipster import-jdl books.jh and entities UI in gateway. I used below JDL files to generate UI for entities in the gateway, and entities server code in microservices. I was looking at docs and issues raised by other people, I couldn't find proper to documentation to connect Micro Service entities with UI for those entities in the gateway through JDL import (should be able to specify the path of micro service similar to command line process). Correct me if my syntax is incorrect. Everything went well, when open I entity page and try to save the object, it did not save it. I got following error on console.

POST http://localhost:8080/api/addresses 404 error (not found)

Books Micro Service JDL file:

entity Address
{
	streetName	String required,
    apartmentOrHouseNumber	String,
    city	String	required,
    zipcode	Long	required,
    state	String,
    country	String
}

entity BookCoverType
{
	coverType	String	required
}


entity Author
{
	firstName	String	required,
    lastName	String	required,
    middleName	String,
}

entity Book 
{
	bookName String	required,
    bookTitle String	required,
    numberOfPages Integer	required,
}






relationship OneToOne 
{
	//Book{bookCoverType(coverType)} to BookCoverType
	Author{address(streetName)} to Address
}

relationship OneToMany 
{
	BookCoverType{book(bookTitle)} to Book
	Book{author(firstName)} to Author
    Author{book(bookTitle)} to Book
    
}


paginate Book with pagination
paginate Author with pagination

BookStore gateway JDL file:

entity Address
{
	streetName	String required,
    apartmentOrHouseNumber	String,
    city	String	required,
    zipcode	Long	required,
    state	String,
    country	String
}

entity BookCoverType
{
	coverType	String	required
}


entity Author
{
	firstName	String	required,
    lastName	String	required,
    middleName	String,
}

entity Book 
{
	bookName String	required,
    bookTitle String	required,
    numberOfPages Integer	required,
}




relationship OneToOne 
{
	//Book{bookCoverType(coverType)} to BookCoverType
	Author{address(streetName)} to Address
}

relationship OneToMany 
{
	BookCoverType{book(bookTitle)} to Book
	Book{author(firstName)} to Author
    Author{book(bookTitle)} to Book
    
}

skipServer *
microservice * with books

paginate Book with pagination
paginate Author with pagination

Address.json

{
    "fluentMethods": true,
    "relationships": [],
    "fields": [
        {
            "fieldName": "streetName",
            "fieldType": "String",
            "fieldValidateRules": [
                "required"
            ]
        },
        {
            "fieldName": "apartmentOrHouseNumber",
            "fieldType": "String"
        },
        {
            "fieldName": "city",
            "fieldType": "String",
            "fieldValidateRules": [
                "required"
            ]
        },
        {
            "fieldName": "zipcode",
            "fieldType": "Long",
            "fieldValidateRules": [
                "required"
            ]
        },
        {
            "fieldName": "state",
            "fieldType": "String"
        },
        {
            "fieldName": "country",
            "fieldType": "String"
        }
    ],
    "changelogDate": "20180119060434",
    "entityTableName": "address",
    "dto": "no",
    "pagination": "no",
    "service": "no",
    "jpaMetamodelFiltering": false,
    "skipServer": true
}
JHipster Version(s)
bookstore@0.0.0 /Users/pjadda/kubernetesapps/bookstore
└── generator-jhipster@4.13.3 

JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "com.bookstore"
    },
    "jhipsterVersion": "4.13.3",
    "baseName": "bookstore",
    "packageName": "com.bookstore",
    "packageFolder": "com/bookstore",
    "serverPort": "8080",
    "authenticationType": "jwt",
    "cacheProvider": "hazelcast",
    "enableHibernateCache": false,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "mysql",
    "prodDatabaseType": "mysql",
    "searchEngine": "elasticsearch",
    "messageBroker": false,
    "serviceDiscoveryType": "eureka",
    "buildTool": "maven",
    "enableSocialSignIn": false,
    "enableSwaggerCodegen": true,
    "jwtSecretKey": "replaced-by-jhipster-info",
    "clientFramework": "angularX",
    "useSass": true,
    "clientPackageManager": "yarn",
    "applicationType": "gateway",
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "enableTranslation": false
  }
}
JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions
entity Address (address) {
  streetName String required,
  apartmentOrHouseNumber String,
  city String required,
  zipcode Long required,
  state String,
  country String
}
entity BookCoverType (book_cover_type) {
  coverType String required
}
entity Author (author) {
  firstName String required,
  lastName String required,
  middleName String
}
entity Book (book) {
  bookName String required,
  bookTitle String required,
  numberOfPages Integer required
}

relationship OneToOne {
  Author{address(streetName)} to Address
}
relationship OneToMany {
  Book{author} to Author{book},
  BookCoverType{book} to Book{bookCoverType},
  Author{book} to Book{author}
}

paginate Author, Book with pagination

Environment and Tools

java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)

git version 2.13.1

node: v8.9.3

npm: 5.6.0

bower: 1.8.2

yarn: 1.3.2

Docker version 17.12.0-ce, build c97c6d6

docker-compose version 1.18.0, build 8dd22a9

Browsers and Operating System
macOS High Sierra, Chrome browser

  • Checking this box is mandatory (this is just to show you read everything)
@gmarziou
Copy link
Contributor

gmarziou commented Jan 19, 2018

I reformatted your text as it was a pain to read, next time please paste jhipster info output as is.

@gmarziou
Copy link
Contributor

gmarziou commented Jan 19, 2018

I'm not sure what you did exactly but it seems to me that you did not found the doc about generating entities in a microservices architecture. You don't need to use skip server.

@pavankjadda
Copy link
Author

@gmarziou I was able to generate entities. I was trying to generate UI for those entities in the gateway and perform CRUD operations.

@gmarziou
Copy link
Contributor

gmarziou commented Jan 19, 2018

My point is about what you did in gateway which looks strange to me but I might have misunderstood what you did exactly. Please list which command you ran on gateway.

@pavankjadda
Copy link
Author

@gmarziou Sorry for misunderstanding. Please look at the modified description. I used
$jhipster import-jdl books.jh in gateway folder.

@gmarziou
Copy link
Contributor

gmarziou commented Jan 19, 2018

Well the doc says to run the entity generator so jhipster entity <Entity name>.
I have never tried to run the jdl import generator in gateway maybe it works but from your 404 error it's clear that URL lacks the service prefix.
Also I don't understand how this process with JDL would work with many services, doc needs to be clarified by someone who knows about JDL.

@deepu105
Copy link
Member

import-jdl should work as well, but its a been a while since I tested it. But you should be using skipSever option and no need to have 2 JDL files, you should use the below JDL and run the same on both microservice and gateway

entity Address
{
	streetName	String required,
    apartmentOrHouseNumber	String,
    city	String	required,
    zipcode	Long	required,
    state	String,
    country	String
}

entity BookCoverType
{
	coverType	String	required
}


entity Author
{
	firstName	String	required,
    lastName	String	required,
    middleName	String,
}

entity Book 
{
	bookName String	required,
    bookTitle String	required,
    numberOfPages Integer	required,
}




relationship OneToOne 
{
	//Book{bookCoverType(coverType)} to BookCoverType
	Author{address(streetName)} to Address
}

relationship OneToMany 
{
	BookCoverType{book(bookTitle)} to Book
	Book{author(firstName)} to Author
    Author{book(bookTitle)} to Book
    
}

microservice * with books

paginate Book with pagination
paginate Author with pagination

@MathieuAA may be we should create a sample microservice JDL with a gateway and 2 microservices, WDYT?

@deepu105
Copy link
Member

@jpavanaryan please try it and let us know

@pavankjadda
Copy link
Author

@deepu105 Where should I specify skipServer option? JDL file (skipServer for *)or command line (jhipster import-jdl books.jh --skipServer)?

@ruddell
Copy link
Member

ruddell commented Jan 19, 2018

@jpavanaryan Because the entities are declared as microservice entities (microservice * with books), the server is automatically skipped.

@deepu105
Copy link
Member

@jpavanaryan I meant you shouldnt be using skipServer, it was a typo

@pavankjadda
Copy link
Author

pavankjadda commented Jan 19, 2018

Thanks, @deepu105 and @ruddell. It worked. It would be nice to have proper documentation for cases like this

@MathieuAA
Copy link
Member

@deepu105 Agreed.

@jdubois jdubois added this to the 4.14.0 milestone Jan 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants