started getting Class Not Found Exception randomly

hey guys. when i start my spring boot app i get this error: java.lang.ClassNotFoundException: lt.mycompany.myapp.service.XmlParserUtil. The thing is that XmlParserUtil was used just fine in this app. Now im adding new functionality, and for some reason i cant even start my app. XmlParserUtil looks like this:
@Service
public class XmlParserUtil {
private StatementDocumentWrapper convertToV053s02(InputStream is) throws JAXBException {
JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
Document doc = ((JAXBElement<Document>) jaxbUnmarshaller.unmarshal(is)).getValue();
StatementDocumentWrapper sDoc = new StatementV053S02DocumentWrapper(doc);
return sDoc;
}
private StatementDocumentWrapper convertToV052s02(InputStream is) throws JAXBException {
JAXBContext jaxbContext = JAXBContext.newInstance(lt.mycompany.iso20022.camt.v052s02.ObjectFactory.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
lt.mycompany.iso20022.camt.v052s02.Document doc = ((JAXBElement<lt.mycompany.iso20022.camt.v052s02.Document>) jaxbUnmarshaller.unmarshal(is)).getValue();
StatementDocumentWrapper sDoc = new StatementV052S02DocumentWrapper(doc);
return sDoc;
}
public StatementDocumentWrapper InputStreamToDocument(InputStream is) throws JAXBException, IOException {
byte[] bytes = is.readAllBytes();
StatementDocumentWrapper sd;
try {
sd = convertToV053s02(new ByteArrayInputStream(bytes));
} catch (UnmarshalException e) {
sd = convertToV052s02(new ByteArrayInputStream(bytes));
}
return sd;
}
}
@Service
public class XmlParserUtil {
private StatementDocumentWrapper convertToV053s02(InputStream is) throws JAXBException {
JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
Document doc = ((JAXBElement<Document>) jaxbUnmarshaller.unmarshal(is)).getValue();
StatementDocumentWrapper sDoc = new StatementV053S02DocumentWrapper(doc);
return sDoc;
}
private StatementDocumentWrapper convertToV052s02(InputStream is) throws JAXBException {
JAXBContext jaxbContext = JAXBContext.newInstance(lt.mycompany.iso20022.camt.v052s02.ObjectFactory.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
lt.mycompany.iso20022.camt.v052s02.Document doc = ((JAXBElement<lt.mycompany.iso20022.camt.v052s02.Document>) jaxbUnmarshaller.unmarshal(is)).getValue();
StatementDocumentWrapper sDoc = new StatementV052S02DocumentWrapper(doc);
return sDoc;
}
public StatementDocumentWrapper InputStreamToDocument(InputStream is) throws JAXBException, IOException {
byte[] bytes = is.readAllBytes();
StatementDocumentWrapper sd;
try {
sd = convertToV053s02(new ByteArrayInputStream(bytes));
} catch (UnmarshalException e) {
sd = convertToV052s02(new ByteArrayInputStream(bytes));
}
return sd;
}
}
can smb help me out? thanks in advance
13 Replies
JavaBot
JavaBot9mo ago
This post has been reserved for your question.
Hey @bambyzas! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
dan1st
dan1st9mo ago
Can you show the pom.xml and the complete stack trace?
i hate SQL so much its unreal
i use gradle 😦
dan1st
dan1st9mo ago
Can you show the build.gradle and the complete stack trace?
dan1st
dan1st9mo ago
as well as how you are running it
i hate SQL so much its unreal
Pastebin
plugins { id 'org.springframework.boot' version '2.2.6.RELEASE' ...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
i hate SQL so much its unreal
this is my build.gradle im just running it in my ide any ideas?
imp_o_rt
imp_o_rt9mo ago
if running in ide and it's intellij sometimes this happens, try file -> invalidate caches... -> invalidate and restart .
i hate SQL so much its unreal
thanks. im doing it right now. i was also thinking would doing smth with gradle help? idk, maybe refreshing gradle project or smth? nope, still the same 😦
Tomasm21
Tomasm219mo ago
Given the context of the error and the line at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49), it is likely that the Spring Boot DevTools is causing the issue. Try disabling Spring Boot DevTools. In your build.gradle comment out the devtools dependency: implementation 'org.springframework.boot:spring-boot-devtools' If you want to use DevTools then just exclude this package: spring.devtools.restart.exclude=lt/mycompany/paymentimport/service/**. Sometimes, cleaning and rebuilding the project can resolve issues related to outdated or corrupt class files. gradle clean build
dan1st
dan1st9mo ago
Alternatively it could theoretically be some verifier issue (some dependency class being missing and verification not completing because of that). You could try to check this by adding -Xverify:none to the JVM args but only do that for testing and remove it afterwards
JavaBot
JavaBot9mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.

Did you find this page helpful?