Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
- at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
- ... 95 more
- Caused by: java.lang.IllegalStateException: Cannot apply class transformer without LoadTimeWeaver specified
- at org.springframework.orm.jpa.persistenceunit.SpringPersistenceUnitInfo.addTransformer(SpringPersistenceUnitInfo.java:80)
- at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactoryImpl(PersistenceProvider.java:373)
- at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactory(PersistenceProvider.java:313)
- at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:343)
- at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:319)
- at foo.AppConfiguration.entityManagerFactory(AppConfiguration.java:57)
- at foo.AppConfiguration$$EnhancerBySpringCGLIB$$a92e9feb.CGLIB$entityManagerFactory$1(<generated>)
- at foo.AppConfiguration$$EnhancerBySpringCGLIB$$a92e9feb$$FastClassBySpringCGLIB$$e4dbaad1.invoke(<generated>)
- at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
- at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:356)
- at foo.AppConfiguration$$EnhancerBySpringCGLIB$$a92e9feb.entityManagerFactory(<generated>)
- at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
- <?xml version="1.0" encoding="UTF-8"?>
- <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">
- <modelVersion>4.0.0</modelVersion>
- <groupId>com.ss.stock</groupId>
- <artifactId>SimpleTest</artifactId>
- <version>1.0-SNAPSHOT</version>
- <packaging>war</packaging>
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <maven.compiler.source>1.8</maven.compiler.source>
- <maven.compiler.target>1.8</maven.compiler.target>
- </properties>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.tomcat.maven</groupId>
- <artifactId>tomcat7-maven-plugin</artifactId>
- <version>2.2</version>
- <configuration>
- <url>http://raspberrypi:8080/manager/text</url>
- <server>TomcatServer</server>
- <path>/StockBatch</path>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-war-plugin</artifactId>
- <version>2.6</version>
- <configuration>
- <failOnMissingWebXml>false</failOnMissingWebXml>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-maven-plugin</artifactId>
- <version>1.4.0.RELEASE</version>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-tomcat</artifactId>
- <scope>provided</scope>
- <version>1.4.0.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-web</artifactId>
- <version>1.4.0.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter</artifactId>
- <version>1.4.0.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.persistence</groupId>
- <artifactId>eclipselink</artifactId>
- <version>2.6.3</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-tx</artifactId>
- <version>4.3.1.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>org.springframework.data</groupId>
- <artifactId>spring-data-jpa</artifactId>
- <version>1.10.2.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>postgresql</groupId>
- <artifactId>postgresql</artifactId>
- <version>9.1-901.jdbc4</version>
- </dependency>
- </dependencies>
- </project>
- @Configuration
- @EnableJpaRepositories("foo")
- @EnableTransactionManagement
- @EnableLoadTimeWeaving
- @EnableScheduling
- public class AppConfiguration {
- @Bean
- public DataSource dataSource() {
- DriverManagerDataSource dmds = new DriverManagerDataSource();
- dmds.setUrl("jdbc:postgresql://raspberrypi:5432/stocks");
- dmds.setUsername("abc");
- dmds.setPassword("***");
- dmds.setDriverClassName("org.postgresql.Driver");
- return dmds;
- }
- @Bean
- public EntityManagerFactory entityManagerFactory() {
- EclipseLinkJpaVendorAdapter vendorAdapter = new EclipseLinkJpaVendorAdapter();
- vendorAdapter.setGenerateDdl(true);
- vendorAdapter.setShowSql(true);
- LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
- factory.setJpaVendorAdapter(vendorAdapter);
- factory.setPackagesToScan("foo");
- factory.setDataSource(dataSource());
- factory.getJpaPropertyMap().put("eclipselink.jdbc.batch-writing", "JDBC");
- factory.getJpaPropertyMap().put("eclipselink.jdbc.batch-writing.size", "500");
- factory.getJpaPropertyMap().put("eclipselink.persistence-context.flush-mode", "commit");
- factory.afterPropertiesSet();
- return factory.getObject();
- }
- @Bean
- public PlatformTransactionManager transactionManager() {
- JpaTransactionManager txManager = new JpaTransactionManager();
- txManager.setEntityManagerFactory(entityManagerFactory());
- return txManager;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement