Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class Not Found Exception #1695

Closed
Daniil-Ivanov1 opened this issue Jun 4, 2024 · 7 comments
Closed

Class Not Found Exception #1695

Daniil-Ivanov1 opened this issue Jun 4, 2024 · 7 comments

Comments

@Daniil-Ivanov1
Copy link

Daniil-Ivanov1 commented Jun 4, 2024

Hello everyone When trying to run SpringBootTest, it crashes with an error that it cannot find the @Autowired fields, although everything works in IDEA . The project structure looks like this:

public interface TestData {

void setUser();
void setScenario();

}

@SpringBootTest(classes = {AbstractTestConfiguration.BaseConfiguration.class})
@slf4j
@embeddedkafka
public abstract class AbstractTestConfiguration implements TestData {

@BeforeAll
public static void startPostgres() {
...
}

@Autowired
protected SomeField someFIeld;

@Autowired
private SomeJpaRespository someJpaRepostitory;

@test
public void testContextStarted() {
...
}

}

public class SomeTestClass extends AbstractTestConfigiuration {

implements setters from interface

}

NoClassDefFoundError: SomeJpaRespositore

Using:
Mac OS Sonome 14.4.1
Temurin JDK 17
Red Hat Language Support v1.31.0
Test Runner For Java v0.41.1
maven 3.9.5

@jdneo
Copy link
Member

jdneo commented Jun 4, 2024

Could you share a sample project for this issue?

@Daniil-Ivanov1
Copy link
Author

@jdneo This code belongs to my company. I can implement the approximate logic and send it to you

@Daniil-Ivanov1
Copy link
Author

Daniil-Ivanov1 commented Jun 4, 2024

@jdneo
Copy link
Member

jdneo commented Jun 5, 2024

I run mvn clean test at the root, but failed

image

Is the packaging type of the module model meant to be pom?

@Daniil-Ivanov1
Copy link
Author

Daniil-Ivanov1 commented Jun 5, 2024

@jdneo Hi! I found a legitimate problem! In our project in pom.xml dependencies have a "classifier" set Which is why the test does not find classes

@jdneo
Copy link
Member

jdneo commented Jun 5, 2024

I see. classifier is not well supported now.

See: #775 & redhat-developer/vscode-java#1031

@jdneo jdneo closed this as not planned Won't fix, can't repro, duplicate, stale Jun 5, 2024
@Daniil-Ivanov1
Copy link
Author

@jdneo Hi! I found a workaround. I think it's worth publishing this.
It is necessary to duplicate dependencies. If one has the classifier tag, then add the same dependency next to it without the tag

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants