I am getting an error on startup with configuring the location of the mapper XML files OR the contents of the MapperConfig.xml itself. Not sure which is the issue.
The error message is below:
06-Sep-2024 16:01:21.184 SEVERE [main] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class [org.springframework.web.context.ContextLoaderListener]
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'AuthService': Unsatisfied dependency expressed through field 'personMapper': Error creating bean with name 'personMapper' defined in file [C:Program FilesApache Software FoundationTomcat 10.1webappscodereaperWEB-INFclassescomempirestateidsdaoPersonMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory': Error creating bean with name 'sqlSessionFactory' defined in class path resource [atlas-dao-context.xml]: Failed to parse config resource: class path resource [MapperConfig.xml]
Here are the beans that I am creating in my XML config. It successfuly configures the JNDi resource and fails on the sqkSessionFactory bean
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/CodereaperDB"/>
</bean>
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mapperLocations" value="classpath:/mapper/*.xml" />
<property name="configLocation" value="classpath:MapperConfig.xml" />
</bean>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
<bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg index="0" ref="sqlSessionFactory" />
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.empirestateids.dao" />
</bean>
here is the content of the MapperConfig.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd" >
<configuration >
<mappers >
<mapper resource="mapper/UsersMapper.xml" />
<mapper resource="mapper/GroupMemberMapper.xml" />
<mapper resource="mapper/PhoneMapper.xml" />
<mapper resource="mapper/PersonMapper.xml" />
<mapper resource="mapper/RegistrationMapper.xml" />
<mapper resource="mapper/AddressMapper.xml" />
<mapper resource="mapper/LookupMapper.xml" />
<mapper resource="mapper/LoincMapper.xml" />
<mapper resource="mapper/ContactMapper.xml" />
<mapper resource="mapper/PersonMapper.xml" />
<mapper resource="mapper/EmailMapper.xml" />
<mapper resource="mapper/GroupAuthorityMapper.xml" />
<mapper resource="mapper/GroupsMapper.xml" />
<mapper resource="mapper/PersistentLoginsMapper.xml" />
<mapper resource="mapper/UsersMapper.xml" />
<mapper resource="mapper/IpowerliftIdMapper.xml" />
<mapper resource="mapper/ProductListMapper.xml" />
<mapper resource="mapper/PaypalEnvMapper.xml" />
<mapper resource="mapper/LoincMapper.xml" />
<mapper resource="mapper/CvxCatalogsMapper.xml" />
<mapper resource="mapper/CvxCataAttributesMapper.xml" />
<mapper resource="mapper/CvxParentMapper.xml" />
<mapper resource="mapper/GroupMemberMapper.xml" />
<mapper resource="mapper/Icd10Mapper.xml" />
<mapper resource="mapper/Icd11Mapper.xml" />
<mapper resource="mapper/RxNormCodesMapper.xml" />
<mapper resource="mapper/SnomedEntityMapper.xml" />
</mappers>
</configuration>
The XML mappers are in the classpath under the mapper directory
Contents of war file
4