Why am I getting a NoClassDefFoundError when deploying on railway?

45 Views Asked by At

I am deploying a spring boot REST API to railway but it is returning me this at the moment of the deploy:

Error: Unable to initialize main class com.group6.server.ServerApplication
Caused by: java.lang.NoClassDefFoundError: org/springframework/security/crypto/password/PasswordEncoder

I am working with Gradle and this is my build.gradle:

plugins {
    id 'java'
    id 'org.springframework.boot' version '3.1.0'
    id 'io.spring.dependency-management' version '1.1.0'
}

group = 'com.group6'
version = '0.0.1'
sourceCompatibility = '17'

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-validation'
    implementation 'org.springframework.boot:spring-boot-starter-web'

    implementation 'org.springframework.boot:spring-boot-starter-security'
    implementation 'org.springframework.security:spring-security-crypto'

    implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
    implementation 'io.jsonwebtoken:jjwt-impl:0.11.5'
    implementation 'io.jsonwebtoken:jjwt-jackson:0.11.5'

    compileOnly 'org.projectlombok:lombok'
    runtimeOnly 'org.postgresql:postgresql'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

jar {
    manifest {
        attributes 'Main-Class': 'com.group6.server.ServerApplication'
    }
}

tasks.named('test') {
    useJUnitPlatform()
}

And I am using PasswordEncoder inside my main file named ServerApplication, in eclipse and IntelliJ it works fine but at the moment I am deploying that error is returned in console.

0

There are 0 best solutions below