Generator-jhipster: Importing .jh/JDL-Studio generated file results in error

Created on 25 Feb 2018  Â·  24Comments  Â·  Source: jhipster/generator-jhipster

Overview of the issue

I'm importing the following .jh file :

enum EventType {
    DUNGEON_OPENED, 
    GOLD_CHANGED, 
    MONSTER_SPAWNED, 
    REALM_CLOSED
}



enum Server {
    USWEST,
    USEAST,
    ASIASOUTHEAST,
    USSOUTH,
    USSOUTHWEST,
    USEAST2,
    USNORTHWEST,
    ASIAEAST,
    EUSOUTHWEST,
    USSOUTH2,
    EUNORTH2,
    EUSOUTH,
    USSOUTH3,
    EUWEST2,
    USMIDWEST,
    EUWEST,
    USEAST3,
    USWEST3,
    USMIDWEST2,
    EUEAST,
    AUSTRALIA,
    EUNORTH,
    USWEST2
}

entity EventData {
    position Position,
    eventType EventType,
    player Player
}

entity Position {
    mapName String,
    server Server,
    x Float,
    y Float
}

relationship ManyToOne {
    EventData{player} to Player
}

entity Player {
    accountId Long
}

entity RealmSpyUser {
    player Player required
}

relationship OneToOne {
    RealmSpyUser{player} to Player
}

relationship OneToOne {
    EventData{position} to Position
}

service all with serviceImpl
paginate EventData with infinite-scroll

And I'm getting

The jdl is being parsed.
warn: The method 'JDLParser::parse' is deprecated and will be removed in the next major release. Please use 'JDLParser::parseFromConfigurationObject' instead.
DEBUG! Error:
{ name: 'WrongTypeException',
  message: 'The type \'GamePosition\' doesn\'t exist for mysql.',
  prototype: Error
    at new BuildException (E:\Files\Projects\RotMG\RotMG\RealmSpy\node_modules\jhipster-core\lib\exceptions\exception_factory.js:59:25)
    at getFields (E:\Files\Projects\RotMG\RotMG\RealmSpy\node_modules\jhipster-core\lib\parser\jdl_parser.js:175:13)
    at fillClassesAndFields (E:\Files\Projects\RotMG\RotMG\RealmSpy\node_modules\jhipster-core\lib\parser\jdl_parser.js:135:15)
    at parseFromConfigurationObject (E:\Files\Projects\RotMG\RotMG\RealmSpy\node_modules\jhipster-core\lib\parser\jdl_parser.js:86:3)
    at Object.parse [as convertToJDL] (E:\Files\Projects\RotMG\RotMG\RealmSpy\node_modules\jhipster-core\lib\parser\jdl_parser.js:64:10)
    at module.exports.parseJDL (E:\Files\Projects\RotMG\RotMG\RealmSpy\node_modules\generator-jhipster\generators\import-jdl\index.js:89:47)
    at Object.<anonymous> (E:\Files\Projects\RotMG\RotMG\RealmSpy\node_modules\yeoman-generator\lib\index.js:399:25)
    at E:\Files\Projects\RotMG\RotMG\RealmSpy\node_modules\run-async\index.js:25:25
    at new Promise (<anonymous>)
    at E:\Files\Projects\RotMG\RotMG\RealmSpy\node_modules\run-async\index.js:24:19 }
WrongTypeException: The type 'GamePosition' doesn't exist for mysql.
events.js:183
      throw er; // Unhandled 'error' event
      ^
Reproduce the error

The following command :
jhipster import-jdl jhipster-jdl.jh --debug

JHipster Version(s)

v4.14.0

JHipster configuration

`Welcome to the JHipster Information Sub-Generator

JHipster Version(s)
[email protected] E:\Files\Projects\RotMG\RotMG\RealmSpy
`-- (empty)

JHipster configuration, a .yo-rc.json file generated in the root folder
<details>
<summary>.yo-rc.json file</summary>
<pre>
{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "com.realmspy"
    },
    "jhipsterVersion": "4.14.0",
    "baseName": "realmdata",
    "packageName": "com.realmspy",
    "packageFolder": "com/realmspy",
    "serverPort": "8080",
    "authenticationType": "session",
    "cacheProvider": "ehcache",
    "enableHibernateCache": false,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "h2Memory",
    "prodDatabaseType": "mysql",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": false,
    "buildTool": "maven",
    "enableSocialSignIn": false,
    "enableSwaggerCodegen": false,
    "rememberMeKey": "replaced-by-jhipster-info",
    "clientFramework": "angularX",
    "useSass": false,
    "clientPackageManager": "yarn",
    "applicationType": "monolith",
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "enableTranslation": false
  }
}
</pre>
</details>


##### **JDL for the Entity configuration(s) `entityName.json` files generated in the `.jhipster` directory**

<details>
<summary>JDL entity definitions</summary>

<pre>




</pre>
</details>


##### **Environment and Tools**

java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)

git version 2.16.1.windows.1

node: v8.9.4

npm: 5.6.0

gulp:
[11:34:13] CLI version 2.0.1

yeoman: 2.0.1

yarn: 1.3.2

Docker version 17.12.0-ce, build c97c6d6

docker-compose version 1.18.0, build 8dd22a96

`

Most helpful comment

First of, the deprecation warning shouldn't have been there, I'll remove it...
And you haven't read the doc.
The issue is that you have a field having a type named Position, which is an entity. Composition/Aggregation is handled through relationships.
Here you go:

enum EventType {
    DUNGEON_OPENED, 
    GOLD_CHANGED, 
    MONSTER_SPAWNED, 
    REALM_CLOSED
}

enum Server {
    USWEST,
    USEAST,
    ASIASOUTHEAST,
    USSOUTH,
    USSOUTHWEST,
    USEAST2,
    USNORTHWEST,
    ASIAEAST,
    EUSOUTHWEST,
    USSOUTH2,
    EUNORTH2,
    EUSOUTH,
    USSOUTH3,
    EUWEST2,
    USMIDWEST,
    EUWEST,
    USEAST3,
    USWEST3,
    USMIDWEST2,
    EUEAST,
    AUSTRALIA,
    EUNORTH,
    USWEST2
}

entity EventData {
    eventType EventType
}

entity Position {
    mapName String,
    server Server,
    x Float,
    y Float
}

relationship ManyToOne {
    EventData{player} to Player
}

entity Player {
    accountId Long
}

entity RealmSpyUser {
    player Player required
}

relationship OneToOne {
    RealmSpyUser{player} to Player
}

relationship OneToOne {
    EventData{position} to Position
}

service all with serviceImpl
paginate EventData with infinite-scroll

All 24 comments

First of, the deprecation warning shouldn't have been there, I'll remove it...
And you haven't read the doc.
The issue is that you have a field having a type named Position, which is an entity. Composition/Aggregation is handled through relationships.
Here you go:

enum EventType {
    DUNGEON_OPENED, 
    GOLD_CHANGED, 
    MONSTER_SPAWNED, 
    REALM_CLOSED
}

enum Server {
    USWEST,
    USEAST,
    ASIASOUTHEAST,
    USSOUTH,
    USSOUTHWEST,
    USEAST2,
    USNORTHWEST,
    ASIAEAST,
    EUSOUTHWEST,
    USSOUTH2,
    EUNORTH2,
    EUSOUTH,
    USSOUTH3,
    EUWEST2,
    USMIDWEST,
    EUWEST,
    USEAST3,
    USWEST3,
    USMIDWEST2,
    EUEAST,
    AUSTRALIA,
    EUNORTH,
    USWEST2
}

entity EventData {
    eventType EventType
}

entity Position {
    mapName String,
    server Server,
    x Float,
    y Float
}

relationship ManyToOne {
    EventData{player} to Player
}

entity Player {
    accountId Long
}

entity RealmSpyUser {
    player Player required
}

relationship OneToOne {
    RealmSpyUser{player} to Player
}

relationship OneToOne {
    EventData{position} to Position
}

service all with serviceImpl
paginate EventData with infinite-scroll

Thank you Mathieu, sorry for the useless issue!

Don't sweat it :) happy to help

Edit: deprecation warnings have been removed, but there was no release.

I don't want to open another issue, I'd post it on stackoverflow but I'm banned from it... Can you help me with something? When I generate using the script it creates an empty field like this

entity EventData {
    eventType EventType,
    object String,
    mapName String required,
    server Server required,
    x Float,
    y Float
}

relationship ManyToOne {
    EventData{player} to Player
}

/* A RotMG Player **/
entity Player {
    accountId Long,
    name String
}


relationship OneToOne {
    Player to RSUser{player}
}

entity RSUser {
    migrateThisToUser String
}


enum EventType {
    DUNGEON_OPENED, 
    GOLD_CHANGED, 
    MONSTER_SPAWNED, 
    REALM_CLOSED
}



enum Server {
    USWEST,
    USEAST,
    ASIASOUTHEAST,
    USSOUTH,
    USSOUTHWEST,
    USEAST2,
    USNORTHWEST,
    ASIAEAST,
    EUSOUTHWEST,
    USSOUTH2,
    EUNORTH2,
    EUSOUTH,
    USSOUTH3,
    EUWEST2,
    USMIDWEST,
    EUWEST,
    USEAST3,
    USWEST3,
    USMIDWEST2,
    EUEAST,
    AUSTRALIA,
    EUNORTH,
    USWEST2
}

image

image

I think it's because of that :

Player to RSUser{player}

instead of

Player{player} to RSUser

Is there something to avoid using this incorrect syntax?

You're actually banned from using SO?! Nice!

The first snippet injects an instance of Player into RSUser (RSUser will have a field named player).
The other one is the opposite (and does not make much sense by the way): Playerwill have an instance of RSUser named player inside.

About the error, it seems you have a field named public, which is kinda bad as it's indeed a reserved keyword. It's weird as your JDL doesn't contain anything named public. There's something fishy here.

If you don't find the solution, I suggest you ask on Gitter. If you actually think this is a bug, post a new issue here.

Yes! I got banned twice!

SO loves micro managing everything and now they weeded me out because I asked too much questions.

I'll keep trying to find the bug.

@MathieuAA The following JDL results in an empty relationshipName field in .jhipster/Player.json. Is this a JDL issue or should we check for an undefined relationshipName in the entity generator?

entity Player
entity RSUser
relationship OneToOne {
    Player to RSUser{player}
}
{
    "fields": [],
    "relationships": [
        {
            "relationshipType": "one-to-one",
            "relationshipName": "",
            "otherEntityName": "rSUser",
            "otherEntityField": "id",
            "ownerSide": true,
            "otherEntityRelationshipName": "player"
        }
    ],
    "changelogDate": "20180225201844",
    "entityTableName": "player",
    "dto": "no",
    "pagination": "no",
    "service": "no",
    "jpaMetamodelFiltering": false,
    "fluentMethods": true,
    "clientRootFolder": ""
}

@ruddell let me confirm it, but I think this is one of mine. If JCore produced this JSON, then this comes from the JCore project, but there should be a good reason behind it.

There's no error so I guess this is either a legitimate yet wrong use case (the relationship should be the other way around), or something forgotten.

@ruddell this use case should be forbidden as it leads to invalid Java files. I'll add an issue in JCore's issue tracker to do it. @iObsidian the relationship should work the other way around (if not, there's a regression in the generator).

entity Player
entity RSUser
relationship OneToOne {
    RSUser{player} to Player
}

thanks @ruddell for pushing this :)

Hey @MathieuAA , I can't put issues on the jhipster github.io website... But the page http://www.jhipster.tech/using-websockets/ is incorrect as the article states :

JHipster provides a simple “tracker” example out-of-the-box. Located in the admin menu

I think you guys removed it but didn't update the page...

I'm looking for a way to enable websockets 'the jhipster way'... Couldn't find any tutorial

@iObsidian Your config shows "websocket": false, you need to choose to enable websockets for the "tracker" example to show up. The prompt where the websocket choice is "Which other technologies would you like to use?"

Thank you! I was sure I had websockets enabled! This makes it work.

I know I've been all around the places and this isn't nowhere near a good place to ask this, but is this tutorial :

http://www.jhipster.tech/using-kafka/

Suposed to work 'as is'?

I'm getting an error

java.net.ConnectException: Connection refused: no further information
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
    at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
    at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1141)

2018-03-03 23:06:04.089  WARN 10144 --- [127.0.0.1:2181)] org.apache.zookeeper.ClientCnxn          : Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect

java.net.ConnectException: Connection refused: no further information
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
    at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
    at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1141)

And this goes in loop forever

I think I'm missing a step here

image

But I'm not sure what to do

It looks like you didn't start Zookeeper or Kafka but I can't tell. Please keep in mind this is our issue tracker, not a question forum.

If you have a question please use Stack Overflow, and tag the question with jhipster. This helps the project to keep the issue tracker clean. Also, Stack Overflow will give your question a larger audience:

  • This will increase your chances to get an answer
  • Answers will be of higher quality, as there is a voting system
  • This will also help other users who might have the same issue, as questions are tagged and easily searchable

Another option is using our Gitter chat, for bigger questions StackOverflow can be better.

If you think you have an issue, please open a new one and fill out the template instead of commenting on an old/unrelated issue.

Yes I understand and I apologize

Yes the Kafka sample should work, you need to run Kafka+Zookeeper with Docker.
I improved it 2 days ago so I know it works, and next release will be better.

Bonjour Julien je suis terriblement novice... Comment fait-on pour faire
tourner Kafka et Zookeeper? Est-ce que il a une commande pour faciliter la
tâche?

2018-03-04 3:16 GMT-05:00 Julien Dubois notifications@github.com:

Yes the Kafka sample should work, you need to run Kafka+Zookeeper with
Docker.
I improved it 2 days ago so I know it works, and next release will be
better.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/jhipster/generator-jhipster/issues/7173#issuecomment-370210491,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AEFAM6lr5_Ek1_BA-AYxYqkjHSFP2Pdrks5ta6LTgaJpZM4SSXBK
.

https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail
Garanti
sans virus. www.avast.com
https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

En anglais SVP.

Please read the doc, http://www.jhipster.tech/using-kafka/
If you are a real beginner, it might be a good idea to start with a simpler architecture than one using Kafka.

ensé que Apache Kafka era relativamente simple teniendo en cuenta el
tutorial y que tengo muchos años de experiencia con Java.

Woops wrong language

Also thanks for the link I just realised I didn't read that line :

Compose configuration file is generated and you can start Kafka with the
command:

docker-compose -f src/main/docker/kafka.yml up -d

https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail
Garanti
sans virus. www.avast.com
https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

Hi guys. Sorry but where I found '.jhipster/...' ?

@paulordie please don't comment on old issues, especially if it's unrelated.
The .jhipster folder is in the root folder of your app.

Was this page helpful?
0 / 5 - 0 ratings