0

I have a WAR containing a dependency JAR. The JAR contains cross-cutting concerns and is written by me as well. I'm using Spring 4.2.3 and Spring-data-jpa 1.9.1 and my configuration is annotation based. I deploy to Wildfly 10.1.0.

The JAR compiles fine and I install it to my local Maven Repo. From the WAR, the JAR is included as a dependency. So far so good.

On the Spring Configuration file of the WAR, I import the Spring Configuration file of the JAR.

Now, when I have normal Spring Beans (Service or Component), everything works fine and Spring finds and resolves all dependencies and Spring Beans in my JAR, which I can then subsequently invoke from the code in my WAR.

However, as soon as I add a Repository and an Entity, Spring does not find the Entity and subsequently my WAR compiles but it does not deploy. I must note that all of this works if I put the JAR code in my WAR direcetly. I think I'm missing a configuration, but I'm not sure where else to look.

Any assistance will be greatly appreciated. Code and Stack-trace below:

On deployment, I get the following error: Error creating bean with name 'synapseRepo': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not an managed type: class hyphen.synapse.data.model.Role

So, the error is pretty straightforward, but I'm not sure what else it is that I'm missing to let Spring know about my Entity.

Thanks.

JAR Code for Configuration:

@Configuration
@ComponentScan("hyphen.synapse")
@EnableTransactionManagement
@EnableJpaRepositories("hyphen.synapse.data")
@PropertySource("classpath:application.properties")
public class SynapseApplicationConfig {
...
}

JAR Code for Repository:

package hyphen.synapse.data.repo;

import hyphen.synapse.data.model.*;
import org.springframework.data.repository.*;

public interface SynapseRepo extends CrudRepository<Role, Long> {

}

JAR Code for Entity:

package hyphen.synapse.data.model;

import javax.persistence.*;

@Entity
@Table(name = "ROLE")
public class Role extends SynapseBaseEntity {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private long id;

    @Column(name = "NAME")
    private String name;


    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}

WAR Code for Configuration:

@Configuration
@EnableTransactionManagement
@EnableJpaRepositories("hyphen.cmd.data")
@PropertySource("classpath:application.properties")
@Import(hyphen.synapse.app.config.SynapseApplicationConfig.class)
public class ApplicationConfig {
...
}

WAR Code for Injection:

package hyphen.synapse.data.dao;

import ...;

@Service
public class SynapseDao {
    @Inject
    private SynapseRepo synapseRepo;

    @Inject
    private EmailService emailService;

Just as a side-note, EmailService is also defined in the JAR, which is autowired correctly.

The following line of code is causing the error:

public interface SynapseRepo extends CrudRepository<Role, Long> ...

Spring is unable to autowire the Entity, in this case, Role. I also know that Role does not contain any Spring annotations. However, I have this exact same code in a WAR and it works fine, but invoking it from a WAR with the code contained in a dependency JAR seems problematic.

Stack-trace:

2017-02-16 22:38:19,666 WARN  [org.springframework.web.context.support.XmlWebApplicationContext] (ServerService Thread Pool -- 218) Exception encountered during context initialization - cancelling refresh at
tempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'synapseServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.f
actory.BeanCreationException: Could not autowire field: private hyphen.synapse.data.dao.SynapseDao hyphen.synapse.business.service.impl.SynapseServiceImpl.synapseDao; nested exception is org.springframework.
beans.factory.BeanCreationException: Error creating bean with name 'synapseDao': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could
 not autowire field: private hyphen.synapse.data.repo.SynapseRepo hyphen.synapse.data.dao.SynapseDao.synapseRepo; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating b
ean with name 'synapseRepo': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not an managed type: class hyphen.synapse.data.model.Role
2017-02-16 22:38:19,666 ERROR [org.springframework.web.servlet.DispatcherServlet] (ServerService Thread Pool -- 218) Context initialization failed: org.springframework.beans.factory.BeanCreationException: Er
ror creating bean with name 'synapseServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private hy
phen.synapse.data.dao.SynapseDao hyphen.synapse.business.service.impl.SynapseServiceImpl.synapseDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name
 'synapseDao': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private hyphen.synapse.data.repo.SynapseRepo
hyphen.synapse.data.dao.SynapseDao.synapseRepo; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'synapseRepo': Invocation of init method failed; nes
ted exception is java.lang.IllegalArgumentException: Not an managed type: class hyphen.synapse.data.model.Role
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:838)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537)
        at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:667)
        at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:633)
        at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:681)
        at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:552)
        at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:493)
        at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
        at javax.servlet.GenericServlet.init(GenericServlet.java:244)
        at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:117)
        at org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:78)
        at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:103)
        at io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:250)
        at io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:133)
        at io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:546)
        at io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:517)
        at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
        at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:559)
        at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:101)
        at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:82)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
        at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private hyphen.synapse.data.dao.SynapseDao hyphen.synapse.business.service.impl.SynapseServiceImpl.synapseDao; ne
