0

I have my Configuration class with Beans as mentioned below

  @Bean(name = "entityManagerFactory")
  public LocalContainerEntityManagerFactoryBean  entityManagerFactory(@Qualifier("sqlServerDataSource") DataSource dataSource) {
      LocalContainerEntityManagerFactoryBean lef = new    LocalContainerEntityManagerFactoryBean();
      lef.setDataSource(dataSource);
      lef.setJpaVendorAdapter(jpaVendorAdapter());
      lef.setPackagesToScan("de.id.dih");
      return lef;
  }

  private JpaVendorAdapter jpaVendorAdapter() {
      HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter();
      hibernateJpaVendorAdapter.setShowSql(true);
      hibernateJpaVendorAdapter.setDatabase(Database.SQL_SERVER);
      hibernateJpaVendorAdapter.setDatabasePlatform("org.hibernate.dialect.SQLServer2008Dialect");
      return hibernateJpaVendorAdapter;
  }

  @Bean
  public PlatformTransactionManager   transactionManager(LocalContainerEntityManagerFactoryBean emf) {
      JpaTransactionManager transactionManager = new JpaTransactionManager();
      transactionManager.setEntityManagerFactory(emf.getObject());
      return transactionManager;
  } 

and Maven dependancies look like:

<dependency>
    <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
    <scope>provided</scope>
</dependency>

<dependency>
    <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
    <!--<scope>provided</scope>-->
</dependency>

<dependency>
    <groupId>org.apache.tomcat</groupId>
    <artifactId>tomcat-jdbc</artifactId>
</dependency>

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.6</version>
</dependency>

<dependency>
    <groupId>com.microsoft.sqlserver</groupId>
    <artifactId>sqljdbc4</artifactId>
    <version>4.0</version>
</dependency> 

And when I deploy my module in Spring XD, I get the following exception

ERROR DeploymentsPathChildrenCache-0 server.ContainerRegistrar - Exception deploying module
java.lang.IllegalArgumentException: Cannot instantiate interface org.springframework.boot.SpringApplicationRunListener : org.springframework.boot.context.event.EventPublishingRunListener
    at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:381)
    at org.springframework.boot.SpringApplication.getRunListeners(SpringApplication.java:352)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:274)
    at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:142)
    at org.springframework.xd.module.core.SimpleModule.initialize(SimpleModule.java:203)
    at org.springframework.xd.dirt.module.ModuleDeployer.deploy(ModuleDeployer.java:98)
    at org.springframework.xd.dirt.module.ModuleDeployer.deployAndStore(ModuleDeployer.java:88)
    at org.springframework.xd.dirt.module.ModuleDeployer.deployAndStore(ModuleDeployer.java:78)
    at org.springframework.xd.dirt.server.ContainerRegistrar.deployModule(ContainerRegistrar.java:231)
    at org.springframework.xd.dirt.server.ContainerRegistrar.deployJobModule(ContainerRegistrar.java:530)
    at org.springframework.xd.dirt.server.ContainerRegistrar.onChildAdded(ContainerRegistrar.java:447)
    at org.springframework.xd.dirt.server.ContainerRegistrar.access$800(ContainerRegistrar.java:95)
    at org.springframework.xd.dirt.server.ContainerRegistrar$DeploymentListener.childEvent(ContainerRegistrar.java:826)
    at org.apache.curator.framework.recipes.cache.PathChildrenCache$5.apply(PathChildrenCache.java:509)
    at org.apache.curator.framework.recipes.cache.PathChildrenCache$5.apply(PathChildrenCache.java:503)
    at org.apache.curator.framework.listen.ListenerContainer$1.run(ListenerContainer.java:92)
    at com.google.common.util.concurrent.MoreExecutors$SameThreadExecutorService.execute(MoreExecutors.java:297)
    at org.apache.curator.framework.listen.ListenerContainer.forEach(ListenerContainer.java:83)
    at org.apache.curator.framework.recipes.cache.PathChildrenCache.callListeners(PathChildrenCache.java:500)
    at org.apache.curator.framework.recipes.cache.EventOperation.invoke(EventOperation.java:35)
    at org.apache.curator.framework.recipes.cache.PathChildrenCache$10.run(PathChildrenCache.java:762)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:722)
   Caused by: java.lang.IllegalArgumentException: class    org.springframework.boot.context.event.EventPublishingRunListener is not assignable to interface org.springframework.boot.SpringApplicationRunListener
    at org.springframework.util.Assert.isAssignable(Assert.java:369)
    at org.springframework.util.Assert.isAssignable(Assert.java:352)
    at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:375)
    ... 29 more

Is it possible to have Configuration class with above mentioned Beans in Spring XD environment ??

Any sooner help is greatly appreciated.

Thanks

Paul Samsotha
  • 205,037
  • 37
  • 486
  • 720
VinniK
  • 35
  • 5

1 Answers1

1

Seems like a classloader issue. Make sure that your module lib/ directory does not contain any jars (same or different version) that are already in XD's global lib/ directory.

If you want to automate this and are ok with gradle, you could draw inspiration from https://github.com/pperalta/spring-xd-source-template build file (this is for a source module, but you can derive the same thing for other kind of module I bet)

ebottard
  • 1,997
  • 2
  • 12
  • 14
  • I do a double check of not having the jars with same or different version. But some how, I feel Spring XD is not supporting the HibernateJpaVendorAdapter . Does any one have sample POC or working example of it ?? – VinniK Sep 12 '14 at 07:43
  • Is there somewhere where we can see your module files, or is this closed source? – ebottard Sep 19 '14 at 07:59