IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Spring Java Discussion :

Erreur non détérminé: java.lang.NullPointerException + Vidage des tables ? [Data]


Sujet :

Spring Java

  1. #1
    Membre du Club
    Homme Profil pro
    Développeur Web
    Inscrit en
    Avril 2008
    Messages
    62
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2008
    Messages : 62
    Points : 49
    Points
    49
    Par défaut Erreur non détérminé: java.lang.NullPointerException + Vidage des tables ?
    Bonjour à tous,
    Je suis novice dans Spring et voila mon problème:
    J'ai une appli avec:
    Java 1.6
    MySQL 5.5.8
    Hibernate 3
    Spring 3.0.5
    Tomcat 6
    Eclipse Helios Service Release 2
    Maven

    Voici mes fichiers de conf:
    ApplicationContext.xml
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
    <beans>
     
       <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="hibernateProperties">
          <props>
            <prop key="hibernate.hbm2ddl.auto">create</prop>
            <prop key="hibernate.connection.pool_size">1</prop>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="hibernate.connection.autocommit">true</prop>
     
            <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
            <prop key="hibernate.connection.driver_class">com.mysql.jdbc.Driver</prop>
            <prop key="hibernate.connection.url">jdbc:mysql://localhost:3306/my_db</prop>
            <prop key="hibernate.connection.username">user</prop>
            <prop key="hibernate.connection.password">password</prop>		
     
          </props>
        </property>
        <property name="annotatedClasses">
          <list>
            <value>com.clinique.entity.Article</value>
            <value>com.clinique.entity.Bloc</value>
    		....
            <value>com.clinique.entity.Roles</value>
            <value>com.clinique.entity.Session</value>
            <value>com.clinique.entity.Stock</value>
            <value>com.clinique.entity.Users</value>
          </list>
        </property>
      </bean>
     
      <bean id="hibernateInterceptor" class="org.springframework.orm.hibernate3.HibernateInterceptor" autowire="byName" /><!--sessionFactory will get autowired-->
     
      <bean id="amirDaoTarget" class="com.clinique.dao.AmirDAOHibernateImpl" autowire="byName" /><!--sessionFactory will get autowired-->
     
      <bean id="amirDAO" class="org.springframework.aop.framework.ProxyFactoryBean">
        <property name="proxyInterfaces">
          <value>com.clinique.dao.AmirDAO</value>
        </property>
        <property name="interceptorNames">
          <list>
            <value>hibernateInterceptor</value>
            <value>amirDaoTarget</value>
          </list>
        </property>
      </bean>
     
    </beans>
    applicationContext-security.xml
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
     
    <?xml version="1.0" encoding="UTF-8"?>
    <beans:beans 	xmlns="http://www.springframework.org/schema/security"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:beans="http://www.springframework.org/schema/beans"
      xmlns:context="http://www.springframework.org/schema/context"
      xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-2.5.xsd
        http://www.springframework.org/schema/security
        http://www.springframework.org/schema/security/spring-security.xsd">
     
      <context:annotation-config/>
      <global-method-security jsr250-annotations="enabled" />
        <beans:bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    		<beans:property name="driverClassName" value="com.mysql.jdbc.Driver" />
    		<beans:property name="url" value="jdbc:mysql://localhost/my_db" />
    		<beans:property name="username" value="user" />
    		<beans:property name="password" value="password" />
    	</beans:bean>
     
      <http auto-config="true">
      	<intercept-url pattern="/myapp/login" access="ROLE_ANONYMOUS,ROLE_USER,ROLE_ADMIN" />
        <intercept-url pattern="/myapp/**" access="ROLE_USER" />
        <form-login login-page="/myapp/login"
        			default-target-url="/myapp/tdb"
        			always-use-default-target="true"
        			authentication-failure-url="/myapp/login?login_error=1" />
         <logout logout-url="/myapp/logout" />
      </http>
     
    	<authentication-manager alias="authenticationManager">
    		<authentication-provider>
    			<jdbc-user-service data-source-ref="dataSource"
    			users-by-username-query="SELECT username, password, enabled FROM users WHERE username = ?"
    			authorities-by-username-query="SELECT username, role FROM roles WHERE username = ?" />
    		</authentication-provider>
    	</authentication-manager >
    </beans:beans>
    dispatcher-servlet.xml
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
    <?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:p="http://www.springframework.org/schema/p"
    	xmlns:context="http://www.springframework.org/schema/context"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
    	<bean id="viewResolver"	class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" />
    	<context:component-scan base-package="com.clinique.controller" />
    	<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
    	<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
    </beans>
    web.xml
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    	<?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
      <display-name>MyApp</display-name>
     
      <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
      </servlet>
     
      <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>/myapp/*</url-pattern>
      </servlet-mapping>
     
      <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
      </welcome-file-list>
     
      <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext.xml
                     /WEB-INF/applicationContext-security.xml</param-value>
      </context-param>
     
      <listener>
        <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
      </listener>
      
      <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      </listener>
     
      <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
      </filter>
     
      <filter-mapping>
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/*</url-pattern>
      </filter-mapping>
    </web-app>
    1. Mon premier soucis est que à chaque fois que je lance mon serveur TomCat sur Eclipse, le contenu des tables "users" et "roles" se vide: voici les logs du démarrage:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    21 nov. 2011 14:19:25 org.apache.catalina.core.AprLifecycleListener init
    INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.6.0_24\bin;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre6/bin/client;C:/Program Files/Java/jre6/bin;C:/Program Files/Java/jre6/lib/i386;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Windows Live\Shared;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Apache Software Foundation\apache-maven-3.0.3\bin;C:\Program Files\Java\jdk1.6.0_24\bin;C:\jboss\jboss403\bin;C:\silverpeas\silverpeas-5.5.2\bin;C:\Program Files\SSH Communications Security\SSH Secure Shell;D:\wamp\bin\php\php5.3.5\PEAR;D:\wamp\bin\php\php5.2.11\PEAR;C:\Program Files\OpenVPN\bin;D:\Work\Eclipse2;
    21 nov. 2011 14:19:25 org.apache.tomcat.util.digester.SetPropertiesRule begin
    ATTENTION: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:MyApp' did not find a matching property.
    21 nov. 2011 14:19:25 org.apache.coyote.http11.Http11Protocol init
    INFO: Initialisation de Coyote HTTP/1.1 sur http-8080
    21 nov. 2011 14:19:25 org.apache.catalina.startup.Catalina load
    INFO: Initialization processed in 402 ms
    21 nov. 2011 14:19:25 org.apache.catalina.core.StandardService start
    INFO: Démarrage du service Catalina
    21 nov. 2011 14:19:25 org.apache.catalina.core.StandardEngine start
    INFO: Starting Servlet Engine: Apache Tomcat/6.0.26
    21 nov. 2011 14:19:26 org.apache.catalina.loader.WebappClassLoader validateJarFile
    INFO: validateJarFile(C:\Users\Portable\workspace2\.metadata\.plugins\org.eclipse.wst.server.core\tmp2\wtpwebapps\MyApp\WEB-INF\lib\servlet-api-2.3.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
    21 nov. 2011 14:19:26 org.apache.catalina.core.ApplicationContext log
    INFO: Set web app root system property: 'webapp.root' = [C:\Users\Portable\workspace2\.metadata\.plugins\org.eclipse.wst.server.core\tmp2\wtpwebapps\MyApp\]
    21 nov. 2011 14:19:26 org.apache.catalina.core.ApplicationContext log
    INFO: Initializing Spring root WebApplicationContext
    INFO  ContextLoader                   - Root WebApplicationContext: initialization started
    INFO  XmlWebApplicationContext        - Refreshing Root WebApplicationContext: startup date [Mon Nov 21 14:19:26 GMT+01:00 2011]; root of context hierarchy
    INFO  XmlBeanDefinitionReader         - Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
    INFO  XmlBeanDefinitionReader         - Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext-security.xml]
    INFO  SpringSecurityCoreVersion       - You are running with Spring Security Core 3.0.5.RELEASE
    INFO  SecurityNamespaceHandler        - Spring Security 'config' module version is 3.0.5.RELEASE
    INFO  tpSecurityBeanDefinitionParser  - Checking sorted filter chain: [Root bean: class [org.springframework.security.web.context.SecurityContextPersistenceFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 300, Root bean: class [org.springframework.security.web.authentication.logout.LogoutFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 400, Root bean: class [org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 800, Root bean: class [org.springframework.security.web.authentication.www.BasicAuthenticationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 1200, Root bean: class [org.springframework.security.web.savedrequest.RequestCacheAwareFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 1300, Root bean: class [org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 1400, Root bean: class [org.springframework.security.web.authentication.AnonymousAuthenticationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 1600, Root bean: class [org.springframework.security.web.session.SessionManagementFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 1700, Root bean: class [org.springframework.security.web.access.ExceptionTranslationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 1800, <org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0>, order = 1900]
    INFO  XmlWebApplicationContext        - Bean '(inner bean)' of type [class org.springframework.security.access.annotation.Jsr250MethodSecurityMetadataSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    INFO  XmlWebApplicationContext        - Bean 'org.springframework.security.access.method.DelegatingMethodSecurityMetadataSource#0' of type [class org.springframework.security.access.method.DelegatingMethodSecurityMetadataSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    INFO  XmlWebApplicationContext        - Bean 'org.springframework.security.methodSecurityMetadataSourceAdvisor' of type [class org.springframework.security.access.intercept.aopalliance.MethodSecurityMetadataSourceAdvisor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    INFO  DefaultListableBeanFactory      - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@827968: defining beans [sessionFactory,hibernateInterceptor,amirDaoTarget,amirDAO,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,org.springframework.security.access.method.DelegatingMethodSecurityMetadataSource#0,org.springframework.security.access.vote.AffirmativeBased#0,org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor#0,org.springframework.security.methodSecurityMetadataSourceAdvisor,org.springframework.aop.config.internalAutoProxyCreator,dataSource,org.springframework.security.web.PortMapperImpl#0,org.springframework.security.web.context.HttpSessionSecurityContextRepository#0,org.springframework.security.web.authentication.session.SessionFixationProtectionStrategy#0,org.springframework.security.authentication.ProviderManager#0,org.springframework.security.access.vote.AffirmativeBased#1,org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0,org.springframework.security.web.access.DefaultWebInvocationPrivilegeEvaluator#0,org.springframework.security.authentication.AnonymousAuthenticationProvider#0,org.springframework.security.web.savedrequest.HttpSessionRequestCache#0,org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint#0,org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0,org.springframework.security.config.http.UserDetailsServiceInjectionBeanPostProcessor#0,org.springframework.security.filterChainProxy,org.springframework.security.provisioning.JdbcUserDetailsManager#0,org.springframework.security.authentication.dao.DaoAuthenticationProvider#0,org.springframework.security.authentication.DefaultAuthenticationEventPublisher#0,org.springframework.security.authenticationManager]; root of factory hierarchy
    INFO  Version                         - Hibernate Annotations 3.2.0.CR2
    INFO  Environment                     - Hibernate 3.2 cr4
    INFO  Environment                     - loaded properties from resource hibernate.properties: {hibernate.bytecode.use_reflection_optimizer=false}
    INFO  Environment                     - Bytecode provider name : cglib
    INFO  Environment                     - using JDK 1.4 java.sql.Timestamp handling
    INFO  AnnotationBinder                - Binding entity from annotated class: com.clinique.entity.Article
    INFO  EntityBinder                    - Bind entity com.clinique.entity.Article on table Article
    INFO  AnnotationBinder                - Binding entity from annotated class: com.clinique.entity.Bloc
    INFO  EntityBinder                    - Bind entity com.clinique.entity.Bloc on table Bloc
    INFO  AnnotationBinder                - Binding entity from annotated class: com.clinique.entity.Roles
    INFO  EntityBinder                    - Bind entity com.clinique.entity.Roles on table Roles
    INFO  AnnotationBinder                - Binding entity from annotated class: com.clinique.entity.Users
    INFO  QueryBinder                     - Binding Named query: Users.usernameLike => select r from Users r where r.username like ?
    INFO  EntityBinder                    - Bind entity com.clinique.entity.Users on table Users
    INFO  AnnotationSessionFactoryBean    - Building new Hibernate SessionFactory
    INFO  riverManagerConnectionProvider  - Using Hibernate built-in connection pool (not for production use!)
    INFO  riverManagerConnectionProvider  - Hibernate connection pool size: 1
    INFO  riverManagerConnectionProvider  - autocommit mode: true
    INFO  riverManagerConnectionProvider  - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/my_db
    INFO  riverManagerConnectionProvider  - connection properties: {user=user, password=****, autocommit=true}
    INFO  SettingsFactory                 - RDBMS: MySQL, version: 5.5.8-log
    INFO  SettingsFactory                 - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.0 ( $Date: 2007-04-05 23:56:05 +0200 (Thu, 05 Apr 2007) $, $Revision: 6376 $ )
    INFO  Dialect                         - Using dialect: org.hibernate.dialect.MySQLDialect
    INFO  TransactionFactoryFactory       - Transaction strategy: org.springframework.orm.hibernate3.SpringTransactionFactory
    INFO  ransactionManagerLookupFactory  - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
    INFO  SettingsFactory                 - Automatic flush during beforeCompletion(): disabled
    INFO  SettingsFactory                 - Automatic session close at end of transaction: disabled
    INFO  SettingsFactory                 - JDBC batch size: 15
    INFO  SettingsFactory                 - JDBC batch updates for versioned data: disabled
    INFO  SettingsFactory                 - Scrollable result sets: enabled
    INFO  SettingsFactory                 - JDBC3 getGeneratedKeys(): enabled
    INFO  SettingsFactory                 - Connection release mode: auto
    INFO  SettingsFactory                 - Maximum outer join fetch depth: 2
    INFO  SettingsFactory                 - Default batch fetch size: 1
    INFO  SettingsFactory                 - Generate SQL with comments: disabled
    INFO  SettingsFactory                 - Order SQL updates by primary key: disabled
    INFO  SettingsFactory                 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
    INFO  ASTQueryTranslatorFactory       - Using ASTQueryTranslatorFactory
    INFO  SettingsFactory                 - Query language substitutions: {}
    INFO  SettingsFactory                 - JPA-QL strict compliance: disabled
    INFO  SettingsFactory                 - Second-level cache: enabled
    INFO  SettingsFactory                 - Query cache: disabled
    INFO  SettingsFactory                 - Cache provider: org.hibernate.cache.NoCacheProvider
    INFO  SettingsFactory                 - Optimize cache for minimal puts: disabled
    INFO  SettingsFactory                 - Structured second-level cache entries: disabled
    INFO  SettingsFactory                 - Echoing all SQL to stdout
    INFO  SettingsFactory                 - Statistics: disabled
    INFO  SettingsFactory                 - Deleted entity synthetic identifier rollback: disabled
    INFO  SettingsFactory                 - Default entity-mode: pojo
    INFO  SessionFactoryImpl              - building session factory
    INFO  SessionFactoryObjectFactory     - Not binding factory to JNDI, no JNDI name configured
    INFO  SchemaExport                    - Running hbm2ddl schema export
    INFO  SchemaExport                    - exporting generated schema to database
    ERROR SchemaExport                    - Unsuccessful: create table Bloc (attribute integer not null auto_increment, nomBloc varchar(255), primary key (attribute))
    ERROR SchemaExport                    - Table 'bloc' already exists
    INFO  SchemaExport                    - schema export complete
    INFO  MethodSecurityInterceptor       - Validated configuration attributes
    INFO  DriverManagerDataSource         - Loaded JDBC driver: com.mysql.jdbc.Driver
    INFO  JdbcUserDetailsManager          - No authentication manager set. Reauthentication of users when changing passwords will not be performed.
    INFO  FilterSecurityInterceptor       - Validated configuration attributes
    INFO  ContextLoader                   - Root WebApplicationContext: initialization completed in 3869 ms
    21 nov. 2011 14:19:30 org.apache.catalina.core.ApplicationContext log
    INFO: Initializing Spring FrameworkServlet 'dispatcher'
    INFO  DispatcherServlet               - FrameworkServlet 'dispatcher': initialization started
    INFO  XmlWebApplicationContext        - Refreshing WebApplicationContext for namespace 'dispatcher-servlet': startup date [Mon Nov 21 14:19:30 GMT+01:00 2011]; parent: Root WebApplicationContext
    INFO  XmlBeanDefinitionReader         - Loading XML bean definitions from ServletContext resource [/WEB-INF/dispatcher-servlet.xml]
    INFO  DefaultListableBeanFactory      - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@fd4662: defining beans [viewResolver,comptabiliteController,homeController,loginController,TDBController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0,org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter#0]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@827968
    INFO  efaultAnnotationHandlerMapping  - Mapped URL path [/comptabilite] onto handler 'comptabiliteController'
    INFO  efaultAnnotationHandlerMapping  - Mapped URL path [/comptabilite.*] onto handler 'comptabiliteController'
    INFO  efaultAnnotationHandlerMapping  - Mapped URL path [/comptabilite/] onto handler 'comptabiliteController'
    INFO  efaultAnnotationHandlerMapping  - Mapped URL path [/home] onto handler 'homeController'
    INFO  efaultAnnotationHandlerMapping  - Mapped URL path [/home.*] onto handler 'homeController'
    INFO  efaultAnnotationHandlerMapping  - Mapped URL path [/home/] onto handler 'homeController'
    INFO  efaultAnnotationHandlerMapping  - Mapped URL path [/home/home.*] onto handler 'homeController'
    INFO  efaultAnnotationHandlerMapping  - Mapped URL path [/home/home/] onto handler 'homeController'
    INFO  efaultAnnotationHandlerMapping  - Mapped URL path [/login] onto handler 'loginController'
    INFO  efaultAnnotationHandlerMapping  - Mapped URL path [/login.*] onto handler 'loginController'
    INFO  efaultAnnotationHandlerMapping  - Mapped URL path [/login/] onto handler 'loginController'
    INFO  efaultAnnotationHandlerMapping  - Mapped URL path [/tdb] onto handler 'TDBController'
    INFO  efaultAnnotationHandlerMapping  - Mapped URL path [/tdb.*] onto handler 'TDBController'
    INFO  efaultAnnotationHandlerMapping  - Mapped URL path [/tdb/] onto handler 'TDBController'
    INFO  DispatcherServlet               - FrameworkServlet 'dispatcher': initialization completed in 405 ms
    21 nov. 2011 14:19:30 org.apache.coyote.http11.Http11Protocol start
    INFO: Démarrage de Coyote HTTP/1.1 sur http-8080
    21 nov. 2011 14:19:30 org.apache.jk.common.ChannelSocket init
    INFO: JK: ajp13 listening on /0.0.0.0:8009
    21 nov. 2011 14:19:30 org.apache.jk.server.JkMain start
    INFO: Jk running ID=0 time=0/24  config=null
    21 nov. 2011 14:19:30 org.apache.catalina.startup.Catalina start
    INFO: Server startup in 5120 ms
    2. Après ça l'appli se lance, et lorsque le controller TDBController s'execute:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    @Controller
    public class TDBController {
    	private AmirDAO amirDAO;
     
    	@RequestMapping("/tdb")
    	   public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException,
           IOException {
    		Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    	    String name = auth.getName();
                //Et voici la ligne 43
    	    Users user = amirDAO.findByUsername(name);
     
    	    System.out.println("Je suis dans le controlleur avec le user : "+user.getNom());
      return new ModelAndView("tdb/index");
    }
    }
    Le fichier d’implémentation Hibernate:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    @Override
    public Users findByUsername(String username){
    	List list = getHibernateTemplate().find("from Users where username=?",username);
    	return (Users)list.get(0);
    }}
    Je reçois ce code d'erreur:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
     
    21 nov. 2011 15:32:59 org.apache.catalina.core.StandardWrapperValve invoke
    GRAVE: "Servlet.service()" pour la servlet dispatcher a généré une exception
    java.lang.NullPointerException
    	at com.clinique.controller.TDBController.handleRequest(TDBController.java:43)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:597)
    	at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
    	at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426)
    	at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414)
    	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
    	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
    	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
    	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:368)
    	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
    	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
    	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
    	at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
    	at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
    	at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
    	at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
    	at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:177)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
    	at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:187)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
    	at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
    	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
    	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:169)
    	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
    	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
    	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    	at java.lang.Thread.run(Thread.java:662)
    Et je suis bloqué depuis un bon moment, votre aide me sera vraiment précieuse.
    Merci d'avance.

  2. #2
    Expert confirmé
    Homme Profil pro
    Inscrit en
    Septembre 2006
    Messages
    2 953
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations forums :
    Inscription : Septembre 2006
    Messages : 2 953
    Points : 4 379
    Points
    4 379
    Par défaut
    Citation Envoyé par samirmember Voir le message
    <prop key="hibernate.hbm2ddl.auto">create</prop>
    vous demandez à Hibernate de recréer la DB à chaque fois…

  3. #3
    Membre du Club
    Homme Profil pro
    Développeur Web
    Inscrit en
    Avril 2008
    Messages
    62
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2008
    Messages : 62
    Points : 49
    Points
    49
    Par défaut Vidage des tables résolu
    Merci beaucoup JeitEmgie, vous aviez tout à fait raison. En modifiant la ligne:
    <prop key="hibernate.hbm2ddl.auto">create</prop> à
    <prop key="hibernate.hbm2ddl.auto">validate</prop>
    Le problème de vidage de table est résolut
    Il me reste le problème de java.lang.NullPointerException
    Quelqu'un a une idée?

  4. #4
    Membre du Club
    Homme Profil pro
    Développeur Web
    Inscrit en
    Avril 2008
    Messages
    62
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2008
    Messages : 62
    Points : 49
    Points
    49
    Par défaut @Autowired
    J'ai réoslu le problème en ajoutant @Autowired à la variable: private private AmirDAO amirDAO; de ma classe TDBController.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 6
    Dernier message: 21/04/2014, 15h14
  2. Erreur de débutant, java.lang.NullPointerException
    Par Ardillon dans le forum Débuter avec Java
    Réponses: 8
    Dernier message: 08/07/2013, 14h42
  3. Erreur "save failed: java.lang.NullPointerException"
    Par faffany dans le forum Struts 2
    Réponses: 8
    Dernier message: 15/09/2011, 11h42
  4. erreurs de type java.lang.NullPointerException
    Par laposte dans le forum Servlets/JSP
    Réponses: 17
    Dernier message: 06/04/2009, 19h45
  5. Erreur impossible à résoudre : java.lang.NullPointerException
    Par loader dans le forum Débuter avec Java
    Réponses: 16
    Dernier message: 11/06/2008, 19h50

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo