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

Generating a reactive microservices architecture has compilation errors #12640

Closed
mraible opened this issue Oct 4, 2020 · 10 comments
Closed
Labels
area: bug 🐛 $$ bug-bounty $$ https://www.jhipster.tech/bug-bounties/ theme: angular theme: microservice theme: reactive ⚛️ Spring WebFlux $300 https://www.jhipster.tech/bug-bounties/
Milestone

Comments

@mraible
Copy link
Contributor

mraible commented Oct 4, 2020

Overview of the issue

I'm trying to create a reactive microservices architecture with the following JDL:

application {
  config {
    baseName gateway,
    reactive true,
    packageName com.okta.developer.gateway,
    applicationType gateway,
    authenticationType oauth2,
    prodDatabaseType postgresql,
    serviceDiscoveryType eureka,
    testFrameworks [protractor]
  }
  entities Blog, Post, Tag, Product
}

application {
  config {
    baseName blog,
    reactive true
    packageName com.okta.developer.blog,
    applicationType microservice,
    authenticationType oauth2,
    databaseType neo4j,
    devDatabaseType neo4j,
    prodDatabaseType neo4j,
    enableHibernateCache false,
    serverPort 8081,
    serviceDiscoveryType eureka
  }
  entities Blog, Post, Tag
}

application {
  config {
    baseName store,
    reactive true
    packageName com.okta.developer.store,
    applicationType microservice,
    authenticationType oauth2,
    databaseType mongodb,
    devDatabaseType mongodb,
    prodDatabaseType mongodb,
    enableHibernateCache false,
    searchEngine elasticsearch,
    serverPort 8082,
    serviceDiscoveryType eureka
  }
  entities Product
}

entity Blog {
  name String required minlength(3),
  handle String required minlength(2)
}

entity Post {
  title String required,
  content TextBlob required,
  date Instant required
}

entity Tag {
  name String required minlength(2)
}

entity Product {
  title String required,
  price BigDecimal required min(0),
  image ImageBlob
}

relationship ManyToOne {
  Blog{user(login)} to User,
  Post{blog(name)} to Blog
}

relationship ManyToMany {
  Post{tag(name)} to Tag{post}
}

paginate Post, Tag with infinite-scroll
paginate Product with pagination

microservice Product with store
microservice Blog, Post, Tag with blog

To use the latest code, I ran the following commands in my fork:

git pull upstream master
npm link

Then, I generated apps using jhipster jdl app.jdl.

When I try to run the gateway with ./mvnw -Pprod, I get a compilation error:

