I'm exporting a JAR that contains a class:
public class SerializerHelper {
public String toJson(final Object src) {...}
}
And the trialApplicationContext.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="serializerHelper" class="com.trial.SerializerHelper"/>
</beans>
Then, I'm importing that JAR on another project, and on its applicationContext.xml I'm importing the trial context as follows:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- Replace all @Autowired by its instances -->
<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/>
<import resource="classpath*:trialApplicationContext"/>
<bean id="booksSerializer" class="com.trial.BooksSerializerImpl" />
...
</beans>
And then, I'm using that bean on my class as:
public interface BooksSerializer {
String getBooks();
}
public class BooksSerializerImpl implements BooksSerializer {
@Autowired
private SerializerHelper serializerHelper;
...
}
However, the code is failing with the following error:
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'booksSerializer' defined in URL [...applicationContext.xml]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect bean class [com.trial.BooksSerializerImpl] for autowiring metadata: could not find class that it depends on java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'booksSerializer' defined in URL [jar:file:/....jar!/applicationContext.xml]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect bean class [com.trial.BooksSerializerImpl] for autowiring metadata: could not find class that it depends on at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:921) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:900) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:684) at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2044) at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1690) at com.sun.enterprise.web.WebApplication.start(WebApplication.java:107) at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122) java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'booksSerializer' defined in URL [jar:file:/....jar!/applicationContext]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect bean class [com.trial.BooksSerializerImpl] for autowiring metadata: could not find class that it depends on at com.sun.enterprise.web.WebApplication.start(WebApplication.java:136) at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122) java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'productSerializer' defined in URL [jar:file:/....jar!/applicationContext.xml]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect bean class [com.trial.BooksSerializerImpl] for autowiring metadata: could not find class that it depends on at com.sun.enterprise.web.WebApplication.start(WebApplication.java:136) at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122) Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'booksSerializer' defined in URL [jar:file:/....jar!/applicationContext.xml]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect bean class [com.trial.BooksSerializerImpl] for autowiring metadata: could not find class that it depends on]]
This error is happening when I'm trying to run my project on a jersey server.
What am I doing wrong? Thanks a lot.
BooksSerializer
interface? Did you put any annotation on that interface ? – Ataur Rahman MunnaBooksSerializer
interface with@Service
and let me know the status. – Ataur Rahman Munna<mvc:component-scan ="package">
? – Ataur Rahman Munna