Cleon Greyjoy
Cleon Greyjoy

Reputation: 61

CrafterCMS: No suitable ClassLoader found for grab

I cloned a new site that was created in an older version (3.0.x) but there are errors in instantiating a bean from a constructor.

I am not able to view or build the application context because of the error. enter image description here

Heres's the runtime exception:

Caused by: java.lang.RuntimeException: No suitable ClassLoader found for grab

Snippet of the jdbc class:

@Grab(group='org.springframework', module = 'spring-jdbc', version = '4.1.9.RELEASE')
@Grab(group='commons-dbcp', module='commons-dbcp', version='1.2.2')
@Grab(group='com.sap.cloud.db.jdbc', module='ngdbc', version='2.2.16')

import org.apache.commons.dbcp.BasicDataSource
import org.springframework.jdbc.core.JdbcTemplate

class SAPJdbcTemplate extends JdbcTemplate {

    def SAPJdbcTemplate(BasicDataSource rq1DataSource, global) {
        super()
        rq1DataSource.setDriverClassName(global.getProperty("studio.db.driverClassName"))
        rq1DataSource.setUrl(global.getProperty("studio.db.url"))
        rq1DataSource.setUsername(global.getProperty("studio.db.username"))
        rq1DataSource.setPassword(global.getProperty("studio.db.password"))
        this.setDataSource(rq1DataSource)
    }
}

Bean from application-context.xml

<bean id="SAPJdbcTemplate" class="com.troo.services.SAPJdbcTemplate">
    <constructor-arg index="0" ref="rq1DataSource"/>
    <constructor-arg index="1" ref="crafter.propertyResolver"/>
</bean>

Upvotes: 0

Views: 91

Answers (1)

sumerz
sumerz

Reputation: 1446

Please review this article

https://docs.craftercms.org/en/3.1/developers/projects/engine/api/script-sandbox-configuration.html#adding-dependencies-with-grapes

Crafter CMS has a Groovy security sandbox that you need to consider.

Upvotes: 1

Related Questions