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

IllegalArgumentException "key cannot be empty or null" on freshly created project. (add steps to the guide or fix the issue) #26140

Closed
bdshadow opened this issue May 15, 2024 · 6 comments · Fixed by #26172

Comments

@bdshadow
Copy link

Overview of the issue

/mvnw build of the freshly created project fails with:

Caused by: java.lang.IllegalArgumentException: key cannot be empty or null
	at org.springframework.util.Assert.hasLength(Assert.java:205)
	at org.springframework.security.web.authentication.rememberme.AbstractRememberMeServices.<init>(AbstractRememberMeServices.java:101)
	at com.dbocharov.myapp.cms.security.PersistentTokenRememberMeServices.<init>(PersistentTokenRememberMeServices.java:72)
	at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:208)
	... 36 common frames omitted
Reproduce the error
  • project is created with the following choices:
Screenshot 2024-05-15 at 18 49 23
  • then database is started with: docker compose -f src/main/docker/postgresql.yml up -d
  • then /mvnw is run according to the readme and it failed
Related issues

#8584

Suggest a Fix

Looks like a property is missed in the applicatio.properties. Or some step needs to be added to the jhipster guide

JHipster Version(s)
dmitrii.bocharov A0111:~/dev/myapp$ jhipster --version
WARNING! Since JHipster v8, the jhipster command will not use the locally installed generator-jhipster.
    If you want to execute the locally installed generator-jhipster, run: npx jhipster
8.4.0
dmitrii.bocharov A0111:~/dev/myapp$ npx jhipster 8.4.0
(node:19832) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
FATAL! 8.4.0 is not a known command. See 'jhipster --help'.
JHipster configuration
Welcome to JHipster v8.4.0

Welcome to the JHipster Information Sub-Generator

myapp@0.0.1-SNAPSHOT /Users/dmitrii.bocharov/dev/myapp
└── generator-jhipster@8.4.0



##### **JHipster configuration, a `.yo-rc.json` file generated in the root folder**


<details>
<summary>.yo-rc.json file</summary>
<pre>
{
  "generator-jhipster": {
    "applicationType": "monolith",
    "authenticationType": "session",
    "baseName": "myapp",
    "buildTool": "maven",
    "cacheProvider": "caffeine",
    "clientFramework": "react",
    "clientTestFrameworks": [],
    "clientTheme": "minty",
    "clientThemeVariant": "primary",
    "creationTimestamp": 1715721355256,
    "databaseType": "sql",
    "devDatabaseType": "postgresql",
    "devServerPort": 9060,
    "enableHibernateCache": false,
    "enableSwaggerCodegen": false,
    "enableTranslation": false,
    "entities": [],
    "feignClient": null,
    "jhipsterVersion": "8.4.0",
    "messageBroker": false,
    "microfrontend": null,
    "microfrontends": [],
    "monorepository": true,
    "nativeLanguage": "en",
    "packageName": "com.dbocharov.myapp.cms",
    "prodDatabaseType": "postgresql",
    "reactive": false,
    "searchEngine": false,
    "serverPort": null,
    "serverSideOptions": [],
    "serviceDiscoveryType": false,
    "skipCommitHook": true,
    "syncUserWithIdp": null,
    "testFrameworks": [],
    "websocket": false,
    "withAdminUi": false
  }
}
</pre>
</details>


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

openjdk version "21.0.1" 2023-10-17
OpenJDK Runtime Environment GraalVM CE 21.0.1+12.1 (build 21.0.1+12-jvmci-23.1-b19)
OpenJDK 64-Bit Server VM GraalVM CE 21.0.1+12.1 (build 21.0.1+12-jvmci-23.1-b19, mixed mode, sharing)

git version 2.39.3 (Apple Git-146)

node: v22.1.0
npm: 10.7.0

Docker version 24.0.2, build cb74dfc

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

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

<pre>

</pre>
</details>
Browsers and Operating System

MacOS Sonoma 14.3.1

Copy link
Contributor

github-actions bot commented May 15, 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

Not reproduce on the main branch

image

@bdshadow
Copy link
Author

i've cloned and built jhipster locally from the main branch, used /bin/jhipster.cjs to generate a project from scratch. When tried to run /mvnw, got the same exception

@qmonmert
Copy link
Contributor

@bdshadow can you provide the file and the line in error please?

@bdshadow
Copy link
Author

here is the full stacktrace:

2024-05-16T11:24:48.917+02:00 ERROR 36853 --- [  restartedMain] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'securityConfiguration' defined in file [/Users/dmitrii.bocharov/dev/myapp/target/classes/com/dbocharov/myapp/cms/config/SecurityConfiguration.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'persistentTokenRememberMeServices' defined in file [/Users/dmitrii.bocharov/dev/myapp/target/classes/com/dbocharov/myapp/cms/security/PersistentTokenRememberMeServices.class]: Failed to instantiate [com.dbocharov.myapp.cms.security.PersistentTokenRememberMeServices]: Constructor threw exception
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:795)
	at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:237)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1355)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1192)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:562)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:975)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:962)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:624)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:334)
	at com.dbocharov.myapp.cms.MyApp.main(MyApp.java:70)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:50)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'persistentTokenRememberMeServices' defined in file [/Users/dmitrii.bocharov/dev/myapp/target/classes/com/dbocharov/myapp/cms/security/PersistentTokenRememberMeServices.class]: Failed to instantiate [com.dbocharov.myapp.cms.security.PersistentTokenRememberMeServices]: Constructor threw exception
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:318)
	at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:306)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1355)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1192)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:562)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1443)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1353)
	at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:904)
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:782)
	... 20 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.dbocharov.myapp.cms.security.PersistentTokenRememberMeServices]: Constructor threw exception
	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:221)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:111)
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:315)
	... 34 common frames omitted
Caused by: java.lang.IllegalArgumentException: key cannot be empty or null
	at org.springframework.util.Assert.hasLength(Assert.java:205)
	at org.springframework.security.web.authentication.rememberme.AbstractRememberMeServices.<init>(AbstractRememberMeServices.java:101)
	at com.dbocharov.myapp.cms.security.PersistentTokenRememberMeServices.<init>(PersistentTokenRememberMeServices.java:72)
	at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:208)
	... 36 common frames omitted

@mshima
Copy link
Member

mshima commented May 17, 2024

Happens with prompt only.
@bdshadow regenerate the project using the cli to fix inconsistencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants