spring bootでログイン画面を作成しています。
参考しているサイト
実行時にこのようなエラーが発生しています。
(文字数制限のため、各項目の上位ログ以外は省略)
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'webSecurityConfig': Injection of autowired dependencies failed; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:405) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1422) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] Caused by: org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:281) ~[spring-orm-5.2.5.RELEASE.jar:5.2.5.RELEASE] at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:255) ~[spring-orm-5.2.5.RELEASE.jar:5.2.5.RELEASE] at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:528) ~[spring-orm-5.2.5.RELEASE.jar:5.2.5.RELEASE] Caused by: org.hibernate.exception.SQLGrammarException: could not extract ResultSet at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:63) ~[hibernate-core-5.4.12.Final.jar:5.4.12.Final] at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42) ~[hibernate-core-5.4.12.Final.jar:5.4.12.Final] at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113) ~[hibernate-core-5.4.12.Final.jar:5.4.12.Final] Caused by: java.sql.SQLSyntaxErrorException: ORA-02289: 順序が存在しません。 at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:494) ~[ojdbc8.jar:12.2.0.1.0] at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:446) ~[ojdbc8.jar:12.2.0.1.0] Caused by: oracle.jdbc.OracleDatabaseException: ORA-02289: 順序が存在しません。 at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:498) ~[ojdbc8.jar:12.2.0.1.0] ... 95 common frames omitted
WebSecurityConfig
@EnableWebSecurity public class WebSecurityConfig extends WebSecurityConfigurerAdapter { @Autowired private UserService userService; @Override protected void configure(HttpSecurity http) throws Exception { http .authorizeRequests() .antMatchers("/", "/signup","/login", "/login-error").permitAll() .antMatchers("/**").hasRole("USER") .and() .formLogin() .loginPage("/login").failureUrl("/login-error"); } @Autowired public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { auth // .inMemoryAuthentication() // .withUser("user").password("password").roles("USER"); .userDetailsService(userService) .passwordEncoder(passwordEncoder()); userService.registerAdmin("admin", "password", "admin@localhost"); } @Bean public PasswordEncoder passwordEncoder() { return new BCryptPasswordEncoder(); //return NoOpPasswordEncoder.getInstance(); } }
UserService
@Service public class UserService implements UserDetailsService { @Autowired private UserRepository repository; @Autowired private PasswordEncoder passwordEncoder; @Override public UserEntity loadUserByUsername(String userName) throws UsernameNotFoundException { if (userName == null || "".equals(userName)) { throw new UsernameNotFoundException("Username is empty"); } UserEntity user = repository.findByUserName(userName); if (user == null) { throw new UsernameNotFoundException("User not found: " + userName); } return user; } @Transactional public void registerAdmin(String username, String password, String mailAddress) { UserEntity user = new UserEntity(username, passwordEncoder.encode(password), mailAddress); user.setAdmin(true); repository.save(user); } @Transactional public void registerUser(String username, String password, String mailAddress) { UserEntity user = new UserEntity(username, passwordEncoder.encode(password), mailAddress); repository.save(user); } }
WebSecurityConfigのuserDetailServiceからuserService.registerAdminまで
コメントし、すでにコメントされているところを復活させたら問題なかったです。
UserServiceのregisterAdminが動くタイミングでrepository.saveが失敗しているようでした。
DB情報
対象テーブル
CREATE TABLE "STUDYUSER"."TODO_LIST_USER" ( "ID" VARCHAR2(20 BYTE) NOT NULL ENABLE, "NAME" VARCHAR2(20 BYTE), "MAILADDRESS" VARCHAR2(20 BYTE), "MAILADDRESSVERIFIED" NUMBER(*,0), "PASSWORD" VARCHAR2(1000 BYTE), "ENABLED" NUMBER(*,0), CONSTRAINT "TODO_LIST_USER_PK" PRIMARY KEY ("ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) TABLESPACE "USERS" ENABLE ) SEGMENT CREATION IMMEDIATE PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) TABLESPACE "USERS" ;
sequence
ORA-02289の対策を調べて、sequenceを作成しましたが
作り方が間違っているのでしょうか。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2020/04/25 00:51
退会済みユーザー
2020/04/25 01:36