죄송합니다.스프링 4와 JPA2 : 재 연결 지연
스프링 4를 처음 사용하면서, 나는 그것이 정말로 도움이되는지 또는 방해가되는지를 의심하기 시작했습니다. 세션이 만료되면 36 초에서 60 초 사이에 다시 연결됩니다.
사용 : Hibernate4 + JPA2 + HikariCP (수영장) + Hibernate.spatial
봄 부팅 나는 병목 현상이 줄에 별표 (*)를 넣어.
2014-07-08 17:59:14 DEBUG o.s.s.w.u.m.AntPathRequestMatcher:145 - Checking match of request : '/rest/restaurant/c1f15300-8bfc-496b-b90c-cf57596c8319/detail'; against '/rest/restaurant'
2014-07-08 17:59:14 DEBUG o.s.s.w.u.m.AntPathRequestMatcher:145 - Checking match of request : '/rest/restaurant/c1f15300-8bfc-496b-b90c-cf57596c8319/detail'; against '/rest/restaurant/**'
2014-07-08 17:59:14 DEBUG o.s.s.w.FilterChainProxy:180 - /rest/restaurant/C1F15300-8BFC-496B-B90C-CF57596C8319/detail has an empty filter list
2014-07-08 17:59:14 DEBUG o.s.w.s.DispatcherServlet:838 - DispatcherServlet with name 'dispatcherServlet' processing GET request for [/almocaqui/rest/restaurant/C1F15300-8BFC-496B-B90C-CF57596C8319/detail]
2014-07-08 17:59:14 DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping:246 - Looking up handler method for path /rest/restaurant/C1F15300-8BFC-496B-B90C-CF57596C8319/detail
2014-07-08 17:59:14 DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping:251 - Returning handler method [public com.snowmanlabs.almocaqui.domain.external.ExternalBasicRestaurant com.snowmanlabs.almocaqui.rest.controller.RestaurantRestController.getDetail(java.lang.String)]
2014-07-08 17:59:14 DEBUG o.s.b.f.s.DefaultListableBeanFactory:249 - Returning cached instance of singleton bean 'restaurantRestController'
2014-07-08 17:59:14 DEBUG o.s.w.s.DispatcherServlet:925 - Last-Modified value for [/almocaqui/rest/restaurant/C1F15300-8BFC-496B-B90C-CF57596C8319/detail] is: -1
2014-07-08 17:59:14 DEBUG o.s.o.j.s.OpenEntityManagerInViewInterceptor:87 - Opening JPA EntityManager in OpenEntityManagerInViewInterceptor
2014-07-08 17:59:14 DEBUG o.s.b.f.s.DefaultListableBeanFactory:249 - Returning cached instance of singleton bean 'transactionManager'
2014-07-08 17:59:14 DEBUG o.s.o.j.JpaTransactionManager:334 - Found thread-bound EntityManager [[email protected]] for JPA transaction
***2014-07-08 17:59:14 DEBUG o.s.o.j.JpaTransactionManager:367 - Creating new transaction with name [com.snowmanlabs.almocaqui.service.implement.RestaurantServiceImpl.getRestaurant]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT,readOnly; ''
2014-07-08 17:59:48 DEBUG o.s.o.j.JpaTransactionManager:403 - Exposing JPA transaction as JDBC transaction [org.springframewo[email protected]356f95be]
2014-07-08 17:59:49 DEBUG o.s.o.j.JpaTransactionManager:755 - Initiating transaction commit
2014-07-08 17:59:49 DEBUG o.s.o.j.JpaTransactionManager:510 - Committing JPA transaction on EntityManager [[email protected]]
2014-07-08 17:59:49 DEBUG o.s.o.j.JpaTransactionManager:603 - Not closing pre-bound JPA EntityManager after transaction
2014-07-08 17:59:50 DEBUG o.s.w.s.m.m.a.RequestResponseBodyMethodProcessor:145 - Written [co[email protected]479caa5b] as "application/json" using [org.springfr[email protected]4a37a117]
2014-07-08 17:59:50 DEBUG o.s.w.s.DispatcherServlet:1012 - Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
2014-07-08 17:59:50 DEBUG o.s.o.j.s.OpenEntityManagerInViewInterceptor:112 - Closing JPA EntityManager in OpenEntityManagerInViewInterceptor
2014-07-08 17:59:50 DEBUG o.s.o.j.EntityManagerFactoryUtils:435 - Closing JPA EntityManager
2014-07-08 17:59:50 DEBUG o.s.w.s.DispatcherServlet:991 - Successfully completed request
PS : AWS에서이 문제는, 공기를 하차 사이트를 만들어 내 파일의
요약 (최대 시간 내부 홀드 초과) :
* RestaurantRestController.java
을@Controller
@RequestMapping(value = "/rest/restaurant")
public class RestaurantRestController {
private final RestaurantService service;
@Inject
public RestaurantRestController(final RestaurantService service) {
this.service = service;
}
@RequestMapping(value = "/{uuid}/detail", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
@ResponseBody
public ExternalBasicRestaurant getDetail(@PathVariable("uuid") String uuid) {
Restaurant restaurant = service.getRestaurant(uuid);
ExternalBasicRestaurant external = createExternalBasicRestaurant(restaurant);
return external;
}
@ExceptionHandler
@ResponseStatus(HttpStatus.CONFLICT)
public String handleUserAlreadyExistsException(UserAlreadyExistsException e) {
return e.getMessage();
}
}
* RestaurantServiceImpl.java
01 23,516,@Service
@Validated
public class RestaurantServiceImpl implements RestaurantService {
private final RestaurantRepository repository;
@Inject
public RestaurantServiceImpl(final RestaurantRepository repository) {
this.repository = repository;
}
@Override
@Transactional(readOnly = true)
public Restaurant getRestaurant(String uuid){
Restaurant restaurant = repository.findOneByUUID(uuid);
return restaurant;
}
}
* RestaurantRepository.java
@Repository
public interface RestaurantRepository extends JpaRepository<Restaurant, Integer> {
}
*있는 application.properties
# Spring
spring.profiles.active=dev
# Server
server.port=8080
server.sessionTimeout=30
# MVC
spring.view.prefix=/WEB-INF/jsp/
spring.view.suffix=.jsp
java.runtime.version=1.7
#DataSource
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.datasource.url=jdbc:sqlserver://x.database.windows.net:1433;database=almocaqui;encrypt=true;hostNameInCertificate=*.database.windows.net;loginTimeout=30;
spring.datasource.username=x
spring.datasource.password=x
spring.datasource.validationQuery=SELECT 1
spring.datasource.testOnBorrow=true
spring.datasource.poolPreparedStatements=true
# JPA
spring.jpa.database-platform=org.hibernate.spatial.dialect.sqlserver.SqlServer2008SpatialDialect
spring.jpa.generate-ddl=true
spring.jpa.show-sql=false
spring.jpa.hibernate.ddl-auto=none
spring.jpa.hibernate.autocommit=false
spring.data.jpa.repositories.enabled=true
# HikariCP
hibernate.connection.provider_class=com.zaxxer.hikari.hibernate.HikariConnectionProvider
hibernate.hikari.minimumPoolSize=20
hibernate.hikari.maximumPoolSize=100
hibernate.hikari.idleTimeout=30
# Tomcat
tomcat.accessLogEnabled=false
tomcat.protocolHeader=x-forwarded-proto
tomcat.remoteIpHeader=x-forwarded-for
tomcat.backgroundProcessorDelay=10
server.tomcat.uri-encoding=UTF-8
server.session-timeout=10
* 지역 최종 : 로컬 호스트 : 8080/휴식/레스토랑/C1F15300-8BFC-496B-B90C-CF57596C8319/세부 사항
정말 오래된 버전으로 1.4.0으로 변경되었습니다. 그러나 문제는 계속됩니다. 중지는 "이름이있는 새 트랜잭션 생성 중 ..."에서 계속 서버를 떨어 뜨릴 수있는 시간 동안 계속됩니다. ws [AWS의 테스트] (http://almocaquiweb-test.elasticbeanstalk.com/rest/restaurant/C1F15300-8BFC-496B-B90C-CF57596C8319/detail)를 확인하십시오. –
테스트 URL을 방문했을 때 일어나는 일. 그것은 나를 위해 즉시로드됩니다 (그리고 재 장전). 이 문제는 http : // stackoverflow입니다.com/questions/24445721/thread-lock-after-opening-new-entitymanager는 나에게도 똑같이 보입니다. – brettw