Advertisement
Guest User

Untitled

a guest
Aug 6th, 2016
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.52 KB | None | 0 0
  1. Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.persistence.EntityManagerFactory]: Factory method 'entityManagerFactory' threw exception; nested exception is java.lang.IllegalStateException: Cannot apply class transformer without LoadTimeWeaver specified
  2. at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
  3. at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
  4. ... 95 more
  5. Caused by: java.lang.IllegalStateException: Cannot apply class transformer without LoadTimeWeaver specified
  6. at org.springframework.orm.jpa.persistenceunit.SpringPersistenceUnitInfo.addTransformer(SpringPersistenceUnitInfo.java:80)
  7. at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactoryImpl(PersistenceProvider.java:373)
  8. at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactory(PersistenceProvider.java:313)
  9. at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:343)
  10. at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:319)
  11. at foo.AppConfiguration.entityManagerFactory(AppConfiguration.java:57)
  12. at foo.AppConfiguration$$EnhancerBySpringCGLIB$$a92e9feb.CGLIB$entityManagerFactory$1(<generated>)
  13. at foo.AppConfiguration$$EnhancerBySpringCGLIB$$a92e9feb$$FastClassBySpringCGLIB$$e4dbaad1.invoke(<generated>)
  14. at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
  15. at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:356)
  16. at foo.AppConfiguration$$EnhancerBySpringCGLIB$$a92e9feb.entityManagerFactory(<generated>)
  17. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  18.  
  19. <?xml version="1.0" encoding="UTF-8"?>
  20. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  21. <modelVersion>4.0.0</modelVersion>
  22. <groupId>com.ss.stock</groupId>
  23. <artifactId>SimpleTest</artifactId>
  24. <version>1.0-SNAPSHOT</version>
  25. <packaging>war</packaging>
  26. <properties>
  27. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  28. <maven.compiler.source>1.8</maven.compiler.source>
  29. <maven.compiler.target>1.8</maven.compiler.target>
  30. </properties>
  31.  
  32.  
  33. <build>
  34. <plugins>
  35. <plugin>
  36. <groupId>org.apache.tomcat.maven</groupId>
  37. <artifactId>tomcat7-maven-plugin</artifactId>
  38. <version>2.2</version>
  39. <configuration>
  40. <url>http://raspberrypi:8080/manager/text</url>
  41. <server>TomcatServer</server>
  42. <path>/StockBatch</path>
  43. </configuration>
  44. </plugin>
  45. <plugin>
  46. <artifactId>maven-war-plugin</artifactId>
  47. <version>2.6</version>
  48. <configuration>
  49. <failOnMissingWebXml>false</failOnMissingWebXml>
  50. </configuration>
  51. </plugin>
  52. <plugin>
  53. <groupId>org.springframework.boot</groupId>
  54. <artifactId>spring-boot-maven-plugin</artifactId>
  55. <version>1.4.0.RELEASE</version>
  56. </plugin>
  57. </plugins>
  58. </build>
  59. <dependencies>
  60. <dependency>
  61. <groupId>org.springframework.boot</groupId>
  62. <artifactId>spring-boot-starter-tomcat</artifactId>
  63. <scope>provided</scope>
  64. <version>1.4.0.RELEASE</version>
  65. </dependency>
  66. <dependency>
  67. <groupId>org.springframework.boot</groupId>
  68. <artifactId>spring-boot-starter-web</artifactId>
  69. <version>1.4.0.RELEASE</version>
  70. </dependency>
  71. <dependency>
  72. <groupId>org.springframework.boot</groupId>
  73. <artifactId>spring-boot-starter</artifactId>
  74. <version>1.4.0.RELEASE</version>
  75. </dependency>
  76. <dependency>
  77. <groupId>org.eclipse.persistence</groupId>
  78. <artifactId>eclipselink</artifactId>
  79. <version>2.6.3</version>
  80. </dependency>
  81. <dependency>
  82. <groupId>org.springframework</groupId>
  83. <artifactId>spring-tx</artifactId>
  84. <version>4.3.1.RELEASE</version>
  85. </dependency>
  86. <dependency>
  87. <groupId>org.springframework.data</groupId>
  88. <artifactId>spring-data-jpa</artifactId>
  89. <version>1.10.2.RELEASE</version>
  90. </dependency>
  91. <dependency>
  92. <groupId>postgresql</groupId>
  93. <artifactId>postgresql</artifactId>
  94. <version>9.1-901.jdbc4</version>
  95. </dependency>
  96. </dependencies>
  97. </project>
  98.  
  99. @Configuration
  100. @EnableJpaRepositories("foo")
  101. @EnableTransactionManagement
  102. @EnableLoadTimeWeaving
  103. @EnableScheduling
  104. public class AppConfiguration {
  105.  
  106. @Bean
  107. public DataSource dataSource() {
  108. DriverManagerDataSource dmds = new DriverManagerDataSource();
  109. dmds.setUrl("jdbc:postgresql://raspberrypi:5432/stocks");
  110. dmds.setUsername("abc");
  111. dmds.setPassword("***");
  112. dmds.setDriverClassName("org.postgresql.Driver");
  113. return dmds;
  114. }
  115.  
  116. @Bean
  117. public EntityManagerFactory entityManagerFactory() {
  118. EclipseLinkJpaVendorAdapter vendorAdapter = new EclipseLinkJpaVendorAdapter();
  119. vendorAdapter.setGenerateDdl(true);
  120. vendorAdapter.setShowSql(true);
  121.  
  122. LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
  123. factory.setJpaVendorAdapter(vendorAdapter);
  124. factory.setPackagesToScan("foo");
  125. factory.setDataSource(dataSource());
  126. factory.getJpaPropertyMap().put("eclipselink.jdbc.batch-writing", "JDBC");
  127. factory.getJpaPropertyMap().put("eclipselink.jdbc.batch-writing.size", "500");
  128. factory.getJpaPropertyMap().put("eclipselink.persistence-context.flush-mode", "commit");
  129. factory.afterPropertiesSet();
  130.  
  131. return factory.getObject();
  132. }
  133.  
  134. @Bean
  135. public PlatformTransactionManager transactionManager() {
  136. JpaTransactionManager txManager = new JpaTransactionManager();
  137. txManager.setEntityManagerFactory(entityManagerFactory());
  138. return txManager;
  139. }
  140. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement