{"action":"created","issue":{"url":"https://api.github.com/repos/jhipster/generator-jhipster/issues/7515","repository_url":"https://api.github.com/repos/jhipster/generator-jhipster","labels_url":"https://api.github.com/repos/jhipster/generator-jhipster/issues/7515/labels{/name}","comments_url":"https://api.github.com/repos/jhipster/generator-jhipster/issues/7515/comments","events_url":"https://api.github.com/repos/jhipster/generator-jhipster/issues/7515/events","html_url":"https://github.com/jhipster/generator-jhipster/issues/7515","id":316362447,"number":7515,"title":"When adding JHipster Entity Audit Generator v3.1.0 to a JHipster application v 4.14.3 turning on Hibernate Level 2 cache throws error on server startup.","user":{"login":"ssavageVT","id":20446573,"avatar_url":"https://avatars1.githubusercontent.com/u/20446573?v=4","gravatar_id":"","url":"https://api.github.com/users/ssavageVT","html_url":"https://github.com/ssavageVT","followers_url":"https://api.github.com/users/ssavageVT/followers","following_url":"https://api.github.com/users/ssavageVT/following{/other_user}","gists_url":"https://api.github.com/users/ssavageVT/gists{/gist_id}","starred_url":"https://api.github.com/users/ssavageVT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ssavageVT/subscriptions","organizations_url":"https://api.github.com/users/ssavageVT/orgs","repos_url":"https://api.github.com/users/ssavageVT/repos","events_url":"https://api.github.com/users/ssavageVT/events{/privacy}","received_events_url":"https://api.github.com/users/ssavageVT/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-04-20T18:09:47Z","updated_at":"2018-04-20T19:11:59Z","closed_at":"2018-04-20T18:39:29Z","author_association":"NONE","body":"##### **Overview of the issue**\r\n\r\nWhen adding JHipster Entity Audit Generator v3.1.0 to a JHipster application v 4.14.3 turning on Hibernate Level 2 cache throws error on server startup.\r\n\r\n##### **Motivation for or Use Case**\r\n\r\nClient needs to audit all entities with an application using the most current version of JHipster\r\n\r\n##### **Reproduce the error**\r\n\r\n-Generate a JHipster app, Hibernate Level 2 cache enabled\r\n\r\nWelcome to the JHipster Generator v4.14.3\r\n _______________________________________________________________________________________________________________\r\n\r\n  If you find JHipster useful consider supporting our collective https://opencollective.com/generator-jhipster\r\n  Documentation for creating an application: http://www.jhipster.tech/creating-an-app/\r\n _______________________________________________________________________________________________________________\r\n\r\nApplication files will be generated in folder: /Users/ssavage/webdev/bugfix\r\n? Which *type* of application would you like to create? Monolithic application (recommended for simple projects)\r\n? What is the base name of your application? bugfix\r\n? What is your default Java package name? com.ipponusa\r\n? Do you want to use the JHipster Registry to configure, monitor and scale your application? No\r\n? Which *type* of authentication would you like to use? JWT authentication (stateless, with a token)\r\n? Which *type* of database would you like to use? SQL (H2, MySQL, MariaDB, PostgreSQL, Oracle, MSSQL)\r\n? Which *production* database would you like to use? MySQL\r\n? Which *development* database would you like to use? H2 with disk-based persistence\r\n? Do you want to use the Spring cache abstraction? Yes, with the Ehcache implementation (local cache, for a single node)\r\n? Do you want to use Hibernate 2nd level cache? Yes\r\n? Would you like to use Maven or Gradle for building the backend? Maven\r\n? Which other technologies would you like to use? \r\n? Which *Framework* would you like to use for the client? Angular 5\r\n? Would you like to enable *SASS* support using the LibSass stylesheet preprocessor? No\r\n? Would you like to enable internationalization support? No\r\n? Besides JUnit and Karma, which testing frameworks would you like to use? \r\n? Would you like to install other generators from the JHipster Marketplace? No\r\n\r\n(probably optional)\r\n-Import a sample JDL file, overwrite all files\r\n-Use default example here: https://start.jhipster.tech/jdl-studio/\r\n\r\n$ jhipster import-jdl jhipster-jdl.jh\r\nUsing JHipster version installed locally in current project's node_modules\r\nExecuting jhipster:import-jdl jhipster-jdl.jh\r\n\r\n-Install generator-hipster-entity-audit\r\n\r\nnpm install -g generator-jhipster-entity-audit\r\n\r\n-Run Entity Audit Generator and overwrite all\r\n\r\n$ yo jhipster-entity-audit\r\nWelcome to the JHipster Entity Audit Generator! v3.1.0\r\n\r\n? Choose which audit framework you would like to use. Custom JHipster auditing (works with SQL)\r\n? Do you want to enable audit for all existing entities? Yes, update all\r\n? Do you want to add an audit log page for entities? Yes\r\n\r\nI'm Updating selected entities Country,Department,Employee,Job,JobHistory,Location,Region,Task\r\n\r\nMake sure these classes does not extend any other class to avoid any errors during compilation.\r\n\r\n-Run ./mvnw and observe the stack trace:\r\n\r\n2018-04-20 14:02:53.184  WARN 40171 --- [  restartedMain] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is java.lang.IllegalStateException: All Hibernate caches should be created upfront. Please update CacheConfiguration.java to add com.ipponusa.domain.EntityAuditEvent\r\n2018-04-20 14:02:53.217 DEBUG 40171 --- [  restartedMain] c.ehcache.core.Ehcache-usersByEmail      : Close successful.\r\n2018-04-20 14:02:53.229 DEBUG 40171 --- [  restartedMain] c.e.c.E.i.domain.Department.employees    : Close successful.\r\n2018-04-20 14:02:53.230 DEBUG 40171 --- [  restartedMain] c.e.c.Ehcache-com.ipponusa.domain.User   : Close successful.\r\n2018-04-20 14:02:53.231 DEBUG 40171 --- [  restartedMain] c.e.c.Ehcache-com.ipponusa.domain.Task   : Close successful.\r\n2018-04-20 14:02:53.232 DEBUG 40171 --- [  restartedMain] c.e.c.E.ipponusa.domain.Authority        : Close successful.\r\n2018-04-20 14:02:53.233 DEBUG 40171 --- [  restartedMain] c.e.c.E.ipponusa.domain.Employee.jobs    : Close successful.\r\n2018-04-20 14:02:53.234 DEBUG 40171 --- [  restartedMain] c.e.c.E.ipponusa.domain.Task.jobs        : Close successful.\r\n2018-04-20 14:02:53.235 DEBUG 40171 --- [  restartedMain] c.e.c.E.ipponusa.domain.Employee         : Close successful.\r\n2018-04-20 14:02:53.236 DEBUG 40171 --- [  restartedMain] c.e.c.Ehcache-com.ipponusa.domain.Job    : Close successful.\r\n2018-04-20 14:02:53.236 DEBUG 40171 --- [  restartedMain] c.e.c.E.ipponusa.domain.JobHistory       : Close successful.\r\n2018-04-20 14:02:53.237 DEBUG 40171 --- [  restartedMain] c.e.c.E.ipponusa.domain.Department       : Close successful.\r\n2018-04-20 14:02:53.238 DEBUG 40171 --- [  restartedMain] c.e.c.E.ipponusa.domain.Location         : Close successful.\r\n2018-04-20 14:02:53.239 DEBUG 40171 --- [  restartedMain] c.ehcache.core.Ehcache-usersByLogin      : Close successful.\r\n2018-04-20 14:02:53.240 DEBUG 40171 --- [  restartedMain] c.e.c.E.ipponusa.domain.Job.tasks        : Close successful.\r\n2018-04-20 14:02:53.241 DEBUG 40171 --- [  restartedMain] c.e.c.E.i.domain.User.authorities        : Close successful.\r\n2018-04-20 14:02:53.241 DEBUG 40171 --- [  restartedMain] c.e.c.E.ipponusa.domain.Region           : Close successful.\r\n2018-04-20 14:02:53.242 DEBUG 40171 --- [  restartedMain] c.e.c.E.ipponusa.domain.Country          : Close successful.\r\n2018-04-20 14:02:53.359 ERROR 40171 --- [  restartedMain] o.s.boot.SpringApplication               : Application startup failed\r\n\r\norg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is java.lang.IllegalStateException: All Hibernate caches should be created upfront. Please update CacheConfiguration.java to add com.ipponusa.domain.EntityAuditEvent\r\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1630)\r\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)\r\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)\r\n\tat org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)\r\n\tat org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)\r\n\tat org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)\r\n\tat org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)\r\n\tat org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1080)\r\n\tat org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:857)\r\n\tat org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)\r\n\tat org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)\r\n\tat org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)\r\n\tat org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)\r\n\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:303)\r\n\tat com.ipponusa.BugfixApp.main(BugfixApp.java:66)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\r\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n\tat java.lang.reflect.Method.invoke(Method.java:498)\r\n\tat org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)\r\nCaused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is java.lang.IllegalStateException: All Hibernate caches should be created upfront. Please update CacheConfiguration.java to add com.ipponusa.domain.EntityAuditEvent\r\n\tat org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:396)\r\n\tat org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:371)\r\n\tat org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:336)\r\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1688)\r\n\tat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1626)\r\n\t... 19 common frames omitted\r\nCaused by: java.lang.IllegalStateException: All Hibernate caches should be created upfront. Please update CacheConfiguration.java to add com.ipponusa.domain.EntityAuditEvent\r\n\tat io.github.jhipster.config.jcache.NoDefaultJCacheRegionFactory.createCache(NoDefaultJCacheRegionFactory.java:41)\r\n\tat org.hibernate.cache.jcache.JCacheRegionFactory.getOrCreateCache(JCacheRegionFactory.java:190)\r\n\tat org.hibernate.cache.jcache.JCacheRegionFactory.buildEntityRegion(JCacheRegionFactory.java:113)\r\n\tat org.hibernate.cache.spi.RegionFactory.buildEntityRegion(RegionFactory.java:132)\r\n\tat org.hibernate.internal.CacheImpl.determineEntityRegionAccessStrategy(CacheImpl.java:439)\r\n\tat org.hibernate.metamodel.internal.MetamodelImpl.initialize(MetamodelImpl.java:120)\r\n\tat org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:301)\r\n\tat org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:452)\r\n\tat org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:889)\r\n\tat org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60)\r\n\tat org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:360)\r\n\tat org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:384)\r\n\t... 23 common frames omitted\r\n\r\n##### **Suggest a Fix**\r\n\r\n-update com.xxx.config.CacheConfiguration and add the following lines:\r\n\t\r\n            cm.createCache(com.xxx.domain.EntityAuditEvent.class.getName(), jcacheConfiguration);\r\n\r\nOn this method:\r\npublic JCacheManagerCustomizer cacheManagerCustomizer() {\r\n        return cm -> {\r\n                    // jhipster-needle-ehcache-add-entry\r\n        };\r\n    }\r\n\r\n##### **JHipster Version(s)**\r\n\r\nJHipster Generator v4.14.3\r\n\r\n##### **JHipster configuration**\r\n\r\n<details>\r\n<summary>.yo-rc.json file</summary>\r\n<pre>\r\n{\r\n  \"generator-jhipster\": {\r\n    \"promptValues\": {\r\n      \"packageName\": \"com.ipponusa\"\r\n    },\r\n    \"jhipsterVersion\": \"4.14.3\",\r\n    \"baseName\": \"bugfix\",\r\n    \"packageName\": \"com.ipponusa\",\r\n    \"packageFolder\": \"com/ipponusa\",\r\n    \"serverPort\": \"8080\",\r\n    \"authenticationType\": \"jwt\",\r\n    \"cacheProvider\": \"ehcache\",\r\n    \"enableHibernateCache\": true,\r\n    \"websocket\": false,\r\n    \"databaseType\": \"sql\",\r\n    \"devDatabaseType\": \"h2Disk\",\r\n    \"prodDatabaseType\": \"mysql\",\r\n    \"searchEngine\": false,\r\n    \"messageBroker\": false,\r\n    \"serviceDiscoveryType\": false,\r\n    \"buildTool\": \"maven\",\r\n    \"enableSocialSignIn\": false,\r\n    \"enableSwaggerCodegen\": false,\r\n    \"jwtSecretKey\": \"replaced-by-jhipster-info\",\r\n    \"clientFramework\": \"angularX\",\r\n    \"useSass\": false,\r\n    \"clientPackageManager\": \"yarn\",\r\n    \"applicationType\": \"monolith\",\r\n    \"testFrameworks\": [],\r\n    \"jhiPrefix\": \"jhi\",\r\n    \"enableTranslation\": false\r\n  },\r\n  \"generator-jhipster-entity-audit\": {\r\n    \"auditFramework\": \"custom\"\r\n  }\r\n}\r\n</pre>\r\n</details>\r\n\r\n\r\n##### **JDL for the Entity configuration(s) `entityName.json` files generated in the `.jhipster` directory**\r\n\r\n<details>\r\n<summary>JDL entity definitions</summary>\r\n\r\n<pre>\r\nentity Region (region) {\r\n  regionName String\r\n}\r\nentity Country (country) {\r\n  countryName String\r\n}\r\n/**\r\n * not an ignored comment\r\n */\r\nentity Location (location) {\r\n  streetAddress String,\r\n  postalCode String,\r\n  city String,\r\n  stateProvince String\r\n}\r\nentity Department (department) {\r\n  departmentName String required\r\n}\r\n/**\r\n * Task entity.\r\n * @author The JHipster team.\r\n */\r\nentity Task (task) {\r\n  title String,\r\n  description String\r\n}\r\n/**\r\n * The Employee entity.\r\n */\r\nentity Employee (employee) {\r\n  /**\r\n   * The firstname attribute.\r\n   */\r\n  firstName String,\r\n  lastName String,\r\n  email String,\r\n  phoneNumber String,\r\n  hireDate Instant,\r\n  salary Long,\r\n  commissionPct Long\r\n}\r\nentity Job (job) {\r\n  jobTitle String,\r\n  minSalary Long,\r\n  maxSalary Long\r\n}\r\nentity JobHistory (job_history) {\r\n  startDate Instant,\r\n  endDate Instant,\r\n  language Language\r\n}\r\n\r\nenum Language {\r\n  FRENCH,\r\n  ENGLISH,\r\n  SPANISH\r\n}\r\n\r\nrelationship OneToOne {\r\n  Country{region} to Region,\r\n  Location{country} to Country,\r\n  Department{location} to Location,\r\n  JobHistory{job} to Job,\r\n  JobHistory{department} to Department,\r\n  JobHistory{employee} to Employee\r\n}\r\nrelationship OneToMany {\r\n  /**\r\n   * A relationship\r\n   */\r\n  Department{employee} to Employee{department},\r\n  Employee{job} to Job{employee}\r\n}\r\nrelationship ManyToOne {\r\n  Employee{manager} to Employee\r\n}\r\nrelationship ManyToMany {\r\n  Job{task(title)} to Task{job}\r\n}\r\n\r\ndto Region, Country, Location, Department, Task, Employee, Job, JobHistory with mapstruct\r\nservice Region, Country, Location, Department, Task, JobHistory with serviceImpl\r\nangularSuffix Region, Country, Location, Department, Task, Employee, Job, JobHistory with mySuffix\r\npaginate Employee, JobHistory with infinite-scroll\r\npaginate Job with pagination\r\n\r\n</pre>\r\n</details>\r\n\r\n\r\n##### **Environment and Tools**\r\n\r\njava version \"1.8.0_101\"\r\nJava(TM) SE Runtime Environment (build 1.8.0_101-b13)\r\nJava HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)\r\n\r\ngit version 2.10.0\r\n\r\nnode: v7.10.0\r\n\r\nnpm: 4.2.0\r\n\r\nbower: 1.8.0\r\n\r\ngulp:\r\n[14:04:39] CLI version 1.2.2\r\n\r\nyeoman: 2.0.2\r\n\r\nyarn: 0.24.6\r\n\r\nDocker version 1.12.0, build 8eab29e\r\n\r\ndocker-compose version 1.8.0, build f3628c7\r\n\r\n##### **Browsers and Operating System**\r\n\r\n<!-- What OS are you on? is this a problem with all browsers or only IE8? -->\r\n\r\n- [ X] Checking this box is mandatory (this is just to show you read everything)\r\n\r\n<!-- Love JHipster? Please consider supporting our collective:\r\n👉  https://opencollective.com/generator-jhipster/donate -->"},"comment":{"url":"https://api.github.com/repos/jhipster/generator-jhipster/issues/comments/383194332","html_url":"https://github.com/jhipster/generator-jhipster/issues/7515#issuecomment-383194332","issue_url":"https://api.github.com/repos/jhipster/generator-jhipster/issues/7515","id":383194332,"user":{"login":"ssavageVT","id":20446573,"avatar_url":"https://avatars1.githubusercontent.com/u/20446573?v=4","gravatar_id":"","url":"https://api.github.com/users/ssavageVT","html_url":"https://github.com/ssavageVT","followers_url":"https://api.github.com/users/ssavageVT/followers","following_url":"https://api.github.com/users/ssavageVT/following{/other_user}","gists_url":"https://api.github.com/users/ssavageVT/gists{/gist_id}","starred_url":"https://api.github.com/users/ssavageVT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ssavageVT/subscriptions","organizations_url":"https://api.github.com/users/ssavageVT/orgs","repos_url":"https://api.github.com/users/ssavageVT/repos","events_url":"https://api.github.com/users/ssavageVT/events{/privacy}","received_events_url":"https://api.github.com/users/ssavageVT/received_events","type":"User","site_admin":false},"created_at":"2018-04-20T19:11:59Z","updated_at":"2018-04-20T19:11:59Z","author_association":"NONE","body":"Sorry about that!  Will submit it over there.  Thanks!"}}
{"actor":{"display_login":"ssavageVT"}}