[INFO] ERROR in src/main/webapp/app/entities/blog/blog/blog-routing.module.ts:10:10 - error TS2305: Module '"./blog.module"' has no exported member 'BlogModule'.
[INFO]
[INFO] 10 import { BlogModule } from './blog.module';
[INFO]             ~~~~~~~~~~
[INFO] src/main/webapp/app/entities/blog/post/post-routing.module.ts:10:10 - error TS2305: Module '"./post.module"' has no exported member 'PostModule'.
[INFO]
[INFO] 10 import { PostModule } from './post.module';
[INFO]             ~~~~~~~~~~
[INFO] src/main/webapp/app/entities/blog/tag/tag-routing.module.ts:10:10 - error TS2305: Module '"./tag.module"' has no exported member 'TagModule'.
[INFO]
[INFO] 10 import { TagModule } from './tag.module';
[INFO]             ~~~~~~~~~
[INFO] src/main/webapp/app/entities/store/product/product-routing.module.ts:10:10 - error TS2305: Module '"./product.module"' has no exported member 'ProductModule'.
[INFO]
[INFO] 10 import { ProductModule } from './product.module';
[INFO]             ~~~~~~~~~~~~~
[INFO] src/main/webapp/app/entities/entity-routing.module.ts:9:83 - error TS2339: Property 'BlogBlogModule' does not exist on type 'typeof import("/Users/mraible/apps/gateway/src/main/webapp/app/entities/blog/blog/blog-routing.module")'.
[INFO]
[INFO] 9         loadChildren: () => import('./blog/blog/blog-routing.module').then(m => m.BlogBlogModule),
[INFO]                                                                                     ~~~~~~~~~~~~~~
[INFO] src/main/webapp/app/entities/entity-routing.module.ts:13:83 - error TS2339: Property 'BlogPostModule' does not exist on type 'typeof import("/Users/mraible/apps/gateway/src/main/webapp/app/entities/blog/post/post-routing.module")'.
[INFO]
[INFO] 13         loadChildren: () => import('./blog/post/post-routing.module').then(m => m.BlogPostModule),
[INFO]                                                                                      ~~~~~~~~~~~~~~
[INFO] src/main/webapp/app/entities/entity-routing.module.ts:17:81 - error TS2339: Property 'BlogTagModule' does not exist on type 'typeof import("/Users/mraible/apps/gateway/src/main/webapp/app/entities/blog/tag/tag-routing.module")'.
[INFO]
[INFO] 17         loadChildren: () => import('./blog/tag/tag-routing.module').then(m => m.BlogTagModule),
[INFO]                                                                                    ~~~~~~~~~~~~~
[INFO] src/main/webapp/app/entities/entity-routing.module.ts:21:90 - error TS2339: Property 'StoreProductModule' does not exist on type 'typeof import("/Users/mraible/apps/gateway/src/main/webapp/app/entities/store/product/product-routing.module")'.
[INFO]
[INFO] 21         loadChildren: () => import('./store/product/product-routing.module').then(m => m.StoreProductModule),
[INFO]                                                                                             ~~~~~~~~~~~~~~~~~~
[INFO]
[INFO] npm ERR! code ELIFECYCLE
[INFO] npm ERR! errno 2
[INFO] npm ERR! gateway@0.0.1-SNAPSHOT webpack: `node --max_old_space_size=4096 node_modules/webpack/bin/webpack.js "--config" "webpack/webpack.prod.js" "--profile"`
[INFO] npm ERR! Exit status 2
[INFO] npm ERR!
[INFO] npm ERR! Failed at the gateway@0.0.1-SNAPSHOT webpack script.

When I try to run the blog app with the same command, I get compilation errors in tests:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:testCompile (default-testCompile) on project blog: Compilation failure: Compilation failure:
[ERROR] /Users/mraible/apps/blog/src/test/java/com/okta/developer/blog/web/rest/TagResourceIT.java:[247,9] cannot find symbol
[ERROR]   symbol:   variable restTagMockMvc
[ERROR]   location: class com.okta.developer.blog.web.rest.TagResourceIT
[ERROR] /Users/mraible/apps/blog/src/test/java/com/okta/developer/blog/web/rest/TagResourceIT.java:[249,17] cannot find symbol
[ERROR]   symbol:   method patch(java.lang.String)
[ERROR]   location: class com.okta.developer.blog.web.rest.TagResourceIT
[ERROR] /Users/mraible/apps/blog/src/test/java/com/okta/developer/blog/web/rest/TagResourceIT.java:[254,24] cannot find symbol
[ERROR]   symbol:   method status()
[ERROR]   location: class com.okta.developer.blog.web.rest.TagResourceIT
[ERROR] /Users/mraible/apps/blog/src/test/java/com/okta/developer/blog/web/rest/TagResourceIT.java:[276,9] cannot find symbol
[ERROR]   symbol:   variable restTagMockMvc
[ERROR]   location: class com.okta.developer.blog.web.rest.TagResourceIT
[ERROR] /Users/mraible/apps/blog/src/test/java/com/okta/developer/blog/web/rest/TagResourceIT.java:[278,17] cannot find symbol
[ERROR]   symbol:   method patch(java.lang.String)
[ERROR]   location: class com.okta.developer.blog.web.rest.TagResourceIT
[ERROR] /Users/mraible/apps/blog/src/test/java/com/okta/developer/blog/web/rest/TagResourceIT.java:[283,24] cannot find symbol
[ERROR]   symbol:   method status()
[ERROR]   location: class com.okta.developer.blog.web.rest.TagResourceIT
[ERROR] /Users/mraible/apps/blog/src/test/java/com/okta/developer/blog/web/rest/TagResourceIT.java:[297,9] cannot find symbol
[ERROR]   symbol:   variable restTagMockMvc
[ERROR]   location: class com.okta.developer.blog.web.rest.TagResourceIT
[ERROR] /Users/mraible/apps/blog/src/test/java/com/okta/developer/blog/web/rest/TagResourceIT.java:[299,17] cannot find symbol
[ERROR]   symbol:   method patch(java.lang.String)
[ERROR]   location: class com.okta.developer.blog.web.rest.TagResourceIT
[ERROR] /Users/mraible/apps/blog/src/test/java/com/okta/developer/blog/web/rest/TagResourceIT.java:[304,24] cannot find symbol
[ERROR]   symbol:   method status()
[ERROR]   location: class com.okta.developer.blog.web.rest.TagResourceIT
[ERROR] /Users/mraible/apps/blog/src/test/java/com/okta/developer/blog/web/rest/PostResourceIT.java:[323,9] cannot find symbol
[ERROR]   symbol:   variable restPostMockMvc
[ERROR]   location: class com.okta.developer.blog.web.rest.PostResourceIT
[ERROR] /Users/mraible/apps/blog/src/test/java/com/okta/developer/blog/web/rest/PostResourceIT.java:[325,17] cannot find symbol
[ERROR]   symbol:   method patch(java.lang.String)
[ERROR]   location: class com.okta.developer.blog.web.rest.PostResourceIT
[ERROR] /Users/mraible/apps/blog/src/test/java/com/okta/developer/blog/web/rest/PostResourceIT.java:[330,24] cannot find symbol
[ERROR]   symbol:   method status()
[ERROR]   location: class com.okta.developer.blog.web.rest.PostResourceIT
[ERROR] /Users/mraible/apps/blog/src/test/java/com/okta/developer/blog/web/rest/PostResourceIT.java:[354,9] cannot find symbol
[ERROR]   symbol:   variable restPostMockMvc
[ERROR]   location: class com.okta.developer.blog.web.rest.PostResourceIT
[ERROR] /Users/mraible/apps/blog/src/test/java/com/okta/developer/blog/web/rest/PostResourceIT.java:[356,17] cannot find symbol
[ERROR]   symbol:   method patch(java.lang.String)
[ERROR]   location: class com.okta.developer.blog.web.rest.PostResourceIT
[ERROR] /Users/mraible/apps/blog/src/test/java/com/okta/developer/blog/web/rest/PostResourceIT.java:[361,24] cannot find symbol
[ERROR]   symbol:   method status()
[ERROR]   location: class com.okta.developer.blog.web.rest.PostResourceIT
[ERROR] /Users/mraible/apps/blog/src/test/java/com/okta/developer/blog/web/rest/PostResourceIT.java:[377,9] cannot find symbol
[ERROR]   symbol:   variable restPostMockMvc
[ERROR]   location: class com.okta.developer.blog.web.rest.PostResourceIT
[ERROR] /Users/mraible/apps/blog/src/test/java/com/okta/developer/blog/web/rest/PostResourceIT.java:[379,17] cannot find symbol
[ERROR]   symbol:   method patch(java.lang.String)
[ERROR]   location: class com.okta.developer.blog.web.rest.PostResourceIT
[ERROR] /Users/mraible/apps/blog/src/test/java/com/okta/developer/blog/web/rest/PostResourceIT.java:[384,24] cannot find symbol
[ERROR]   symbol:   method status()
[ERROR]   location: class com.okta.developer.blog.web.rest.PostResourceIT
[ERROR] /Users/mraible/apps/blog/src/test/java/com/okta/developer/blog/web/rest/BlogResourceIT.java:[314,9] cannot find symbol
[ERROR]   symbol:   variable restBlogMockMvc
[ERROR]   location: class com.okta.developer.blog.web.rest.BlogResourceIT
[ERROR] /Users/mraible/apps/blog/src/test/java/com/okta/developer/blog/web/rest/BlogResourceIT.java:[316,17] cannot find symbol
[ERROR]   symbol:   method patch(java.lang.String)
[ERROR]   location: class com.okta.developer.blog.web.rest.BlogResourceIT
[ERROR] /Users/mraible/apps/blog/src/test/java/com/okta/developer/blog/web/rest/BlogResourceIT.java:[321,24] cannot find symbol
[ERROR]   symbol:   method status()
[ERROR]   location: class com.okta.developer.blog.web.rest.BlogResourceIT
[ERROR] /Users/mraible/apps/blog/src/test/java/com/okta/developer/blog/web/rest/BlogResourceIT.java:[344,9] cannot find symbol
[ERROR]   symbol:   variable restBlogMockMvc
[ERROR]   location: class com.okta.developer.blog.web.rest.BlogResourceIT
[ERROR] /Users/mraible/apps/blog/src/test/java/com/okta/developer/blog/web/rest/BlogResourceIT.java:[346,17] cannot find symbol
[ERROR]   symbol:   method patch(java.lang.String)
[ERROR]   location: class com.okta.developer.blog.web.rest.BlogResourceIT
[ERROR] /Users/mraible/apps/blog/src/test/java/com/okta/developer/blog/web/rest/BlogResourceIT.java:[351,24] cannot find symbol
[ERROR]   symbol:   method status()
[ERROR]   location: class com.okta.developer.blog.web.rest.BlogResourceIT
[ERROR] /Users/mraible/apps/blog/src/test/java/com/okta/developer/blog/web/rest/BlogResourceIT.java:[366,9] cannot find symbol
[ERROR]   symbol:   variable restBlogMockMvc
[ERROR]   location: class com.okta.developer.blog.web.rest.BlogResourceIT
[ERROR] /Users/mraible/apps/blog/src/test/java/com/okta/developer/blog/web/rest/BlogResourceIT.java:[368,17] cannot find symbol
[ERROR]   symbol:   method patch(java.lang.String)
[ERROR]   location: class com.okta.developer.blog.web.rest.BlogResourceIT
[ERROR] /Users/mraible/apps/blog/src/test/java/com/okta/developer/blog/web/rest/BlogResourceIT.java:[373,24] cannot find symbol
[ERROR]   symbol:   method status()
[ERROR]   location: class com.okta.developer.blog.web.rest.BlogResourceIT
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Finally, in the store app, I get a compilation failure:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project store: Compilation failure
[ERROR] /Users/mraible/apps/store/src/main/java/com/okta/developer/store/web/rest/ProductResource.java:[154,21] incompatible types: cannot infer type-variable(s) R
[ERROR]     (argument mismatch; bad return type in lambda expression
[ERROR]       com.okta.developer.store.domain.Product cannot be converted to reactor.core.publisher.Mono<? extends R>)
[ERROR]
[ERROR] -> [Help 1]
Motivation for or Use Case

