Advertisement
Guest User

Untitled

a guest
Oct 10th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.52 KB | None | 0 0
  1. INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1622fdf: defining beans [daoClient,serviceClient,daoProduit,serviceProduit,dataSource,persistenceUnitManager,entityMangerFactory,transactionManager,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor]; root of factory hierarchy
  2. Hibernate: alter table PRODUITS drop foreign key FKF2D1D7EAA6CDC455
  3. Hibernate: drop table if exists Client
  4. Hibernate: drop table if exists PRODUITS
  5. Hibernate: create table Client (idClient bigint not null auto_increment, adressClient varchar(255), nomClient varchar(255), prenomClient varchar(255), telephoneClient varchar(255), primary key (idClient))
  6. Hibernate: create table PRODUITS (idProduit bigint not null auto_increment, descriptionProduit varchar(255), designationProduit varchar(255), prixProduit double precision not null, qteProduit integer not null, idClient bigint, primary key (idProduit))
  7. Hibernate: alter table PRODUITS add index FKF2D1D7EAA6CDC455 (idClient), add constraint FKF2D1D7EAA6CDC455 foreign key (idClient) references Client (idClient)
  8. Exception in thread "main" java.lang.NullPointerException
  9. at com.axiz.projet.dao.IClientImp.addClient2(IClientImp.java:53)
  10. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  11. at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  12. at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  13. at java.lang.reflect.Method.invoke(Unknown Source)
  14. at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
  15. at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
  16. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
  17. at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
  18. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
  19. at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
  20. at com.sun.proxy.$Proxy3.addClient2(Unknown Source)
  21. at com.axiz.projet.services.ClientServiceImp.addClient2(ClientServiceImp.java:48)
  22. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  23. at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  24. at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  25. at java.lang.reflect.Method.invoke(Unknown Source)
  26. at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
  27. at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
  28. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
  29. at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
  30. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
  31. at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
  32. at com.sun.proxy.$Proxy4.addClient2(Unknown Source)
  33. at com.axiz.projet.Test.main(Test.java:23)
  34.  
  35. <?xml version="1.0" encoding="UTF-8"?>
  36. <beans xmlns="http://www.springframework.org/schema/beans"
  37. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  38. xmlns:context="http://www.springframework.org/schema/context"
  39. xmlns:tx="http://www.springframework.org/schema/tx"
  40. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  41. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
  42. http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">
  43. <bean id="daoClient" class="com.axiz.projet.dao.IClientImp"/>
  44. <bean id="serviceClient" class="com.axiz.projet.services.ClientServiceImp">
  45. <property name="daoClient" ref="daoClient"></property>
  46. </bean>
  47. <bean id="daoProduit" class="com.axiz.projet.dao.IProduitImpl"/>
  48. <bean id="serviceProduit" class="com.axiz.projet.services.ProduitServiceImp">
  49. <property name="daoProduit" ref="daoProduit"></property>
  50. </bean>
  51. <!-- -->
  52. <bean name="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
  53. <property name="driverClassName" value="com.mysql.jdbc.Driver" />
  54. <property name="url" value="jdbc:mysql://localhost:3306/bd_produit_hibernate" />
  55. <property name="username" value="root" />
  56. <property name="password" value="" />
  57. </bean>
  58. <!-- -->
  59. <bean id="persistenceUnitManager" depends-on="transactionManager"
  60. class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
  61. <property name="persistenceXmlLocation" value="classpath*:META-INF/persistence.xml"/>
  62. <property name="defaultDataSource" ref="dataSource"/>
  63. <property name="dataSourceLookup">
  64. <bean class="org.springframework.jdbc.datasource.lookup.BeanFactoryDataSourceLookup"/>
  65. </property>
  66. </bean>
  67. <!-- ******************** -->
  68.  
  69.  
  70. <bean id="entityMangerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
  71.  
  72. <property name="persistenceUnitManager" ref="persistenceUnitManager"/>
  73. <property name="persistenceUnitName" value="prodClientPersistence"/>
  74. </bean>
  75.  
  76. <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
  77. <property name="entityManagerFactory" ref="entityMangerFactory"/>
  78. </bean>
  79.  
  80.  
  81. <tx:annotation-driven transaction-manager="transactionManager" />
  82.  
  83.  
  84.  
  85.  
  86. </beans>
  87.  
  88. <?xml version="1.0" encoding="UTF-8"?>
  89. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  90. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  91. <modelVersion>4.0.0</modelVersion>
  92. <groupId>com.axiz</groupId>
  93. <artifactId>projet</artifactId>
  94. <name>prodCatProjet</name>
  95. <packaging>war</packaging>
  96. <version>1.0.0-BUILD-SNAPSHOT</version>
  97. <properties>
  98. <java-version>1.6</java-version>
  99. <org.springframework-version>3.1.1.RELEASE</org.springframework-version>
  100. <org.aspectj-version>1.6.10</org.aspectj-version>
  101. <org.slf4j-version>1.6.6</org.slf4j-version>
  102. </properties>
  103. <dependencies>
  104. <!-- Spring -->
  105. <dependency>
  106. <groupId>org.springframework</groupId>
  107. <artifactId>spring-context</artifactId>
  108. <version>${org.springframework-version}</version>
  109. <exclusions>
  110. <!-- Exclude Commons Logging in favor of SLF4j -->
  111. <exclusion>
  112. <groupId>commons-logging</groupId>
  113. <artifactId>commons-logging</artifactId>
  114. </exclusion>
  115. </exclusions>
  116. </dependency>
  117. <dependency>
  118. <groupId>org.springframework</groupId>
  119. <artifactId>spring-webmvc</artifactId>
  120. <version>${org.springframework-version}</version>
  121. </dependency>
  122.  
  123. <!-- AspectJ -->
  124. <dependency>
  125. <groupId>org.aspectj</groupId>
  126. <artifactId>aspectjrt</artifactId>
  127. <version>${org.aspectj-version}</version>
  128. </dependency>
  129.  
  130. <!-- Logging -->
  131. <dependency>
  132. <groupId>org.slf4j</groupId>
  133. <artifactId>slf4j-api</artifactId>
  134. <version>${org.slf4j-version}</version>
  135. </dependency>
  136. <dependency>
  137. <groupId>org.slf4j</groupId>
  138. <artifactId>jcl-over-slf4j</artifactId>
  139. <version>${org.slf4j-version}</version>
  140. <scope>runtime</scope>
  141. </dependency>
  142. <dependency>
  143. <groupId>org.slf4j</groupId>
  144. <artifactId>slf4j-log4j12</artifactId>
  145. <version>${org.slf4j-version}</version>
  146. <scope>runtime</scope>
  147. </dependency>
  148. <dependency>
  149. <groupId>log4j</groupId>
  150. <artifactId>log4j</artifactId>
  151. <version>1.2.15</version>
  152. <exclusions>
  153. <exclusion>
  154. <groupId>javax.mail</groupId>
  155. <artifactId>mail</artifactId>
  156. </exclusion>
  157. <exclusion>
  158. <groupId>javax.jms</groupId>
  159. <artifactId>jms</artifactId>
  160. </exclusion>
  161. <exclusion>
  162. <groupId>com.sun.jdmk</groupId>
  163. <artifactId>jmxtools</artifactId>
  164. </exclusion>
  165. <exclusion>
  166. <groupId>com.sun.jmx</groupId>
  167. <artifactId>jmxri</artifactId>
  168. </exclusion>
  169. </exclusions>
  170. <scope>runtime</scope>
  171. </dependency>
  172.  
  173. <!-- @Inject -->
  174. <dependency>
  175. <groupId>javax.inject</groupId>
  176. <artifactId>javax.inject</artifactId>
  177. <version>1</version>
  178. </dependency>
  179.  
  180. <!-- Servlet -->
  181. <dependency>
  182. <groupId>javax.servlet</groupId>
  183. <artifactId>servlet-api</artifactId>
  184. <version>2.5</version>
  185. <scope>provided</scope>
  186. </dependency>
  187. <dependency>
  188. <groupId>javax.servlet.jsp</groupId>
  189. <artifactId>jsp-api</artifactId>
  190. <version>2.1</version>
  191. <scope>provided</scope>
  192. </dependency>
  193. <dependency>
  194. <groupId>javax.servlet</groupId>
  195. <artifactId>jstl</artifactId>
  196. <version>1.2</version>
  197. </dependency>
  198.  
  199. <!-- Test -->
  200. <dependency>
  201. <groupId>junit</groupId>
  202. <artifactId>junit</artifactId>
  203. <version>4.7</version>
  204. <scope>test</scope>
  205. </dependency>
  206.  
  207. <dependency>
  208. <groupId>org.springframework</groupId>
  209. <artifactId>spring-orm</artifactId>
  210. <version>3.1.1.RELEASE</version>
  211. </dependency>
  212. <dependency>
  213. <groupId>org.springframework</groupId>
  214. <artifactId>spring-beans</artifactId>
  215. <version>3.1.1.RELEASE</version>
  216. </dependency>
  217. <dependency>
  218. <groupId>org.springframework</groupId>
  219. <artifactId>spring-tx</artifactId>
  220. <version>3.1.1.RELEASE</version>
  221. </dependency>
  222. <dependency>
  223. <groupId>org.hibernate</groupId>
  224. <artifactId>hibernate-commons-annotations</artifactId>
  225. <version>3.2.0.Final</version>
  226. </dependency>
  227. <dependency>
  228. <groupId>org.hibernate</groupId>
  229. <artifactId>hibernate-entitymanager</artifactId>
  230. <version>4.1.9.Final</version>
  231. </dependency>
  232. <dependency>
  233. <groupId>org.hibernate</groupId>
  234. <artifactId>hibernate-validator</artifactId>
  235. <version>4.2.0.Final</version>
  236. </dependency>
  237. <dependency>
  238. <groupId>mysql</groupId>
  239. <artifactId>mysql-connector-java</artifactId>
  240. <version>5.1.21</version>
  241. </dependency>
  242. <dependency>
  243. <groupId>org.hibernate.javax.persistence</groupId>
  244. <artifactId>hibernate-jpa-2.0-api</artifactId>
  245. <version>1.0.0.Final</version>
  246. </dependency>
  247. </dependencies>
  248. <build>
  249. <plugins>
  250. <plugin>
  251. <artifactId>maven-eclipse-plugin</artifactId>
  252. <version>2.9</version>
  253. <configuration>
  254. <additionalProjectnatures>
  255. <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
  256. </additionalProjectnatures>
  257. <additionalBuildcommands>
  258. <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
  259. </additionalBuildcommands>
  260. <downloadSources>true</downloadSources>
  261. <downloadJavadocs>true</downloadJavadocs>
  262. </configuration>
  263. </plugin>
  264. <plugin>
  265. <groupId>org.apache.maven.plugins</groupId>
  266. <artifactId>maven-compiler-plugin</artifactId>
  267. <version>2.5.1</version>
  268. <configuration>
  269. <source>1.6</source>
  270. <target>1.6</target>
  271. <compilerArgument>-Xlint:all</compilerArgument>
  272. <showWarnings>true</showWarnings>
  273. <showDeprecation>true</showDeprecation>
  274. </configuration>
  275. </plugin>
  276. <plugin>
  277. <groupId>org.codehaus.mojo</groupId>
  278. <artifactId>exec-maven-plugin</artifactId>
  279. <version>1.2.1</version>
  280. <configuration>
  281. <mainClass>org.test.int1.Main</mainClass>
  282. </configuration>
  283. </plugin>
  284. </plugins>
  285. </build>
  286. </project>
  287.  
  288. import java.util.List;
  289.  
  290. import org.springframework.transaction.annotation.Transactional;
  291.  
  292. import com.axiz.projet.dao.IClient;
  293. import com.axiz.projet.entities.Client;
  294. @Transactional
  295. public class ClientServiceImp implements IClientService {
  296. private IClient daoClient;
  297. @Override
  298. public Client addClient(Client client) {
  299.  
  300. return daoClient.addClient(client);
  301. }
  302.  
  303. @Override
  304. public List<Client> getAll() {
  305. // TODO Auto-generated method stub
  306. return daoClient.getAll();
  307. }
  308.  
  309. @Override
  310. public Client getClientById(Long idClient) {
  311. // TODO Auto-generated method stub
  312. return daoClient.getClientById(idClient);
  313. }
  314.  
  315. @Override
  316. public void deleteClient(Long idClient) {
  317. daoClient.deleteClient(idClient);
  318.  
  319. }
  320.  
  321. @Override
  322. public Client updateClient(Client client) {
  323. // TODO Auto-generated method stub
  324. return daoClient.updateClient(client);
  325. }
  326.  
  327. public void setDaoClient(IClient daoClient) {
  328. this.daoClient = daoClient;
  329. }
  330.  
  331. @Override
  332. public void addClient2(Client client) {
  333. daoClient.addClient2(client);
  334.  
  335. }
  336.  
  337. }
  338.  
  339. package com.axiz.projet.dao;
  340.  
  341. import java.util.List;
  342. import java.util.concurrent.Executor;
  343.  
  344. import javax.persistence.EntityManager;
  345. import javax.persistence.PersistenceContext;
  346. import javax.persistence.Query;
  347.  
  348. import org.springframework.transaction.annotation.Transactional;
  349.  
  350. import com.axiz.projet.entities.Client;
  351. @Transactional
  352. public class IClientImp implements IClient {
  353. @PersistenceContext
  354. private EntityManager em;
  355. @Override
  356. public Client addClient(Client client) {
  357.  
  358. em.persist(client);
  359.  
  360.  
  361. return client;
  362. }
  363.  
  364. @Override
  365. public List<Client> getAll() {
  366. Query query=em.createQuery("select c from Client c");
  367. return query.getResultList();
  368. }
  369.  
  370. @Override
  371. public Client getClientById(Long idClient) {
  372. Client client=em.find(Client.class, idClient);
  373. return client;
  374. }
  375.  
  376. @Override
  377. public void deleteClient(Long idClient) {
  378. em.remove(getClientById(idClient));
  379.  
  380. }
  381.  
  382. @Override
  383. public Client updateClient(Client client) {
  384. // TODO Auto-generated method stub
  385. return em.merge(client);
  386. }
  387.  
  388.  
  389. public void addClient2(Client client) {
  390. // TODO Auto-generated method stub
  391. em.persist(client);
  392. }
  393.  
  394. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement