I am currently working on a maven project but every time i try to deploy my war i get the exception below:
ERROR [DispatcherPortlet:276] Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.context.weaving.AspectJWeavingEnabler#0': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loadTimeWeaver': Initialization of bean failed; nested exception is java.lang.IllegalStateException: ClassLoader [org.apache.catalina.loader.WebappClassLoader] does NOT provide an 'addTransformer(ClassFileTransforme r)' method. Specify a custom LoadTimeWeaver or start your Java virtual machine with Spring's agent: -javaagent:org.springframework.instrument.jar
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1097)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:661)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:446)
at org.springframework.web.portlet.FrameworkPortlet.createPortletApplicationContext(FrameworkPortlet.java:356)
at org.springframework.web.portlet.FrameworkPortlet.initPortletApplicationContext(FrameworkPortlet.java:294)
at org.springframework.web.portlet.FrameworkPortlet.initPortletBean(FrameworkPortlet.java:268)
at org.springframework.web.portlet.GenericPortletBean.init(GenericPortletBean.java:120)
I simply don't understand when i have everything in place properly why this error. Please checkout my declaration in POM.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4</version>
<configuration>
<forkMode>once</forkMode>
<argLine>
-javaagent:"path\spring-instrument-3.1.0.RELEASE.jar"
</argLine>
<useSystemClassloader>true</useSystemClassloader>
</configuration>
</plugin>
Please guide.
If you are using tomcat bundle and to enable load-time-weaving in Tomcat add Spring Instrument Tomcat to Tomcat's lib directory and the following in the context.xml inside the META-INF directory of your tomcat:
<Context path="/test">
<Loader loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader"/>
</Context>
Refer to the Spring Docs on the tomcat's configuration.
Note: The configuration for tomcat differs based on the version.
Though this question was asked long time back, I am still answering it. Somebody else might find it useful.
If you are using Tomcat try adding the following in the catalina.bash for windows or catalina.sh for linux servers:
set CATALINA_OPTS=%CATALINA_OPTS% -javaagent:"C:\path\to\spring-instrument-3.1.1.RELEASE.jar"
Keep in mind it will work only in Tomcat versions less than 7.0.55. After that it wont take it. And you will need to add it in the context.xml as mentioned here load-time-weaver (aspectj-weaver) is not working in apache tomcat 7.0.55.
Related
I have a Spring Boot REST project with multiple #SpringBootTest JUnit test cases.
The project uses Spring Cache with Cache2K. There is a factory bean that creates a CacheManager with a cache.
#Bean
public CacheManager cache2kCacheManager() {
SpringCache2kCacheManager cache2kCacheManager = new SpringCache2kCacheManager()
.defaultSetup(b -> b.entryCapacity(3).expireAfterWrite(3, TimeUnit.SECONDS).disableMonitoring(false));
Function<Cache2kBuilder<?, ?>, Cache2kBuilder<?, ?>> campaignCacheBuilder;
campaignCacheBuilder = x -> x.name("campaigns-cache")
.entryCapacity(5));
cache2kCacheManager.addCaches(campaignCacheBuilder);
return cache2kCacheManager;
}
All the test cases run successfully when run in the IDE. The application also runs when launched in the IDE. However when I run mvn clean install on the project, the test cases fail due to Cache object creation error.
[ERROR] testCacheReadAndWrite Time elapsed: 0 s <<< ERROR!
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cache2kCacheManager' defined in class path resource [com/demos/cachedemo/cache/configuration/Cache2KConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cache.CacheManager]: Factory method 'cache2kCacheManager' threw exception; nested exception is java.lang.IllegalStateException: Cache already created: 'campaigns-cache'
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cache.CacheManager]: Factory method 'cache2kCacheManager' threw exception; nested exception is java.lang.IllegalStateException: Cache already created: 'campaigns-cache'
Caused by: java.lang.IllegalStateException: Cache already created: 'campaigns-cache'
I tried removing the test cases with error, but others start failing with the same exception. It appears that the context is being reused/shared. I have already added #DirtiesContext to the test cases, but that does not fix the issue.
Can anyone help me with this issue?
Update 1: The project was created using start.spring.io and has the default build plugin in pom.xml.
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
The issue was due to the Maven Surefire tests running in parallel. This answer provided a solution which solved the problem.
The project was created using start.spring.io and had default build plugins (I have edited the question with the previous build configuration).
I added the following Surefire configuration to limit the parallel runs.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<reuseForks>false</reuseForks>
<forkCount>1</forkCount>
</configuration>
</plugin>
</plugins>
</build>
If there is a better solution, please post it.
I have built a spring boot war file using maven, When I try to deploy the war file to an external tomcat server in command prompt. I get an exception.
Error creating bean with name 'inMemoryDatabaseShutdownExecutor' defined in class path resource [org/springframework/boot/devtools/autoconfigure/DevToolsDataSourceAutoConfiguration.class]: Unsatisfied dependency expressed through method 'inMemoryDatabaseShutdownExecutor' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: oracle.jdbc.OracleDriver
I am using two application.properties files one in src/main/resources that has the actual datasource config to Oracle and another in src/test/resources that has a datasource for a H2 in memory database.
Please let me know if I missed anything, Like placing the property file in config under tomcat folder etc.
I suppose you have set oracle.jdbc.OracleDriver as driver-class-name on your application.properties under src/main/java, right? Did you remember to include this dependency on pom.xml similar to what follows?
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.4.0</version>
</dependency>
Edit
Try adding this to tomcat's context.xml:
<Resource name="jdbc/mydb" auth="Container" type="javax.sql.DataSource"
maxTotal="100" maxIdle="30" maxWaitMillis="10000"
username="xxx" password="xxx" driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:#localhost:1521:xe"/>
Okay, The root cause of this is there is no oracle6 jar in my war file - Even though I added the dependency in my pom.xml.
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc</artifactId>
<version>6</version>
<scope>system</scope>
<systemPath>${basedir}/lib/ojdbc6.jar</systemPath>
</dependency>
Therefore I've added the jar explicitly into my Tomcat lib and it worked.
I added the Datasource Configuration using the programmatic way as below and it worked, not sure why couldn't it be picked from application.properties.
#Configuration
public class DatasourceConfig {
#Bean
public DataSource datasource() {
return DataSourceBuilder.create()
.driverClassName("com.mysql.cj.jdbc.Driver")
.url("jdbc:mysql://localhost:3306/test_db")
.username("username")
.password("password")
.build();
}
}
Credits to Baeldung article here
I am trying to deploy war on TC server using STS. I am able to build the project without any dependency issues. But once I try to add the war to the server , I get the following error:
[2017-03-29 09:27:14,303] ERROR [ContextLoader]Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ApplConfigService': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configManager': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'UserAuthentication': Injection of resource dependencies failed; nested exception is java.lang.NoClassDefFoundError: SessionFactory
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:311)
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:839)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4729)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5167)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:586)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1750)
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)
Troubleshooting steps I tried:
I made sure the war that was built had all the necessary jars under WEB_INF/lib
Tried adding the jars to buildpath
Made sure maven dependencies are added under Preferences->Deployment Assembly
Cleaned the server several times
Forced maven to download all the jars again
Did Maven install from command line to make sure the wars are building properly
Tried deploying the war manually into tomcat/STS and starting the server on command line. It starts without this error but gives 404 for the application URL.
Tried STS and Eclipse
For some reason it is not able to find the Hibernate jars from the server. I have tried most of the solutions I came across for this error on Stack overflow but it doesn't go away.
Any insights on this will be greatly appreciated!
The issue was with IDE. I copied the WEB-INF folder from target folder of the project and pasted it the folder in server path overriding the WEB-INF present there:
Server path location
I am able to start the server now with no issues
I don't have enough points to comment, this would be better as a comment. But for posterity sake: Many people are not aware that a war file and an ear file are simply zipped up content with specific files in specific places. To look at the file, you can rename the extension to ".zip" and then browse the files inside.
I know you already answered your own question, but others might find this useful. :)
I am migrating EJB 3.0 application from jboss AS 6 to wildfly AS 8.
Is it possible to deploy EJB 3.0 application to wildfly as ease in wildfly? After updating the EJB spec as per wildfly EJB modules in pom.xml, I am getting compilation error that below symbols are not found as the related APIs are not available in wildfly.
org.jboss.ejb3.annotation.LocalBinding;
org.jboss.ejb3.annotation.Depends;
org.jboss.ejb3.annotation.Management;
org.jboss.ejb3.annotation.Service;
The above annotations are found in jboss-ejb3-ext-api.jar and it is a part of jBoss 6 AS.
javax.annotation.security.PermitAll
The above annotations are found in jboss-annotations-api_1.1_spec.jar and it is a part of jBoss 6 AS.
From the documentation, I understood that wildfly support EJB3.2 and EJB3.2 does not support #LocalBinding / #RemoteBinding.So how will I do the same in wildfly using standalone.xml / ejb-jar.xml / any other configuration.
I tried following the blog: JBoss: Binding values into JNDI in JBoss EAP 6 similar to JNDIBindingServiceMgr
but could not link where I tried to lookup EJB bean based on jndi name but did not work.
Please help. Many Thanks.
Annotate you bean interface with #Remote and or #Local.
Annotate you bean implementation with #Stateless.
Build the project with maven to generate EJB JAR and the client JAR (exclude your server implementation if it is used outside of your EAR).
<build>
<plugins>
<!-- maven-ejb-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<configuration>
<clientExcludes>
<clientExclude>**/ejb/*</clientExclude>
</clientExcludes>
</configuration>
</plugin>
</plugins>
</build>
Package the EJB in a EAR. (This is optional, but I deploy the web module as one .ear file).
To be able to know the JNDI Name of you EJB, Wildfly follow the standard naming convention.
`java:global///
For example ear has the name my-ear, ejb name my-ejbs and the bean interface a.b.c.MyBeanRemote and the implementation a.b.c.ejb.MyBean : Remote JNDI path will be java:global/my-ear/my-ejbs/MyBean or more verbose java:global/my-ear/my-ejbs/MyBean!a.b.c.MyBeanRemote.
To generate this structure of deployment I use the following configuration in my ear project:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
<version>7</version>
<applicationId>my-ear</applicationId>
<applicationName>my-ear</applicationName>
<defaultLibBundleDir>/lib</defaultLibBundleDir>
<jboss>
<version>5</version>
<unauthenticated-principal>guest</unauthenticated-principal>
<security-domain>ABC</security-domain>
</jboss>
<modules>
<webModule>
<groupId>a.b.c.my-group</groupId>
<artifactId>my-web-app</artifactId>
<uri>my-web-app.war</uri>
<contextRoot>/my-web-app</contextRoot>
</webModule>
<ejbModule>
<groupId>a.b.c.my-group</groupId>
<artifactId>my-ejbs</artifactId>
<uri>my-ejbs.jar</uri>
</ejbModule>
</modules>
</configuration>
</plugin>
</plugins>
</build>
<applicationName>my-ear</applicationName> will set the right name used by my application EAR (without the version).
<uri>my-ejbs.jar</uri> will remove the version of my ejb module, so it is not reflected in the JNDI path.
Hints: The JNDI name of your bean is printed in the log file when the EAR is deployed.
If you want to access the bean from outside the application server, you must use the JNDI path that begin with java:jboss/exported
I am experimenting with spring, maven, and eclipse but stumbling on a weird issue.
I am running Eclipse Helios SR1 with the STS (Spring tools suite) plugin which includes the Maven plugin also.
What i want to achieve is a spring mvc webapp which uses an application context loaded from a local application context xml file, but also from other application contexts in jar files dependencies included in WEB-INF/lib.
What i'd ultimately like to do is have my persistence layer separated in its own jar file but containing its own spring context files with persistence specific configuration (e.g a jpa entityManagerFactory for example).
So to experiment with loading resources from jar dependencies, i created a simple maven project from eclipse, which defines an applicationContext.xml file in src/main/resources
Inside, i define a bean
<bean id="mybean" class="org.test.MyClass" />
and create the class in the org.test package
I run mvn->install from eclipse, which generates me a jar file containing my class and the applicationContext.xml file:
testproj.jar
|_META-INF
|_org
|_test
|_MyClass.class
|_applicationContext.xml
I then create a spring mvc project from the Spring template projects provided by STS.
I have configured an instance of Tomcat 7.0.8 , and also an instance of springSource tc Server within eclipse. Deploying the newly created project on both servers works without problem.
I then add my previous project as a maven dependency of the mvc project. the jar file is correctly added in the Maven Dependencies of the project.
In the web.xml that is generated, i now want to load the applicationContext.xml from the jar file as well as the existing one generated for the project. My web.xml now looks like this:
org.springframework.web.context.ContextLoaderListener
<!-- Processes application requests -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath*:applicationContext.xml,
/WEB-INF/spring/appServlet/servlet-context.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
Also, in my servlet-context.xml, i have the following:
<context:component-scan base-package="org.test" />
<context:component-scan base-package="org.remy.mvc" />
to load classes from the jar spring context (org.test) and to load controllers from the mvc app context.
I also change one of my controllers in org.remy.mvc to autowire MyClass to verify that loading the context has worked as intended.
public class MyController {
#Autowired
private MyClass myClass;
public void setMyClass(MyClass myClass) {
this.myClass = myClass;
}
public MyClass getMyClass() {
return myClass;
}
[...]
}
Now this is the weird bit:
If i deploy the spring mvc web on my tomcat instance inside eclipse (run on server...) I get the following error :
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/test/MyClass
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:442)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:458)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:339)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:306)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
at javax.servlet.GenericServlet.init(GenericServlet.java:160)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1133)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1087)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:996)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4834)
at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5155)
at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5150)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NoClassDefFoundError: org/test/MyClass
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
at java.lang.Class.getDeclaredMethods(Class.java:1791)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:446)
at org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping.determineUrlsForHandlerMethods(DefaultAnnotationHandlerMapping.java:172)
at org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping.determineUrlsForHandler(DefaultAnnotationHandlerMapping.java:118)
at org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMapping.detectHandlers(AbstractDetectingUrlHandlerMapping.java:79)
at org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMapping.initApplicationContext(AbstractDetectingUrlHandlerMapping.java:58)
at org.springframework.context.support.ApplicationObjectSupport.initApplicationContext(ApplicationObjectSupport.java:119)
at org.springframework.web.context.support.WebApplicationObjectSupport.initApplicationContext(WebApplicationObjectSupport.java:72)
at org.springframework.context.support.ApplicationObjectSupport.setApplicationContext(ApplicationObjectSupport.java:73)
at org.springframework.context.support.ApplicationContextAwareProcessor.invokeAwareInterfaces(ApplicationContextAwareProcessor.java:106)
at org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:85)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:394)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1413)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
... 25 more
20-Feb-2011 10:54:53 org.apache.catalina.core.ApplicationContext log
SEVERE: StandardWrapper.Throwable
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/test/MyClass
If i build the war file (using maven "install" goal), and then deploy that war file in the webapps directory of a standalone tomcat server (7.0.8 as well) it WORKS :-(
What am i missing ?
Thanks for the help.
Thanks to all of you who tried to answer my question. I think i found the solution to my own problem (after much frustration)
This has already been answered in
ClassNotFoundException DispatcherServlet when launching Tomcat (Maven dependencies not copied to wtpwebapps)
Sounds like a spring.jar is being picked up from inside Tomcat which is the wrong classloader as it cannot see your classes.
How did you install said Tomcat inside Eclipse?