I'd like to write a blog post about our reactive microservices support.

Reproduce the error

Use latest code, npm link, create with JDL above, then run ./mvnw -Pprod in each directory.

JHipster Version(s)

Latest code on main branch.

JHipster configuration

I'm using Java 11.

openjdk 11.0.8 2020-07-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.8+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.8+10, mixed mode)
@pascalgrimaud
Copy link
Member

pascalgrimaud commented Oct 4, 2020

There are 2 problems:

@pascalgrimaud
Copy link
Member

Thanks @mshima : the angular part should be easy to fix. It's just related to naming with Microservice

@mshima
Copy link
Member

mshima commented Oct 4, 2020

@pascalgrimaud not so simple.

export class <%= locals.microserviceName ? upperFirstCamelCase(locals.microserviceName) : '' %><%= entityAngularName %>Module {}

The locals variables just doesn't exists and it's used in many places, I will try to identify when it was lost.

@mshima
Copy link
Member

mshima commented Oct 4, 2020

The locals variables just doesn't exists and it's used in many places, I will try to identify when it was lost.

Just found it's provided by ejs. <%= locals.microserviceName %> === <% microserviceName %>

@mraible
Copy link
Contributor Author

mraible commented Oct 8, 2020

I tried it again with the latest code. After generating all projects, I tried running ./mvnw -Pprod in them. Results:

  • gateway: Hangs after spring-boot-maven-plugin:2.3.4.RELEASE:run and AsciiArt
  • blog: Same errors
  • store: Same