sted exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'synapseDao': Injection of autowired dependencies failed; nested exception is org.springframework.bean
s.factory.BeanCreationException: Could not autowire field: private hyphen.synapse.data.repo.SynapseRepo hyphen.synapse.data.dao.SynapseDao.synapseRepo; nested exception is org.springframework.beans.factory.B
eanCreationException: Error creating bean with name 'synapseRepo': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not an managed type: class hyphen.synapse.data.mod
el.Role
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573)
        at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
        ... 41 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'synapseDao': Injection of autowired dependencies failed; nested exception is org.springframework.beans.facto
ry.BeanCreationException: Could not autowire field: private hyphen.synapse.data.repo.SynapseRepo hyphen.synapse.data.dao.SynapseDao.synapseRepo; nested exception is org.springframework.beans.factory.BeanCrea
tionException: Error creating bean with name 'synapseRepo': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not an managed type: class hyphen.synapse.data.model.Role
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545)
        ... 43 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private hyphen.synapse.data.repo.SynapseRepo hyphen.synapse.data.dao.SynapseDao.synapseRepo; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'synapseRepo': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not an managed
type: class hyphen.synapse.data.model.Role
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573)
        at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
        ... 54 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'synapseRepo': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not
an managed type: class hyphen.synapse.data.model.Role
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545)
        ... 56 more
Caused by: java.lang.IllegalArgumentException: Not an managed type: class hyphen.synapse.data.model.Role
        at org.hibernate.jpa.internal.metamodel.MetamodelImpl.managedType(MetamodelImpl.java:219)
        at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.<init>(JpaMetamodelEntityInformation.java:68)
        at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getEntityInformation(JpaEntityInformationSupport.java:67)
        at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:152)
        at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:99)
        at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:81)
        at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:185)
        at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:251)
        at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:237)
        at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:92)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
        ... 66 more

2017-02-16 22:38:19,666 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 218) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./masterdatamanager: org.
jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./masterdatamanager: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 's
ynapseServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private hyphen.synapse.data.dao.SynapseD
ao hyphen.synapse.business.service.impl.SynapseServiceImpl.synapseDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'synapseDao': Injection of au
towired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private hyphen.synapse.data.repo.SynapseRepo hyphen.synapse.data.dao.Synaps
eDao.synapseRepo; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'synapseRepo': Invocation of init method failed; nested exception is java.lang.Ill
egalArgumentException: Not an managed type: class hyphen.synapse.data.model.Role
        at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:85)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
        at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'synapseServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.bea
ns.factory.BeanCreationException: Could not autowire field: private hyphen.synapse.data.dao.SynapseDao hyphen.synapse.business.service.impl.SynapseServiceImpl.synapseDao; nested exception is org.springframew
ork.beans.factory.BeanCreationException: Error creating bean with name 'synapseDao': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: C
ould not autowire field: private hyphen.synapse.data.repo.SynapseRepo hyphen.synapse.data.dao.SynapseDao.synapseRepo; nested exception is org.springframework.beans.factory.BeanCreationException: Error creati
ng bean with name 'synapseRepo': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not an managed type: class hyphen.synapse.data.model.Role
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:838)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537)
        at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:667)
        at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:633)
        at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:681)
        at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:552)
        at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:493)
        at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
        at javax.servlet.GenericServlet.init(GenericServlet.java:244)
        at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:117)
        at org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:78)
        at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:103)
        at io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:250)
        at io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:133)
        at io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:546)
        at io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:517)
        at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
        at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:559)
        at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:101)
        at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:82)
        ... 6 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private hyphen.synapse.data.dao.SynapseDao hyphen.synapse.business.service.impl.SynapseServiceImpl.synapseDao; ne
sted exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'synapseDao': Injection of autowired dependencies failed; nested exception is org.springframework.bean
s.factory.BeanCreationException: Could not autowire field: private hyphen.synapse.data.repo.SynapseRepo hyphen.synapse.data.dao.SynapseDao.synapseRepo; nested exception is org.springframework.beans.factory.B
eanCreationException: Error creating bean with name 'synapseRepo': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not an managed type: class hyphen.synapse.data.mod
el.Role
Eugene
  • 3
  • 3

1 Answers1

1

Your SynapseRepo and CommandRepo interface should have the @Repository annotation.

However the root of the problem is that you have a JPA configuration in your WAR file and a JPA configuration in your JAR. Because the names, properties files, etc. will lead to beans overriding each other. You will need to spend the time to make them unique. You can follow the instructions at https://stackoverflow.com/a/19976132/724835

Community
  • 1
  • 1
JustinKSU
  • 4,875
  • 2
  • 29
  • 51
  • Thanks for your response. Can you please elaborate on Point 1, I'm not sure what you mean. Regarding Point 2, I've tried that, but same result, albeit that it is not required since it is inherited by extending CrudRepository. – Eugene Feb 17 '17 at 07:54
  • Looking at the error more closely I updated my answer. – JustinKSU Feb 17 '17 at 14:38
  • Thanks JustinKSU, I've attempted your suggestions but the error persists. I've also removed "extends SynapseBaseEntity" from the Role class declaration. SynapseBaseEntity is an empty class that implements Serializable, but I've removed it anyway. The only place where class Role is reference is in SynapseRepo: public interface SynapseRepo extends CrudRepository { } On second thought – Eugene Feb 17 '17 at 16:09
  • This exact JAR codebase works when I deploy it as a WAR directly. I'm quite happy to make my codebase available for scrutiny. Can I upload it here as a zip? – Eugene Feb 17 '17 at 16:17
  • I'm not sure what the issue is. It looks correct. If you can share the code on GitHub I could look deeper. – JustinKSU Feb 17 '17 at 18:05
  • Thanks, Really appreciate it. I'll post it there and advise once complete. Kinds Regards. – Eugene Feb 17 '17 at 19:17
  • Hi, I've deployed the code to GitHub. Any assistance will really be appreciated. Synapse is the JAR and CustomerManager is the WAR. URL: https://github.com/eugenemartinza Thanks. – Eugene Feb 17 '17 at 22:47
  • Your repo is still missing @Repository – JustinKSU Feb 17 '17 at 23:26
  • Hi, I Just checked, it is there. – Eugene Feb 19 '17 at 19:46
  • I see it now. I'll try to find some time today to look more closely – JustinKSU Feb 20 '17 at 16:44
  • @Eugene you checked in your password, make sure you change it locally. – JustinKSU Feb 20 '17 at 23:32
  • @Eugene I checked out the code and can see that independently they do work (as you said). The core of the problem is you have the JPA configurations overriding each other. See the updated answer for how to fix this. Please accept this answer if it works for you. – JustinKSU Feb 21 '17 at 00:27
  • Please accept my utmost gratitude for taking the time and effort to read my code and post your answer. It resolved my issue. Really, you won't know what this means to us that this matter is resolved. This problem altogether halted our progress in terms of Component Development for the past 3 weeks now and you managed to provide us with a solution. Again, I absolutely appreciate your time and effort. Thank you very, very much. :-) Regards, Eugene. – Eugene Feb 21 '17 at 15:57
  • I'm glad I could help. Computer programming is a community. Pay it forward by becoming active on this site. Cheers – JustinKSU Feb 21 '17 at 21:38