Hi,
I'm developing a web application using :
Spring 3.1.2
Tomcat 6
JDK 7
SQL Serveur 2008 R2 (JDBC driver sqljdbc4.jar)
All is working as expected.
When moving from JDK 7 to JDK 6, my application is not working anymore
I'm confused, as Spring prerequisites are JDK 1.5+.
It seems to be dabase related :
When starting Tomcat, no error on console.
When accessing to my application, the browser keeps blocked on "waiting for localhost".
When debbuging, I see a problemon on this line :
I have put a breakpoint in isUrlProtected method, but I'm not able to reach it.Code:if (SpringHelper.getInstance(request).getUrlService().isUrlProtected(pUrl))
When watching content of getUrlService(), I see information I'm not used to work with :
I never enter in isUrlProtected method, my breakpoint is never reached.Code:CGLIB$BOUND true [...] CGLIB$CALLBACK_0 Cglib2AopProxy$DynamicAdvisedInterceptor (id=3121) iUrlDao null
The Tomcat thread is marked as "Running" but no response was sent to the client (still displaying "waiting for localhost").
I have not any exception in console.
Here is my service layer :
Here is my DAO layer :Code:// imports [...] @Transactional public class ServiceUrl { private InterfaceTUrlDao iUrlDao; /** * @return the iUrlDao */ public InterfaceTUrlDao getiUrlDao() { return iUrlDao; } /** * @param iUrlDao the iUrlDao to set */ public void setiUrlDao(InterfaceTUrlDao iUrlDao) { this.iUrlDao = iUrlDao; } public void persist(TUrl transientInstance) { iUrlDao.persist(transientInstance); } public void remove(TUrl persistentInstance) { iUrlDao.remove(persistentInstance); } public TUrl merge(TUrl detachedInstance) { return iUrlDao.merge(detachedInstance); } public TUrl findById(int id) { return iUrlDao.findById(id); } public boolean isUrlProtected(String urlPath) { // just search for the entry in db return iUrlDao.findByPath(urlPath) != null; } }
Here my application-context.xml fileCode:// imports [...] /** * Home object for domain model class TUrl. * @author Hibernate Tools */ public class TUrlDao implements InterfaceTUrlDao { private static final Log log = LogFactory.getLog(TUrlDao.class); @PersistenceContext(type=PersistenceContextType.EXTENDED) private EntityManager entityManager; public void persist(TUrl transientInstance) { log.debug("persisting TUrl instance"); try { entityManager.persist(transientInstance); log.debug("persist successful"); } catch (RuntimeException re) { log.error("persist failed", re); throw re; } } public void remove(TUrl persistentInstance) { log.debug("removing TUrl instance"); try { entityManager.remove(persistentInstance); log.debug("remove successful"); } catch (RuntimeException re) { log.error("remove failed", re); throw re; } } public TUrl merge(TUrl detachedInstance) { log.debug("merging TUrl instance"); try { TUrl result = entityManager.merge(detachedInstance); log.debug("merge successful"); return result; } catch (RuntimeException re) { log.error("merge failed", re); throw re; } } public TUrl findById(int id) { log.debug("getting TUrl instance with id: " + id); try { TUrl instance = entityManager.find(TUrl.class, id); entityManager.refresh(instance); log.debug("get successful"); return instance; } catch (RuntimeException re) { log.error("get failed", re); throw re; } } public TUrl findByPath(String path) { try { Query query = entityManager.createQuery("select u from TUrl u where u.pathUrl like :theUrl"); query.setParameter("theUrl", path); TUrl result = (TUrl) query.getSingleResult(); entityManager.refresh(result); return result; } catch (NoResultException nre) { return null; } catch (NonUniqueResultException nure) { throw nure; } } }
My SpringHelper class :Code:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd"> <!-- DAO layer --> <bean id="daoUrl" class="myProject.dao.jpa.TUrlDao" /> [...] <!-- Service layer --> <bean id="serviceUrl" class="myProject.service.ServiceUrl"> <property name="iUrlDao" ref="daoUrl"/> </bean> [...] <!-- Exception translation bean post processor --> <bean class="org.springframework.orm.hibernate3.HibernateExceptionTranslator"/> <bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" /> <!-- SQL Server data source --> <bean id="sqlServerDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" /> <property name="url" value="jdbc:sqlserver://serverName:;databaseName=sid" /> <property name="username" value="user" /> <property name="password" value="pwd" /> </bean> <!-- entity manager --> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="dataSource" ref="sqlServerDataSource" /> <property name="jpaVendorAdapter"> <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> <property name="showSql" value="false" /> <property name="databasePlatform" value="org.hibernate.dialect.SQLServer2008Dialect" /> <property name="generateDdl" value="false" /> </bean> </property> </bean> <!-- Transactions manager --> <bean id="txManager" class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory" ref="entityManagerFactory" /> </bean> <!-- enable the configuration of transactional behavior based on annotations --> <tx:annotation-driven transaction-manager="txManager" /> <!-- Persistence --> <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" /> <!-- Other data source not used currently... --> <bean id="oracleDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="oracle.jdbc.OracleDriver" /> <property name="url" value="jdbc:oracle:thin:@server:1521:instance" /> <property name="username" value="user" /> <property name="password" value="pwd" /> </bean> <!-- Form validation : associated messages --> <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> <property name="basename"> <value>messages</value> </property> </bean> </beans>
When moving back to JDK 7, it's working.Code:// imports [...] /** * Spring Helper class. * * Provide access to bean objects defined in spring application context file. * * Based on Singleton pattern to initialize objects once. * */ public class SpringHelper { /** * Unique instance */ private static SpringHelper instance = null; /** * Service layer */ private ServiceUrl urlService; /** * @return the urlService */ public ServiceUrl getUrlService() { return urlService; } [...] /** * Singleton * */ public static SpringHelper getInstance(HttpServletRequest request) { // first call if (instance == null) { instance = new SpringHelper(request); } return instance; } /** * Private constructor to force Singleton usage */ private SpringHelper(HttpServletRequest request) { // get servlet context from request ServletContext servletContext = request.getSession().getServletContext(); // get service layer urlService = (ServiceUrl) WebApplicationContextUtils.getWebApplicationContext(servletContext).getBean("serviceUrl"); } }
I'm a little bit lost on this topic...





Reply With Quote
).