Issues with Oracle JDBC with Hibernate... Sometimes - oracle

I'm having a bit of a unique issue.
I'm able to successfully connect and manage entities when running JUnit tests, but once I start my actual application, I get "Specified JDBC Driver oracle.jdbc.OracleDriver class not found."
What confuses me is that it is there. It works when running my JUnit Tests.
Any insights are appreciated!
hibernate.cfg.xml
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="db">
<property name="hibernate.connection.driver_class">oracle.jdbc.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:#host:port/db</property>
<property name="hibernate.connection.username">username</property>
<property name="hibernate.connection.password">password</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="hibernate.default_schema">db</property>
<property name="show_sql">true</property>
<mapping resource="org/entity/RunResultEntity.hbm.xml"/>
<mapping resource="org/entity/TransactionResultEntity.hbm.xml"/>
<mapping resource="org/entity/FailureResultEntity.hbm.xml"/>
</session-factory>
</hibernate-configuration>
HibernateUtil.java
package org.util;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.*;
public class HibernateUtil {
private static SessionFactory sessionFactory = buildSessionFactory();
private static SessionFactory buildSessionFactory() {
try {
// Create the SessionFactory from hibernate.cfg.xml
Configuration configuration = new Configuration();
configuration.configure();
ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(
configuration.getProperties()
).buildServiceRegistry();
sessionFactory = configuration.buildSessionFactory(serviceRegistry);
return sessionFactory;
} catch (Throwable ex) {
// Exception thrown here!
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
public static void shutdown() {
// Close caches and connection pools
getSessionFactory().close();
}
}
pom.xml (dependency added to local repository)
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.3.0</version>
<scope>provided</scope>
</dependency>
log
Oct 09, 2014 3:02:58 PM org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
Oct 09, 2014 3:02:58 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.0.1.Final}
Oct 09, 2014 3:02:58 PM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
Oct 09, 2014 3:02:58 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
Oct 09, 2014 3:02:58 PM org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
Oct 09, 2014 3:02:58 PM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
Oct 09, 2014 3:02:58 PM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: org/entity/RunResultEntity.hbm.xml
Oct 09, 2014 3:02:59 PM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: org/entity/TransactionResultEntity.hbm.xml
Oct 09, 2014 3:02:59 PM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: org/entity/FailureResultEntity.hbm.xml
Oct 09, 2014 3:02:59 PM org.hibernate.cfg.Configuration doConfigure
INFO: HHH000041: Configured SessionFactory: db
Oct 09, 2014 3:02:59 PM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000402: Using Hibernate built-in connection pool (not for production use!)
Initial SessionFactory creation failed.org.hibernate.HibernateException: Specified JDBC Driver oracle.jdbc.OracleDriver class not found
Exception in thread "main" java.lang.ExceptionInInitializerError

I found my problem. Lower in my pom.xml I had this little snippet
<dependency>
<groupId>org.hibernate.common</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>4.0.1.Final</version>
<classifier>tests</classifier>
</dependency>
The classifier was only giving access to my test suite. Removing the classifier fixed the issue.
<dependency>
<groupId>org.hibernate.common</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>4.0.1.Final</version>
</dependency>

Related

Spring boot #Cron taking a long time(5 min) to start up

have a cron job class which is annotated with #Component.
when I am running the cron job its taking approx 5 min to start up.
the last logs are mentioned above
eligible.coupon.merchant.scheduler.cron=0 * * * * *
Sep 21, 2020 2:59:43 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {5.2.17.Final}
Sep 21, 2020 2:59:43 PM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
Sep 21, 2020 2:59:43 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
Sep 21, 2020 2:59:44 PM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.Oracle12cDialect
Sep 21, 2020 2:59:45 PM org.hibernate.type.BasicTypeRegistry register
INFO: HHH000270: Type registration [byte[]] overrides previous : org.hibernate.type.BinaryType#1410d645
Sep 21, 2020 2:59:45 PM org.hibernate.type.BasicTypeRegistry register
INFO: HHH000270: Type registration [[B] overrides previous : org.hibernate.type.BinaryType#1410d645
Sep 21, 2020 2:59:45 PM org.hibernate.type.BasicTypeRegistry register
INFO: HHH000270: Type registration [Byte[]] overrides previous : org.hibernate.type.WrapperBinaryType#13908f9c
Sep 21, 2020 2:59:45 PM org.hibernate.type.BasicTypeRegistry register
#Component
public class EligibleMerchantController extends DigitalApiRestServiceBinding implements MerchantSchedulerService {
protected final Logger log = LoggerFactory.getLogger(EligibleMerchantController.class);
#Value("${eligible.coupon.merchant.pagesize}")
Integer defaultPagesize;
#Autowired
EligibleMerchantBusinessService service;
#Override
#Scheduled(cron = "${eligible.coupon.merchant.scheduler.cron}")
public void eligibleMerchantScheduler() {
// my cron job
}
}
#Bean
public TaskScheduler taskScheduler() {
return new ConcurrentTaskScheduler();
}
}
its taking more than 5 min which it shouldnt
removed a property
spring.jpa.hibernate.ddl-auto=update
this was taking a long time

Spring Rich Client Toolbar Menu won't show

I have downloaded Spring Rich Client 1.1.0 from sourceforge and wired up all the beans. When I run the app, I see a pane but no menubar. No warnings or errors in the console.
Here are the menuBar beans:
<bean id="menuBar" class="org.springframework.richclient.command.CommandGroupFactoryBean" >
<property name="members">
<list>
<ref bean="userManagementMenu" />
</list>
</property>
</bean>
<bean id="userManagementMenu" class="org.springframework.richclient.command.CommandGroupFactoryBean" >
<property name="members">
<list>
<ref bean="userCommand"/>
<ref bean="userGroupCommand"/>
<value>separator</value>
</list>
</property>
</bean>
<bean id="fd1" class="org.springframework.richclient.command.config.CommandFaceDescriptor">
<constructor-arg index="0" value="hello"/>
</bean>
<bean id="fd2" class="org.springframework.richclient.command.config.CommandFaceDescriptor">
<constructor-arg index="0" value="there"/>
</bean>
<bean id="userCommand" class="org.springframework.richclient.command.support.WidgetViewCommand">
<property name="widgetViewDescriptorId" value="userView" />
<property name="faceDescriptor" ref="fd1"/>
</bean>
<bean id="userGroupCommand" class="org.springframework.richclient.command.support.WidgetViewCommand">
<property name="widgetViewDescriptorId" value="userGroupView" />
<property name="faceDescriptor" ref="fd2"/>
</bean>
And it is called as follows:
<bean id="lifecycleAdvisor" class="org.springframework.richclient.application.config.DefaultApplicationLifecycleAdvisor">
<property name="windowCommandBarDefinitions" value="ctx/commands.xml"/>
<property name="windowCommandManagerBeanName" value="windowCommandManager"/>
<property name="startingPageId" value="userGroupView"/>
<property name="menubarBeanName" value="menuBar"/>
</bean>
Here are the view related beans:
<bean name="userView" scope="prototype" class="org.springframework.richclient.application.support.DefaultViewDescriptor">
<property name="viewClass" value="com.mycom.views.UserGroupView"/>
</bean>
<bean name="userGroupView" scope="prototype" class="org.springframework.richclient.application.support.DefaultViewDescriptor">
<property name="viewClass" value="com.mycom.views.UserGroupView"/>
</bean>
Here are the misc beans
<bean id="serviceLocator" class="org.springframework.richclient.application.ApplicationServicesLocator">
<property name="applicationServices" ref="applicationServices" />
</bean>
<bean id="applicationServices"
class="org.springframework.richclient.application.support.DefaultApplicationServices" />
<bean id="applicationEventMulticaster"
class="org.springframework.context.event.SimpleApplicationEventMulticaster" />
<bean id="application" class="org.springframework.richclient.application.Application">
<constructor-arg index="0" ref="applicationDescriptor"/>
<constructor-arg index="1" ref="lifecycleAdvisor"/>
</bean>
<bean id="applicationDescriptor" class="org.springframework.richclient.application.support.DefaultApplicationDescriptor">
<property name="version" value="1.0"/>
<property name="buildId" value="20060408-001"/>
</bean>
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basenames">
<list>
<value>messages</value>
</list>
</property>
</bean>
Here is the UserGroupView:
package com.mycom.views;
import java.awt.BorderLayout;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import org.springframework.richclient.application.support.AbstractView;
public class UserGroupView extends AbstractView {
private JTextField field = new JTextField();
private JLabel lbl = new JLabel("UserGroup:");
public JComponent createControl() {
JPanel view = new JPanel();
view.add(lbl, BorderLayout.NORTH);
view.add(field, BorderLayout.SOUTH);
return view;
}
}
Here is the code for UserView
package com.mycom.views;
import java.awt.BorderLayout;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import org.springframework.richclient.application.support.AbstractView;
public class UserView extends AbstractView {
private JTextField field = new JTextField();
private JLabel lbl = new JLabel("User:");
public JComponent createControl() {
JPanel view = new JPanel();
view.add(lbl, BorderLayout.NORTH);
view.add(field, BorderLayout.SOUTH);
return view;
}
}
Here is the console log:
Feb 24, 2016 9:21:13 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext#45283ce2: display name [org.springframework.context.support.ClassPathXmlApplicationContext#45283ce2]; startup date [Wed Feb 24 09:21:13 PST 2016]; root of context hierarchy
Feb 24, 2016 9:21:13 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [ctx/appbundle.xml]
Feb 24, 2016 9:21:13 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [ctx/application.xml]
Feb 24, 2016 9:21:13 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [ctx/commands.xml]
Feb 24, 2016 9:21:13 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [ctx/models.xml]
Feb 24, 2016 9:21:13 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [ctx/filters.xml]
Feb 24, 2016 9:21:13 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [ctx/filterforms.xml]
Feb 24, 2016 9:21:13 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [ctx/editors.xml]
Feb 24, 2016 9:21:13 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [ctx/forms.xml]
Feb 24, 2016 9:21:13 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [ctx/dataproviders.xml]
Feb 24, 2016 9:21:13 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [ctx/services.xml]
Feb 24, 2016 9:21:13 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [ctx/views.xml]
Feb 24, 2016 9:21:13 AM org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
INFO: Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext#45283ce2]: org.springframework.beans.factory.support.DefaultListableBeanFactory#591f989e
Feb 24, 2016 9:21:13 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#591f989e: defining beans [serviceLocator,applicationServices,applicationEventMulticaster,application,windowCommandManager,lifecycleAdvisor,applicationDescriptor,messageSource,menuBar,userManagementMenu,fd1,fd2,userCommand,userGroupCommand,baseModel,user,userGroup,userFilter,userGroupFilter,abstractFilterForm,userFilterForm,userGroupFilterForm,abstractDataEditor,userDataEditor,userGroupDataEditor,abstractForm,userForm,userGroupForm,abstractDataProvider,userDataProvider,userGroupDataProvider,userService,userGroupService,userView,userGroupView]; root of factory hierarchy
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.support.DefaultApplicationServices$8 build
INFO: Creating default service impl: CommandConfigurer
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.support.DefaultApplicationServices$7 build
INFO: No object configurer bean Id has been set; configuring defaults.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.support.DefaultApplicationServices$4 build
INFO: Creating default service impl: CommandServices
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userCommand.foreground]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userCommand.background]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userCommand.caption]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userCommand.description]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.support.DefaultApplicationServices$10 build
INFO: Creating default service impl: IconSource
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.support.DefaultApplicationServices$9 build
INFO: Creating default service impl: ImageSource
Feb 24, 2016 9:21:13 AM org.springframework.core.io.support.PropertiesLoaderSupport loadProperties
INFO: Loading properties file from class path resource [org/springframework/richclient/image/images.properties]
Feb 24, 2016 9:21:13 AM org.springframework.richclient.image.DefaultIconSource getIcon
INFO: No image resource found for icon with key 'userCommand.icon'; returning a icon.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.image.DefaultIconSource getIcon
INFO: No image resource found for icon with key 'userCommand.large.icon'; returning a icon.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userCommand.foreground]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userCommand.background]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userCommand.caption]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userCommand.description]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.image.DefaultIconSource getIcon
INFO: No image resource found for icon with key 'userCommand.icon'; returning a icon.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.image.DefaultIconSource getIcon
INFO: No image resource found for icon with key 'userCommand.large.icon'; returning a icon.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userGroupCommand.foreground]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userGroupCommand.background]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userGroupCommand.caption]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userGroupCommand.description]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.image.DefaultIconSource getIcon
INFO: No image resource found for icon with key 'userGroupCommand.icon'; returning a icon.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.image.DefaultIconSource getIcon
INFO: No image resource found for icon with key 'userGroupCommand.large.icon'; returning a icon.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userGroupCommand.foreground]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userGroupCommand.background]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userGroupCommand.caption]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userGroupCommand.description]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.image.DefaultIconSource getIcon
INFO: No image resource found for icon with key 'userGroupCommand.icon'; returning a icon.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.image.DefaultIconSource getIcon
INFO: No image resource found for icon with key 'userGroupCommand.large.icon'; returning a icon.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userManagementMenu.foreground]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userManagementMenu.background]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.config.DefaultApplicationObjectConfigurer loadMessage
INFO: The message source is unable to find message code [userManagementMenu.description]. Ignoring and returning null.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.image.DefaultIconSource getIcon
INFO: No image resource found for icon with key 'userManagementMenu.icon'; returning a icon.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.image.DefaultIconSource getIcon
INFO: No image resource found for icon with key 'userManagementMenu.large.icon'; returning a icon.
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.ApplicationLauncher displaySplashScreen
INFO: No splash screen bean found to display. Continuing...
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.support.DefaultApplicationServices$25 build
INFO: Creating default service impl: ApplicationWindowFactory
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.support.DefaultApplicationWindowFactory createApplicationWindow
INFO: Creating new DefaultApplicationWindow
Feb 24, 2016 9:21:13 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.richclient.application.config.DefaultApplicationLifecycleAdvisor$CommandBarApplicationContext#21cf5ed5: display name [org.springframework.richclient.application.config.DefaultApplicationLifecycleAdvisor$CommandBarApplicationContext#21cf5ed5]; startup date [Wed Feb 24 09:21:13 PST 2016]; parent: org.springframework.context.support.ClassPathXmlApplicationContext#45283ce2
Feb 24, 2016 9:21:13 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [ctx/commands.xml]
Feb 24, 2016 9:21:13 AM org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
INFO: Bean factory for application context [org.springframework.richclient.application.config.DefaultApplicationLifecycleAdvisor$CommandBarApplicationContext#21cf5ed5]: org.springframework.beans.factory.support.DefaultListableBeanFactory#5853b97a
Feb 24, 2016 9:21:13 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#5853b97a: defining beans [menuBar,userManagementMenu,fd1,fd2,userCommand,userGroupCommand]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory#591f989e
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.support.DefaultApplicationServices$26 build
INFO: Creating default service impl: ApplicationPageFactory
Feb 24, 2016 9:21:13 AM org.springframework.richclient.application.support.DefaultApplicationPageFactory createApplicationPage
INFO: Creating new DefaultApplicationPage
Feb 24, 2016 9:21:13 AM org.springframework.richclient.core.LabeledObjectSupport getDisplayName
INFO: This labeled object's display name is not configured; returning 'displayName'
Feb 24, 2016 9:21:13 AM org.springframework.richclient.core.LabeledObjectSupport getDisplayName
INFO: This labeled object's display name is not configured; returning 'displayName'
Feb 24, 2016 9:21:14 AM org.springframework.richclient.application.support.DefaultApplicationServices$2 build
INFO: Creating default service impl: MenuFactory
Feb 24, 2016 9:21:14 AM org.springframework.richclient.application.support.DefaultApplicationServices$3 build
INFO: Creating default service impl: ButtonFactory
Feb 24, 2016 9:21:14 AM org.springframework.richclient.application.support.DefaultApplicationServices$5 build
INFO: Creating default service impl: ComponentFactory
Feb 24, 2016 9:21:14 AM org.springframework.richclient.application.support.DefaultApplicationServices$19 build
INFO: Creating default service impl: ViewDescriptorRegistry
Feb 24, 2016 9:21:14 AM org.springframework.richclient.application.support.DefaultApplicationServices$27 build
INFO: Creating default service impl: PageComponentPaneFactory
Feb 24, 2016 9:21:14 AM org.springframework.richclient.core.LabeledObjectSupport getDisplayName
INFO: This labeled object's display name is not configured; returning 'displayName'
Feb 24, 2016 9:33:19 AM org.springframework.context.support.AbstractApplicationContext doClose
INFO: Closing org.springframework.context.support.ClassPathXmlApplicationContext#45283ce2: display name [org.springframework.context.support.ClassPathXmlApplicationContext#45283ce2]; startup date [Wed Feb 24 09:21:13 PST 2016]; root of context hierarchy
Feb 24, 2016 9:33:19 AM org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons
INFO: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#591f989e: defining beans [serviceLocator,applicationServices,applicationEventMulticaster,application,windowCommandManager,lifecycleAdvisor,applicationDescriptor,messageSource,menuBar,userManagementMenu,fd1,fd2,userCommand,userGroupCommand,baseModel,user,userGroup,userFilter,userGroupFilter,abstractFilterForm,userFilterForm,userGroupFilterForm,abstractDataEditor,userDataEditor,userGroupDataEditor,abstractForm,userForm,userGroupForm,abstractDataProvider,userDataProvider,userGroupDataProvider,userService,userGroupService,userView,userGroupView]; root of factory hierarchy
The label and text box are displayed, but there is no tool bar. Any idea why? Thanking you in anticipation.
package com.mycom.form;
import com.mycom.model.User;
import org.springframework.richclient.form.builder.FormLayoutFormBuilder;
public class UserForm extends AbstractForm{
public UserForm(String formId, User user) throws Exception{
super(formId, user);
}
protected void addComponents(FormLayoutFormBuilder builder){
super.addComponents(builder);
builder.addPropertyAndLabel("dateOfBirth");
builder.nextRow();
builder.addPropertyAndLabel("userGroup");
}
}
AbstractForm code:
package com.mycom.form;
import javax.swing.JComponent;
import com.jgoodies.forms.layout.FormLayout;
import com.mycom.model.BaseModel;
import org.springframework.binding.form.FieldMetadata;
import org.springframework.richclient.form.FormModelHelper;
import org.springframework.richclient.form.TabbedForm;
import org.springframework.richclient.form.builder.FormLayoutFormBuilder;
public class AbstractForm extends TabbedForm{
private String tabName;
public AbstractForm(String formId, BaseModel baseModel) throws Exception{
super(FormModelHelper.createFormModel(baseModel, formId));
}
protected Tab[] getTabs(){
FormLayout layout = new FormLayout("default, 3dlu, fill:pref:nogrow", "default");
FormLayoutFormBuilder builder = new FormLayoutFormBuilder(getBindingFactory(), layout);
addComponents(builder);
return new Tab[] {new Tab(getTabName(), builder.getPanel())};
}
protected void addComponents(FormLayoutFormBuilder builder){
builder.addPropertyAndLabel("id");
builder.nextRow();
JComponent nameComponent = builder.addPropertyAndLabel("name")[1];
builder.nextRow();
FieldMetadata idMetaData = getFormModel().getFieldMetadata("id");
idMetaData.setReadOnly(true);
setFocusControl(nameComponent);
}
protected String getTabName(){
return tabName;
}
public void setTabName(String tabName) {
this.tabName = tabName;
}
}
Form beans:
<bean name="abstractForm" scope="prototype" abstract = "true">
<property name= "tabName" value="Detail" />
</bean>
<bean name="userForm" scope="prototype" class="com.mycom.form.UserForm">
<constructor-arg index = "0" value="userForm" />
<constructor-arg index = "1" ref="user" />
<property name= "tabName" value="User Detail" />
</bean>

web app startup warning:No MyBatis mapper was found in ... ,Please check your configuration

My configuration is:
spring-4.2.3
mybatis-3.3.0
mybatis-spring-1.2.3
mapper looks like:
package com.vsi.idp.map.server.mapper;
//imports...
public interface SeniorMapper extends BaseMapper<Long, Senior>
{
#Results({...})
#Select(...)
public List<Senior> query(...);
}
ServiceImpl looks like:
package com.vsi.idp.map.server;
//imports...
#Service("querySenior")
public class SeniorQueryServiceImpl extends RemoteServiceServlet implements SeniorQueryService
{
#Autowired
SeniorMapper mapper;
#Override
public List<Senior> query(Address address, String careType){...}
}
applicationContext.xml looks like:
<beans ... default-lazy-init="true">
<!-- MyBatis Mapper Interfaces -->
<mybatis:scan base-package="com.vsi.idp.map.server.mapper" />
//other configurations
</beans>
Spock unit test looks like below,and runs as expected
#ContextConfiguration(locations = "file:war/WEB-INF/applicationContext.xml")
public class SeniorQueryServiceImplTest extends Specification{
#Autowired
SeniorQueryServiceImpl service
def "query by full address"(){
//blabla
}
}
But when start web application,I got this warning:
WARNING: No MyBatis mapper was found in '[com.vsi.idp.map.server.mapper]' package. Please check your configuration.
So,how to solve this problem?
UPDATEit is a gwt web application,full error stack is:
INFO: Root WebApplicationContext: initialization started Nov 23, 2015 7:12:29 PM org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh
INFO: Refreshing Root WebApplicationContext: startup date [Mon Nov 23 19:12:29 CST 2015]; root of context hierarchy Nov 23, 2015 7:12:29 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml] Nov 23, 2015 7:12:29 PM org.mybatis.spring.mapper.ClassPathMapperScanner doScan
WARNING: No MyBatis mapper was found in '[com.vsi.idp.map.server.mapper]' package. Please check your configuration.Nov 23, 2015 7:12:30 PM org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor <init>
INFO: JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
Module setup completed in 1698 ms
Nov 23, 2015 7:12:30 PM org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Root WebApplicationContext: initialization completed in 1557 ms
#MapperScan(basePackages = "com.vsi.idp.map.server.mapper")
you can try add it!
Have you defined MapperScannerConfigurer in applicationContext.xml? If so, please delete it.
I have the following config in my applicationContext.xml, and when I deleted it, the warning has gone.
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.james.reg.mapper" />
<property name="sqlSessionFactory" ref="sqlSessionFactory" />
</bean>

WARNING: No mapping found for HTTP request with URI [/CustomerDetails/] in DispatcherServlet with name 'customerdispatcher' [duplicate]

This question already has answers here:
Why does Spring MVC respond with a 404 and report "No mapping found for HTTP request with URI [...] in DispatcherServlet"?
(13 answers)
Closed 6 years ago.
I had a issue in spring3 frameowrk.org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/CustomerDetails/] in DispatcherServlet with name 'customerdispatcher'
Please see the following
Jun 01, 2014 11:16:27 AM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files (x86)\PC Connectivity Solution\;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Sony\VAIO Improvement\;C:\Program Files (x86)\Sony\VAIO Startup Setting Tool;C:\Program Files\MySQL\MySQL Server 5.1\bin;;.
Jun 01, 2014 11:16:28 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:CustomerDetails' did not find a matching property.
Jun 01, 2014 11:16:28 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Jun 01, 2014 11:16:28 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Jun 01, 2014 11:16:28 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1635 ms
Jun 01, 2014 11:16:28 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jun 01, 2014 11:16:28 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.50
Jun 01, 2014 11:16:30 AM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(C:\Users\Smileanbu\Documents\Spring_JDBC\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\CustomerDetails\WEB-INF\lib\servlet-api.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class
Jun 01, 2014 11:16:33 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/core_rt is already defined
Jun 01, 2014 11:16:33 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/core is already defined
Jun 01, 2014 11:16:33 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/core is already defined
Jun 01, 2014 11:16:33 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt_rt is already defined
Jun 01, 2014 11:16:33 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt is already defined
Jun 01, 2014 11:16:33 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/fmt is already defined
Jun 01, 2014 11:16:33 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/functions is already defined
Jun 01, 2014 11:16:33 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/permittedTaglibs is already defined
Jun 01, 2014 11:16:33 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/scriptfree is already defined
Jun 01, 2014 11:16:33 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/sql_rt is already defined
Jun 01, 2014 11:16:33 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/sql is already defined
Jun 01, 2014 11:16:33 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/sql is already defined
Jun 01, 2014 11:16:33 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/xml_rt is already defined
Jun 01, 2014 11:16:33 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/xml is already defined
Jun 01, 2014 11:16:33 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/xml is already defined
Jun 01, 2014 11:16:33 AM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Jun 01, 2014 11:16:33 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'customerdispatcher'
Jun 01, 2014 11:16:33 AM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'customerdispatcher': initialization started
Jun 01, 2014 11:16:33 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing WebApplicationContext for namespace 'customerdispatcher-servlet': startup date [Sun Jun 01 11:16:33 IST 2014]; root of context hierarchy
Jun 01, 2014 11:16:34 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/customerdispatcher-servlet.xml]
Jun 01, 2014 11:16:34 AM org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider registerDefaultFilters
INFO: JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning
Jun 01, 2014 11:16:35 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#19705d39: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,viewResolver,dataSource,sessionFactory,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,transactionManager,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; root of factory hierarchy
300 [localhost-startStop-1] INFO org.hibernate.annotations.common.Version - Hibernate Commons Annotations 3.2.0.Final
312 [localhost-startStop-1] INFO org.hibernate.cfg.Environment - Hibernate 3.6.10.Final
315 [localhost-startStop-1] INFO org.hibernate.cfg.Environment - hibernate.properties not found
321 [localhost-startStop-1] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
327 [localhost-startStop-1] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
479 [localhost-startStop-1] INFO org.hibernate.cfg.Configuration - configuring from url: file:/C:/Users/Smileanbu/Documents/Spring_JDBC/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/CustomerDetails/WEB-INF/classes/hibernate.cfg.xml
538 [localhost-startStop-1] WARN org.hibernate.util.DTDEntityResolver - recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
594 [localhost-startStop-1] INFO org.hibernate.cfg.Configuration - Configured SessionFactory: null
688 [localhost-startStop-1] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: com.springforbeginners.model.Customer
778 [localhost-startStop-1] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity com.springforbeginners.model.Customer on table CUSTOMER
900 [localhost-startStop-1] INFO org.hibernate.cfg.Configuration - Hibernate Validator not found: ignoring
Jun 01, 2014 11:16:36 AM org.springframework.orm.hibernate3.LocalSessionFactoryBean buildSessionFactory
INFO: Building new Hibernate SessionFactory
919 [localhost-startStop-1] INFO org.hibernate.cfg.search.HibernateSearchEventListenerRegister - Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled.
929 [localhost-startStop-1] INFO org.hibernate.connection.ConnectionProviderFactory - Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider
1606 [localhost-startStop-1] INFO org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.MySQLDialect
1641 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Database ->
name : MySQL
version : 5.1.73-community
major : 5
minor : 1
1641 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Driver ->
name : MySQL-AB JDBC Driver
version : mysql-connector-java-5.1.14 ( Revision: ${bzr.revision-id} )
major : 5
minor : 1
1644 [localhost-startStop-1] INFO org.hibernate.transaction.TransactionFactoryFactory - Transaction strategy: org.springframework.orm.hibernate3.SpringTransactionFactory
1648 [localhost-startStop-1] INFO org.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
1648 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled
1648 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled
1649 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - JDBC batch size: 15
1649 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - JDBC batch updates for versioned data: disabled
1651 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Scrollable result sets: enabled
1651 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): enabled
1651 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Connection release mode: auto
1653 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Maximum outer join fetch depth: 2
1654 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1
1654 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled
1654 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled
1654 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Order SQL inserts for batching: disabled
1654 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
1661 [localhost-startStop-1] INFO org.hibernate.hql.ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
1661 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Query language substitutions: {}
1661 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - JPA-QL strict compliance: disabled
1663 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Second-level cache: enabled
1663 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Query cache: disabled
1663 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Cache region factory : org.hibernate.cache.impl.NoCachingRegionFactory
1681 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: disabled
1681 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Structured second-level cache entries: disabled
1699 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Echoing all SQL to stdout
1701 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Statistics: disabled
1702 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled
1702 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Default entity-mode: pojo
1702 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Named query checking : enabled
1702 [localhost-startStop-1] INFO org.hibernate.cfg.SettingsFactory - Check Nullability in Core (should be disabled when Bean Validation is on): enabled
1751 [localhost-startStop-1] INFO org.hibernate.impl.SessionFactoryImpl - building session factory
1788 [localhost-startStop-1] INFO org.hibernate.type.BasicTypeRegistry - Type registration [characters_clob] overrides previous : org.hibernate.type.PrimitiveCharacterArrayClobType#236f7565
1788 [localhost-startStop-1] INFO org.hibernate.type.BasicTypeRegistry - Type registration [clob] overrides previous : org.hibernate.type.ClobType#6a844c0f
1788 [localhost-startStop-1] INFO org.hibernate.type.BasicTypeRegistry - Type registration [java.sql.Clob] overrides previous : org.hibernate.type.ClobType#6a844c0f
1788 [localhost-startStop-1] INFO org.hibernate.type.BasicTypeRegistry - Type registration [wrapper_characters_clob] overrides previous : org.hibernate.type.CharacterArrayClobType#139da36b
1788 [localhost-startStop-1] INFO org.hibernate.type.BasicTypeRegistry - Type registration [materialized_clob] overrides previous : org.hibernate.type.MaterializedClobType#5253cfdc
1788 [localhost-startStop-1] INFO org.hibernate.type.BasicTypeRegistry - Type registration [materialized_blob] overrides previous : org.hibernate.type.MaterializedBlobType#7c739ebd
1788 [localhost-startStop-1] INFO org.hibernate.type.BasicTypeRegistry - Type registration [wrapper_materialized_blob] overrides previous : org.hibernate.type.WrappedMaterializedBlobType#abaca20
1789 [localhost-startStop-1] INFO org.hibernate.type.BasicTypeRegistry - Type registration [blob] overrides previous : org.hibernate.type.BlobType#6d2c0060
1789 [localhost-startStop-1] INFO org.hibernate.type.BasicTypeRegistry - Type registration [java.sql.Blob] overrides previous : org.hibernate.type.BlobType#6d2c0060
2313 [localhost-startStop-1] INFO org.hibernate.impl.SessionFactoryObjectFactory - Not binding factory to JNDI, no JNDI name configured
Jun 01, 2014 11:16:38 AM org.springframework.orm.hibernate3.HibernateTransactionManager afterPropertiesSet
INFO: Using DataSource [org.apache.commons.dbcp.BasicDataSource#1c53ccd6] of Hibernate SessionFactory for HibernateTransactionManager
Jun 01, 2014 11:16:38 AM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'customerdispatcher': initialization completed in 4758 ms
Jun 01, 2014 11:16:38 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Jun 01, 2014 11:16:38 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Jun 01, 2014 11:16:38 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 10104 ms
Jun 01, 2014 11:16:40 AM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/CustomerDetails/] in DispatcherServlet with name 'customerdispatcher'
customerdispatcher-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">
<context:annotation-config />
<context:component-scan base-package="com.springforbeginners.controller.CustomerController" />
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
<bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/customerdb"/>
<property name="username" value="root"/>
<property name="password" value="123456"/>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
<property name="configurationClass">
<value>org.hibernate.cfg.AnnotationConfiguration</value>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<tx:annotation-driven />
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
</beans>
Web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<servlet>
<servlet-name>customerdispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>customerdispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/index</welcome-file>
</welcome-file-list>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
</web-app>
CustomerController class
package com.springforbeginners.controller;
import com.springforbeginners.model.Customer;
import com.springforbeginners.service.CustomerService;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
#Controller
public class CustomerController {
#Autowired
private CustomerService customerService;
#RequestMapping("/index")
public String listCustomers(Map<String, Object> map) {
map.put("customer", new Customer());
map.put("customerList", customerService.listCustomer());
return "customer";
}
#RequestMapping(value = "/add", method = RequestMethod.POST)
public String addCustomer(#ModelAttribute("customer") Customer customer, BindingResult result) {
customerService.addCustomer(customer);
return "redirect:/index";
}
#RequestMapping("/delete/{customerId}")
public String deleteCustomer(#PathVariable("customerId") Integer customerId) {
customerService.removeCustomer(customerId);
return "redirect:/index";
}
}
I am not able to get my customer.jsp page it is present in my WEB_INF/jsp/customer.jsp.Please help me from this error No matching Http request for URL
WARNING: No mapping found for HTTP request with URI [/CustomerDetails/] in DispatcherServlet with name 'customerdispatcher'
In your controller or your web.xml, there's nothing that maps yor URI to CustomerDetails. You should either change
<url-pattern>/</url-pattern> to <url-pattern>/CustomerDetails</url-pattern>
or add this in your controller
#Controller
#RequestMapping(value = "CustomerDetails")
public class CustomerController {
...
}
And then you can call the url by:
Context/CustomerDetails/index
And by the way, in your <welcome-file-list>, if you are trying to call the servlet on initializing, it won't work, the <welcome-file> has to be a "file".

Failed to Load ApplicationContext during Spring unit test

I am trying to run a Junit functional test using Springs java-config for my application context. I am not sure if it is a problem with Spring or Junit... just not sure.. The application runs fine on my local server (hitting the db), but when I try to run my test it bombs out.
I just moved from xml to java config so I can always import my xml context files (which I know works in my tests) but going forward I would rather just use my java config.
My Test Class
#RunWith(SpringJUnit4ClassRunner.class)
#ContextConfiguration(loader = AnnotationConfigContextLoader.class,
classes = { AppConfig.class, ServletConfig.class })
#EnvironmentConfiguration(db2Enabled = true)
public class EventDAOTest {
The StackTrace
Feb 4, 2014 11:51:45 AM com.aoins.config.CachingPropertyFileReader <clinit>
SEVERE: ERROR - Configuration Framework not detected!
Feb 4, 2014 11:51:45 AM com.aoins.config.CachingPropertyFileReader readFile
SEVERE: Unable to build property reference for: (common).
2014-02-04 11:51:45,510 | DEBUG | : | LoggerConfigurer | Msg: Log4j configured with: 'C:/javalog/log4jPCProperties.xml'
2014-02-04 11:51:48,248 | INFO | : | EnvironmentConfigurer | Msg: DB2 Connection was established
2014-02-04 11:51:48,279 | INFO | : | EnvironmentConfigurer | Msg: CICS Connection was established
2014-02-04 11:51:48,279 | INFO | : | EnvironmentConfigurer | Msg: JMS Connection was NOT established according to the configuration
2014-02-04 11:51:48,279 | INFO | : | EnvironmentConfigurer | Msg: EMail Connection was NOT established according to the configuration
Feb 4, 2014 11:51:48 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.GenericApplicationContext#215d215d: startup date [Tue Feb 04 11:51:48 EST 2014]; root of context hierarchy
Feb 4, 2014 11:51:49 AM org.springframework.web.servlet.handler.AbstractHandlerMethodMapping registerHandlerMethod
INFO: Mapped "{[/Data/associates],methods=[GET],params=[],headers=[],consumes=[],produces=[application/json],custom=[]}" onto public org.springframework.ui.ModelMap com.aoins.sales.eventplanning.associate.AssociateDataController.retrieveAssociates(java.lang.String)
Feb 4, 2014 11:51:49 AM org.springframework.web.servlet.handler.AbstractHandlerMethodMapping registerHandlerMethod
INFO: Mapped "{[/Data/associateFilterTypes],methods=[GET],params=[],headers=[],consumes=[],produces=[application/json],custom=[]}" onto public org.springframework.ui.ModelMap com.aoins.sales.eventplanning.associatefiltertype.AssociateFilterDataController.retrieveEventFilterTypes()
Feb 4, 2014 11:51:49 AM org.springframework.web.servlet.handler.AbstractHandlerMethodMapping registerHandlerMethod
INFO: Mapped "{[/Data/associateFilterTypes/{pTypeCode}],methods=[GET],params=[],headers=[],consumes=[],produces=[application/json],custom=[]}" onto public org.springframework.ui.ModelMap com.aoins.sales.eventplanning.associatefiltertype.AssociateFilterDataController.retrieveEventFilterType(java.lang.String) throws com.aoins.sales.eventplanning.associatefiltertype.AssociateFilterTypeNotFoundException
Feb 4, 2014 11:51:49 AM org.springframework.web.servlet.handler.AbstractHandlerMethodMapping registerHandlerMethod
INFO: Mapped "{[/Data/dateFilterTypes],methods=[GET],params=[],headers=[],consumes=[],produces=[application/json],custom=[]}" onto public org.springframework.ui.ModelMap com.aoins.sales.eventplanning.datefiltertype.DateFilterDataController.retrieveEventFilterTypes()
Feb 4, 2014 11:51:49 AM org.springframework.web.servlet.handler.AbstractHandlerMethodMapping registerHandlerMethod
INFO: Mapped "{[/Data/dateFilterTypes/{pTypeCode}],methods=[GET],params=[],headers=[],consumes=[],produces=[application/json],custom=[]}" onto public org.springframework.ui.ModelMap com.aoins.sales.eventplanning.datefiltertype.DateFilterDataController.retrieveEventFilterType(java.lang.String) throws com.aoins.sales.eventplanning.datefiltertype.DateFilterTypeNotFoundException
Feb 4, 2014 11:51:49 AM org.springframework.web.servlet.handler.AbstractHandlerMethodMapping registerHandlerMethod
INFO: Mapped "{[/Data/departments/{pDepartmentCode}],methods=[GET],params=[],headers=[],consumes=[],produces=[application/json],custom=[]}" onto public org.springframework.ui.ModelMap com.aoins.sales.eventplanning.department.DepartmentDataController.retrieveDepartment(java.lang.String) throws com.aoins.sales.eventplanning.department.DepartmentNotFoundException
Feb 4, 2014 11:51:49 AM org.springframework.web.servlet.handler.AbstractHandlerMethodMapping registerHandlerMethod
INFO: Mapped "{[/Data/divisions],methods=[GET],params=[],headers=[],consumes=[],produces=[application/json],custom=[]}" onto public org.springframework.ui.ModelMap com.aoins.sales.eventplanning.division.DivisionDataController.retrieveDivisionsDepartments()
Feb 4, 2014 11:51:49 AM org.springframework.web.servlet.handler.AbstractHandlerMethodMapping registerHandlerMethod
INFO: Mapped "{[/],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.aoins.sales.eventplanning.events.EventController.showEvents()
Feb 4, 2014 11:51:49 AM org.springframework.web.servlet.handler.AbstractHandlerMethodMapping registerHandlerMethod
INFO: Mapped "{[//Test],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.aoins.sales.eventplanning.events.EventController.showTests()
Feb 4, 2014 11:51:49 AM org.springframework.web.servlet.handler.AbstractHandlerMethodMapping registerHandlerMethod
INFO: Mapped "{[/Data/events/{pEventId}],methods=[GET],params=[],headers=[],consumes=[],produces=[application/json],custom=[]}" onto public org.springframework.ui.ModelMap com.aoins.sales.eventplanning.events.EventDataController.retrieveEvent(java.lang.Integer)
Feb 4, 2014 11:51:49 AM org.springframework.web.servlet.handler.AbstractHandlerMethodMapping registerHandlerMethod
INFO: Mapped "{[/Data/events],methods=[GET],params=[page && associateFilter && dateFilter],headers=[],consumes=[],produces=[application/json],custom=[]}" onto public org.springframework.ui.ModelMap com.aoins.sales.eventplanning.events.EventDataController.retrieveFiltered(com.aoins.sales.eventplanning.associatefiltertype.AssociateFilterType,com.aoins.sales.eventplanning.datefiltertype.DateFilterType,java.lang.Integer,com.aoins.sales.user.User)
Feb 4, 2014 11:51:49 AM org.springframework.web.servlet.handler.AbstractHandlerMethodMapping registerHandlerMethod
INFO: Mapped "{[/Data/events],methods=[POST],params=[],headers=[],consumes=[application/json],produces=[application/json],custom=[]}" onto public org.springframework.ui.ModelMap com.aoins.sales.eventplanning.events.EventDataController.saveEvent(com.aoins.sales.eventplanning.events.EventBeanImpl,com.aoins.sales.user.User) throws com.aoins.sales.eventplanning.events.EventException
Feb 4, 2014 11:51:49 AM org.springframework.web.servlet.handler.AbstractHandlerMethodMapping registerHandlerMethod
INFO: Mapped "{[/Data/Public/events],methods=[GET],params=[],headers=[],consumes=[],produces=[application/json],custom=[]}" onto public java.util.List<com.aoins.sales.eventplanning.events.Event> com.aoins.sales.eventplanning.events.EventDataPublicController.doList()
Feb 4, 2014 11:51:49 AM org.springframework.web.servlet.handler.AbstractHandlerMethodMapping registerHandlerMethod
INFO: Mapped "{[/Data/Public/events/{pEventId}],methods=[GET],params=[],headers=[],consumes=[],produces=[application/json],custom=[]}" onto public com.aoins.sales.eventplanning.events.Event com.aoins.sales.eventplanning.events.EventDataPublicController.doRetrieve(java.lang.Integer)
Feb 4, 2014 11:51:49 AM org.springframework.web.servlet.handler.AbstractHandlerMethodMapping registerHandlerMethod
INFO: Mapped "{[/Data/eventTypes],methods=[GET],params=[],headers=[],consumes=[],produces=[application/json],custom=[]}" onto public org.springframework.ui.ModelMap com.aoins.sales.eventplanning.eventtype.EventTypeDataController.retrieveEventTypes()
Feb 4, 2014 11:51:49 AM org.springframework.web.servlet.handler.AbstractHandlerMethodMapping registerHandlerMethod
INFO: Mapped "{[/Data/eventTypes/{pTypeCode}],methods=[GET],params=[],headers=[],consumes=[],produces=[application/json],custom=[]}" onto public org.springframework.ui.ModelMap com.aoins.sales.eventplanning.eventtype.EventTypeDataController.retrieveEventType(java.lang.String) throws com.aoins.sales.eventplanning.eventtype.EventTypeNotFoundException
Feb 4, 2014 11:51:49 AM org.springframework.test.context.TestContextManager prepareTestInstance
SEVERE: Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener#20c820c8] to prepare test instance [com.aoins.sales.eventplanning.events.EventDAOTest#f7e0f7e]
Throwable occurred: java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext(CacheAwareContextLoaderDelegate.java:99)
at org.springframework.test.context.DefaultTestContext.getApplicationContext(DefaultTestContext.java:101)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:326)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:212)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:232)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:89)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:175)
at com.aoins.func.tester.AOSpringFunctionalTester.run(AOSpringFunctionalTester.java:48)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultServletHandlerMapping' defined in class path resource [org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfiguration.class]: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.web.servlet.HandlerMapping org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport.defaultServletHandlerMapping()] threw exception; nested exception is java.lang.IllegalArgumentException: A ServletContext is required to configure default servlet handling
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:592)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1094)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:989)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:700)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:121)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:60)
at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContextInternal(CacheAwareContextLoaderDelegate.java:64)
at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext(CacheAwareContextLoaderDelegate.java:91)
... 26 more
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.web.servlet.HandlerMapping org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport.defaultServletHandlerMapping()] threw exception; nested exception is java.lang.IllegalArgumentException: A ServletContext is required to configure default servlet handling
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:188)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:581)
... 41 more
Caused by: java.lang.IllegalArgumentException: A ServletContext is required to configure default servlet handling
at java.lang.Throwable.<init>(Throwable.java:67)
at org.springframework.util.Assert.notNull(Assert.java:111)
at org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer.<init>(DefaultServletHandlerConfigurer.java:54)
at org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport.defaultServletHandlerMapping(WebMvcConfigurationSupport.java:330)
at org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration$$EnhancerByCGLIB$$104f0b6f.CGLIB$defaultServletHandlerMapping$22(<generated>)
at org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration$$EnhancerByCGLIB$$104f0b6f$$FastClassByCGLIB$$ff8cbba8.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:326)
at org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration$$EnhancerByCGLIB$$104f0b6f.defaultServletHandlerMapping(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:166)
... 42 more
So it appears that it is not finding the configuration framework, but I have been following the reference guides and API... not sure what I am missing or not configuring correctly. I am using Spring 4.0, Junit 4.10
Also, for each test it throws this error. That to me means it is trying to load the ApplicationContext again (prepareRefresh)... once for each #Test -- that also doesn't make sense to me...
Here are some resources:
ContextConfiguration API
Spring Reference Guide
Spring blog post
I moved from spring 3.2.0 to 4.0.3 and had to update my javax.servlet dependency (in maven) from servlet 2.5 to servlet 3.0.1. The final dependency was
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
</dependency>
Then it worked
You'll need to annotate your test class with
#WebAppConfiguration
so that the test environment provides your WebApplicationContext with a mock ServletContext required by your MVC configuration.
Since a couple people mentioned Servlet version issues:
As of Spring 4.0 the set of mocks is now based on the Servlet 3.0 API.
You have two options:
use 3.2.x spring-test dependency
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>3.2.14.RELEASE</version>
<scope>test</scope>
</dependency>
upgrade to servlet 3.0
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
</dependency>
In gradle
testCompile 'javax.servlet:javax.servlet-api:3.1.0'
Note: this works for me even though I'm testing against Google App Engine (servlet 2.4) Because it is only used for tests.
https://jira.spring.io/browse/SPR-11049
the way to solve such problems -
try to force import of the notFoundClass manually, by smth like:
Class c = javax.servlet.SessionCookieConfig.class;
so Idea+Maven suggested me to add maven dependency, i agreed. And suddenly in pom.xml the code appeared:
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-servlet_3.0_spec</artifactId>
<version>1.0</version>
<scope>test</scope>
</dependency>
then i removed "Class c = javax.servlet.SessionCookieConfig.class;" - there is no need in it, rather than to load necessary dependency.
You can add a MockServletContext to your test applicationContext.
The MockServletContext can be found in spring-test.jar (or maven dependency). You should (obviously) not use this in production, but only register it in a context that you include in your test context.
Use #ActiveProfiles({"{test", "default"}) annotation

Resources