Since I have the ability, I'm slapping a large bug bounty on this one. I'd love it if we had first-class reactive support.

@mraible mraible added $$ bug-bounty $$ https://www.jhipster.tech/bug-bounties/ $300 https://www.jhipster.tech/bug-bounties/ labels Oct 8, 2020
atomfrede added a commit to atomfrede/generator-jhipster that referenced this issue Oct 8, 2020
@atomfrede
Copy link
Member

atomfrede commented Oct 8, 2020

@mraible Blog and Store should compile (maybe you can check?) but I have test errors (404 when using patch).
Regarding the gateway not starting up, did you start the registry (and keycloak)? I had the exact same error (just hangs, but starting in IDEA revealed more logs) because my registry was crashing.

@mraible
Copy link
Contributor Author

mraible commented Oct 8, 2020

I tried creating everything again and the same compilation errors from above still happen on Blog and Store. It's possible I didn't have the registry running and that's why it didn't start before. I did have to start it a couple of times before it'd stay up, so thanks for that. Now I get the following error in the gateway:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 
'connectionFactory' defined in class path resource [org/springframework/boot/autoconfigure/r2dbc/ConnectionFactoryConfigurations$Pool.class]: 
Bean instantiation via factory method failed; nested exception is 
org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.r2dbc.pool.ConnectionPool]: 
Factory method 'connectionFactory' threw exception; nested exception is java.lang.IllegalArgumentException: 
Invalid URL: r2dbc:h2:file:./target/h2db/db/gateway;DB_CLOSE_DELAY=-1

@atomfrede
Copy link
Member

The h2 problem I also realized. I think there was a similar problem once on the micronaut blueprint. Will have a look. Regarding the compilation errors are you sure you have used this branch to generate again?

@atomfrede
Copy link
Member

atomfrede commented Oct 9, 2020

The correct r2dbc url looks like this url: r2dbc:h2:file://././target/h2db/db/reactiveundertow;DB_CLOSE_DELAY=-1, see https://github.com/r2dbc/r2dbc-h2 and r2dbc/r2dbc-h2#150. So first it must be // to fix the startup error and ././ to fix the non implicit db file path during runtime.

atomfrede added a commit to atomfrede/generator-jhipster that referenced this issue Oct 12, 2020
mshima pushed a commit to mshima/generator-jhipster that referenced this issue Oct 13, 2020
@atomfrede
Copy link
Member

As #12688 is merged I think this can be closed. regarding the bounty, I will donate parts of that to

mshima pushed a commit to mshima/generator-jhipster that referenced this issue Oct 14, 2020
@pascalgrimaud pascalgrimaud added this to the 7.0.0 milestone Oct 18, 2020
Tcharl pushed a commit to Tcharl/generator-jhipster that referenced this issue Nov 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: bug 🐛 $$ bug-bounty $$ https://www.jhipster.tech/bug-bounties/ theme: angular theme: microservice theme: reactive ⚛️ Spring WebFlux $300 https://www.jhipster.tech/bug-bounties/
Projects
None yet
Development

No branches or pull requests

4 participants