jhipster / generator-jhipster

JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
https://www.jhipster.tech
Apache License 2.0
21.54k stars 4.02k forks source link

JHipster application is throwing error on production build #8497

Closed arabbani closed 6 years ago

arabbani commented 6 years ago
Overview of the issue

I'm using JHipster v5.4.2. The project works fine during development. But after i have generated a executable war for production, it is throwing the following error:

Motivation for or Use Case
Reproduce the error

` Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'servletEndpointRegistrar' defined in class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration$WebMvcServletEndpointManagementContextConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar]: Factory method 'servletEndpointRegistrar' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'auditEventsEndpoint' defined in class path resource [org/springframework/boot/actuate/autoconfigure/audit/AuditEventsEndpointAutoConfiguration.class]: Unsatisfied dependency expressed through method 'auditEventsEndpoint' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'customAuditEventRepository' defined in URL [jar:file:/D:/Projects/arif/fb-quiz/target/fb-quiz-0.0.1-SNAPSHOT.war!/WEB-INF/classes!/com/creatives/apsstr/repository/CustomAuditEventRepository.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'persistenceAuditEventRepository': Cannot create inner bean '(inner bean)#1a87b51' of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property 'entityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#1a87b51': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.boot.archive.spi.ArchiveException: Could not build ClassFile 2018-10-07 21:30:32.887 DEBUG 9436 --- [ main] Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.

Related issues
Suggest a Fix
JHipster Version(s)
JHipster Version(s)
fb-quiz@0.0.0 D:\Projects\arif\fb-quiz                                                                                           
`-- generator-jhipster@5.4.2                                                                                                     
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
                                                                                                                            
{                                                                                                                                
  "generator-jhipster": {                                                                                                        
    "promptValues": {                                                                                                            
      "packageName": "com.creatives.apsstr"                                                                                      
    },                                                                                                                           
    "jhipsterVersion": "5.4.2",                                                                                                  
    "applicationType": "monolith",                                                                                               
    "baseName": "FbQuiz",                                                                                                        
    "packageName": "com.creatives.apsstr",                                                                                       
    "packageFolder": "com/creatives/apsstr",                                                                                     
    "serverPort": "8080",                                                                                                        
    "authenticationType": "session",                                                                                             
    "cacheProvider": "ehcache",                                                                                                  
    "enableHibernateCache": true,                                                                                                
    "websocket": false,                                                                                                          
    "databaseType": "sql",                                                                                                       
    "devDatabaseType": "mysql",                                                                                                  
    "prodDatabaseType": "mysql",                                                                                                 
    "searchEngine": false,                                                                                                       
    "messageBroker": false,                                                                                                      
    "serviceDiscoveryType": false,                                                                                               
    "buildTool": "maven",                                                                                                        
    "enableSwaggerCodegen": false,                                                                                               
    "rememberMeKey": "YourJWTSecretKeyWasReplacedByThisMeaninglessTextByTheJHipsterInfoCommandForObviousSecurityReasons",        
    "clientFramework": "angularX",                                                                                               
    "useSass": true,                                                                                                             
    "clientPackageManager": "npm",                                                                                               
    "testFrameworks": [],                                                                                                        
    "jhiPrefix": "apsstr",                                                                                                       
    "enableTranslation": false                                                                                                   
  }                                                                                                                              
}                                                                                                                                
Environment and Tools

java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)

git version 2.19.0.windows.1

node: v8.12.0

npm: 6.4.1

JHipster configuration
Entity configuration(s) entityName.json files generated in the .jhipster directory
Browsers and Operating System
jdubois commented 6 years ago

As there are many ways to do this, could you give the exact commands you use to build the application and to run it?

arabbani commented 6 years ago

Build command : mvnw -Pprod package Run command: java -jar fb-quiz-0.0.1-SNAPSHOT.war

jdubois commented 6 years ago

For running it you don't need the "java -jar" part (but it won't solve your issue). And what about your database, can you log in and see the schema?

arabbani commented 6 years ago

yes

arabbani commented 6 years ago

I can log in with the database and see schema

jdubois commented 6 years ago

I just tried with your configuration and commands and I can't reproduce :-(

Do you have anything else in your logs? Maybe you changed something from the original generated project?

arabbani commented 6 years ago

I just removed ${hibernate.version} from pom as it was managed by spring boot

deepu105 commented 6 years ago

Can you put the hibernate version back in and try? I think we specify that for a reason

Thanks & Regards, Deepu

On Mon, Oct 8, 2018 at 10:45 AM Arif Rabbani notifications@github.com wrote:

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

entity UserQuizInput { uiText String maxlength(100) required, name String maxlength(50) required, type UserQuizInputType required } entity Quiz { name String maxlength(70) required, description String maxlength(120) required, active Boolean required, publishDate ZonedDateTime required, waitingUiText String maxlength(200), image String required, alternateImage String } entity FbRole { name String maxlength(70) required } entity Category { name String maxlength(50) required } entity OptionType { name String maxlength(100) required } entity QuizOption { text String maxlength(1000) required, image String, gender Gender required } entity TextCoordinate { text String maxlength(1000) required, color String maxlength(7) required, font String maxlength(50) required, fontSize Integer required, topLeftX Integer required, topLeftY Integer required, bottomRightX Integer required, bottomRightY Integer required } entity ImageCoordinate { image String required, circle Boolean required, topLeftX Integer required, topLeftY Integer required, bottomRightX Integer required, bottomRightY Integer required } entity QuizResult { baseImage String required } entity CalculationConfig { calculationStart Integer required, calculationEnd Integer required } entity CodeBlock { name String required, params String maxlength(1000), resultTags String maxlength(1000) required } entity ResultOption { matchGender GenderMatch, resultName String maxlength(100) required, optionCount Integer required, excludeFriendOptions Boolean required, type QuizType } entity UserQuizResultOption { resultOptionId Long required, options String required } entity UserQuiz { userId Long required, userSocialId String required, testDate ZonedDateTime required } entity ExecuteBlock { params String maxlength(1000) } entity Trivia { name String maxlength(70) required, description String maxlength(120), image String required, active Boolean required, publishDate ZonedDateTime required } entity TriviaQuestion { name String required, image String, answerType AnswerType required } entity TriviaAnswer { text String, image String, correctAnswer Boolean } entity TriviaResult { fromMark Integer required, toMark Integer required, text String required } entity TriviaCategory { name String maxlength(100) required } entity Poll { name String maxlength(70) required, description String maxlength(120) required, active Boolean required, startDate ZonedDateTime required, endDate ZonedDateTime required, image String required, resultImage String, optionType AnswerType } entity PollOption { text String, image String, vote Integer } entity PollCategory { name String maxlength(70) required }

enum UserQuizInputType { TEXT, DP_IMAGE, EXTRA_IMAGE }

enum Gender { MALE, FEMALE, OTHER, NONE }

enum GenderMatch { SAME, OPPOSITE, HUMAN, HUMAN_OR_NONE, SAME_OR_NONE, OPPOSITE_OR_NONE, ANY }

enum QuizType { CALCULATION, DEFINED_OPTION, FB_PROFILE }

enum AnswerType { QUESTION_WITH_IMAGE_ANSWERS, QUESTION_WITH_TEXT_ANSWERS }

relationship OneToOne { Quiz{result} to QuizResult, ResultOption{calculationConfig} to CalculationConfig } relationship OneToMany { Quiz{userInput} to UserQuizInput{quiz}, QuizResult{textCoordinate} to TextCoordinate{quizResult}, QuizResult{imageCoordinate} to ImageCoordinate{quizResult}, QuizResult{resultOption} to ResultOption{quizResult}, UserQuiz{resultOption} to UserQuizResultOption{userQuiz}, ResultOption{executeBlock} to ExecuteBlock{resultOption}, Trivia{question} to TriviaQuestion{trivia}, TriviaQuestion{answer} to TriviaAnswer{question}, Trivia{result} to TriviaResult{trivia}, Poll{option} to PollOption{poll} } relationship ManyToOne { UserQuiz{quiz} to Quiz, ExecuteBlock{block} to CodeBlock } relationship ManyToMany { Quiz{category(name)} to Category, Quiz{role(name)} to FbRole, QuizOption{type(name)} to OptionType, ResultOption{definedOption} to QuizOption{resultOption}, Trivia{categoryMap} to TriviaCategory, Poll{categoryMap} to PollCategory }

paginate Quiz, QuizOption, Trivia, Poll with infinite-scroll service Quiz, QuizOption, CodeBlock, ResultOption, UserQuiz, Trivia, Poll with serviceClass

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jhipster/generator-jhipster/issues/8497#issuecomment-427760222, or mute the thread https://github.com/notifications/unsubscribe-auth/ABDlF4YVtiEot5lcBWaFJB6TzFHQSlhhks5uixDBgaJpZM4XMasx .

arabbani commented 6 years ago

I tried @deepu105

jdubois commented 6 years ago

@arabbani and is your JDL working fine? As you didn't give it in the original post, I tested without it - could you also try? So we know if that comes from the JDL or not.

arabbani commented 6 years ago

Ok

arabbani commented 6 years ago

yeah it's working fine without entities

arabbani commented 6 years ago

Maybe something is wrong. I'll check and let you know

pascalgrimaud commented 6 years ago

@arabbani : if you can use start.jhipster.tech and generate a project with your issue, it will help to reproduce. As no one here manage to reproduce the issue.

deepu105 commented 6 years ago

I'm closing this as we couldn't reproduce, if you can reproduce and provide exact steps for us then I'll reopen it