I am trying to set up Testcontainers to perform integration tests for a project that uses Spring 5.3 and Oracle 12C, but I am getting the error "ORA-28040: No matching authentication protocol" every time I try to run a test.
The production database is accessed using NamedParameterJdbcTemplate, configured like this:
<tx:annotation-driven proxy-target-class="true"
transaction-manager="transactionManager" />
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="${connectionDataSource}" />
</bean>
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
<bean class="org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate" id="namedParameterJdbcTemplate">
<constructor-arg ref="dataSource"/>
</bean>
connectionDataSource is just a property with the value jdbc/myproject, which points to a conecction configured in the application server (Bea Weblogic 12.2).
I am trying to configure the test datasource in a separated file test-applicationContext-resources.xml like this:
<tx:annotation-driven proxy-target-class="true"
transaction-manager="transactionManager" />
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="org.testcontainers.jdbc.ContainerDatabaseDriver"/>
<property name="url" value="jdbc:tc:oracle:21-slim-faststart:///myproject?TC_INITSCRIPT=/myproject.sql"/>
<property name="username" value="myproject"/>
<property name="password" value="myproject"/>
</bean>
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
<bean class="org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate" id="namedParameterJdbcTemplate">
<constructor-arg ref="dataSource"/>
</bean>
And then I try to execute this test class:
@ExtendWith(SpringExtension.class)
@ContextConfiguration(locations = {"classpath:test-applicationContext-resources.xml"})
@WebAppConfiguration
@Testcontainers
class MyProjectTest {
@Autowired
MyProjectDAO myProjectDAO;
@Test
void test() {
int userNumber = myProjectDAO.countUsers();
assertEquals(1, userNumber);
}
}
but I am getting the mentioned error.
I tried removing username and password properties from the configuration, and also the driverClassName property, but did not change a thing.
The JDBC driver that I am using in production is:
testRuntime group: 'com.oracle', name: 'ojdbc', version: '6'
not sure if this could be the cause.
Doing some searches it looks like people having this problem could solve it setting SQLNET.ALLOWED_LOGON_VERSION=8 but I am not sure how to do that with a Testcontainers image.
@ibre5041 is right. I solved it just by changing the ojdbc to version 8:
testRuntime group: 'com.oracle.database.jdbc', name: 'ojdbc8', version: '23.3.0.23.09'