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

login error in spring boot app after creating a fresh app using jhipster 8.7.0 #27121

Open
javagrails opened this issue Aug 29, 2024 · 8 comments

Comments

@javagrails
Copy link

javagrails commented Aug 29, 2024

Overview of the issue

login error in spring boot app after creating a fresh app using jhipster 8.7.0

Motivation for or Use Case

Problem happen in spring boot app when Login button pressed in Angular app

DomainUserDetailsService class below method line

.map(user -> createSpringSecurityUser(login, user))
AND
.map(user -> createSpringSecurityUser(lowercaseLogin, user))

@Override
@Transactional(readOnly = true)
public UserDetails loadUserByUsername(final String login) {
    LOG.debug("Authenticating {}", login);

    if (new EmailValidator().isValid(login, null)) {
        return userRepository
            .findOneWithAuthoritiesByEmailIgnoreCase(login)
            .map(user -> createSpringSecurityUser(login, user))
            .orElseThrow(() -> new UsernameNotFoundException("User with email " + login + " was not found in the database"));
    }

    String lowercaseLogin = login.toLowerCase(Locale.ENGLISH);
    return userRepository
        .findOneWithAuthoritiesByLogin(lowercaseLogin)
        .map(user -> createSpringSecurityUser(lowercaseLogin, user))
        .orElseThrow(() -> new UsernameNotFoundException("User " + lowercaseLogin + " was not found in the database"));
}

AccountResource class below method line

.map(AdminUserDTO::new)

@GetMapping("/account")
public AdminUserDTO getAccount() {
    return userService
        .getUserWithAuthorities()
        .map(AdminUserDTO::new)
        .orElseThrow(() -> new AccountResourceException("User could not be found"));
}
Reproduce the error

? What is the base name of your application? jhesz
? Which type of application would you like to create? Monolithic application (recommended for simple projects)
? What is your default Java package name? com.jhesz.app
? Would you like to use Maven or Gradle for building the backend? Maven
? Do you want to make it reactive with Spring WebFlux? No
? Which type of authentication would you like to use? JWT authentication (stateless, with a token)
? Besides JUnit, which testing frameworks would you like to use?
? Which type of database would you like to use? SQL (H2, PostgreSQL, MySQL, MariaDB, Oracle, MSSQL)
? Which production database would you like to use? PostgreSQL
? Which development database would you like to use? H2 with disk-based persistence
? Which cache do you want to use? (Spring cache abstraction) Hazelcast (distributed cache, for multiple nodes, supports rate-limiting for gateway
applications)
? Do you want to use Hibernate 2nd level cache? Yes
? Which other technologies would you like to use? Elasticsearch as search engine, WebSockets using Spring Websocket, API first development using
OpenAPI-generator
? Which framework would you like to use for the client? Angular
? Besides Jest/Vitest, which testing frameworks would you like to use? Cypress
? Do you want to generate the admin UI? Yes
? Would you like to use a Bootswatch theme (https://bootswatch.com/)? Default JHipster
? Would you like to enable internationalization support? Yes
? Please choose the native language of the application English
? Please choose additional languages to install Arabic (Libya), Bengali, Turkish, Thai
? Would you like to generate code coverage for Cypress tests? [Experimental] Yes
? Would you like to audit Cypress tests? Yes

Suggest a Fix

may be related with Spring DevTools dependency and hot-reload settings I made false hot-reload {spring.devtools.restart.enabled=false} but still problem is there

JHipster Version(8.7.0)
JHipster configuration

Welcome to JHipster v8.7.0

Welcome to the JHipster Information Sub-Generator

[email protected] /Users/userpc/hipster/jhesz
└── [email protected]
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "applicationType": "monolith",
    "authenticationType": "jwt",
    "baseName": "jhesz",
    "buildTool": "maven",
    "cacheProvider": "hazelcast",
    "clientFramework": "angular",
    "clientTestFrameworks": [
      "cypress"
    ],
    "clientTheme": "none",
    "creationTimestamp": 1724919198469,
    "cypressAudit": true,
    "cypressCoverage": true,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "devServerPort": 4200,
    "enableHibernateCache": true,
    "enableSwaggerCodegen": true,
    "enableTranslation": true,
    "entities": [],
    "feignClient": null,
    "jhipsterVersion": "8.7.0",
    "languages": [
      "en",
      "ar-ly",
      "bn",
      "tr",
      "th"
    ],
    "messageBroker": false,
    "microfrontend": null,
    "microfrontends": [],
    "nativeLanguage": "en",
    "packageName": "com.jhesz.app",
    "prodDatabaseType": "postgresql",
    "reactive": false,
    "searchEngine": "elasticsearch",
    "serverPort": null,
    "serverSideOptions": [
      "searchEngine:elasticsearch",
      "websocket:spring-websocket",
      "enableSwaggerCodegen:true"
    ],
    "serviceDiscoveryType": false,
    "syncUserWithIdp": null,
    "testFrameworks": [
      "cypress"
    ],
    "websocket": "spring-websocket",
    "withAdminUi": true
  }
}
Environment and Tools

openjdk version "17" 2021-09-14
OpenJDK Runtime Environment (build 17+35-2724)
OpenJDK 64-Bit Server VM (build 17+35-2724, mixed mode, sharing)

git version 2.45.2

node: v20.17.0
npm: 10.8.2

Docker version 24.0.7, build afdd53b

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions

fresh-error

@mraible

@mraible
Copy link
Contributor

mraible commented Aug 29, 2024

@javagrails To provide all the information we need, please run jhipster info in your project's root folder, and copy/paste the result into the issue description. Please add ##### **JHipster configuration** before the output so our automation can verify.

@javagrails
Copy link
Author

@mraible I added the info of your given command

@qmonmert
Copy link
Contributor

@javagrails if you add System.setProperty("spring.devtools.restart.enabled", "false"); here:

    public static void main(String[] args) {
        SpringApplication app = new SpringApplication(JheszApp.class);
        DefaultProfileUtil.addDefaultProfile(app);
        System.setProperty("spring.devtools.restart.enabled", "false");
        Environment env = app.run(args).getEnvironment();
        logApplicationStartup(env);
    }

is it working?

Copy link
Contributor

github-actions bot commented Aug 29, 2024

JHipster has completed the sample check
.yo-rc.json: valid
Entities JDL: blank
Application: successfully generated
Frontend check: success
Backend check: success
E2E check: success

This check uses jhipster info output from the issue description to generate the sample.
Bug report that does not contain this information will be marked as invalid.

@qmonmert
Copy link
Contributor

Seems related to hazelcast/hazelcast#26361 if you generate the same app without hazelcast it works

@OmarHawk
Copy link
Contributor

Maybe fixed with #27063 ?

@javagrails
Copy link
Author

@javagrails if you add System.setProperty("spring.devtools.restart.enabled", "false"); here:

    public static void main(String[] args) {
        SpringApplication app = new SpringApplication(JheszApp.class);
        DefaultProfileUtil.addDefaultProfile(app);
        System.setProperty("spring.devtools.restart.enabled", "false");
        Environment env = app.run(args).getEnvironment();
        logApplicationStartup(env);
    }

is it working?

@qmonmert yes I tried both you mentioned and below

spring:
  devtools:
    restart:
      enabled: false  # true

in application-dev.yml file but same issue still there

I will check without hazelcast and inform here

@javagrails
Copy link
Author

@qmonmert it's true may the problem is hazelcast because when I use Ehcache it's working though I didn't try other cache like redis yet. Now my Question is a bit above @OmarHawk said Maybe fixed with #27063 seems it merged with main branch of jhipster .. so how can I use that main branch with my current project specifically for hazelcast fix or code gen

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

5 participants