question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Run with exception

See original GitHub issue

I use gradle thinResolve build OK and run with java -Dthin.root=. -jar sample.jar

Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.springframework.boot.loader.wrapper.ThinJarWrapper.launch(ThinJarWrapper.java:140)
        at org.springframework.boot.loader.wrapper.ThinJarWrapper.main(ThinJarWrapper.java:107)
Caused by: java.lang.NoClassDefFoundError: javax/servlet/MultipartConfigElement
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
        at java.lang.Class.getDeclaredMethod(Class.java:2128)
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:47)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
        at org.springframework.boot.loader.thin.ThinJarLauncher.launch(ThinJarLauncher.java:193)
        at org.springframework.boot.loader.thin.ThinJarLauncher.main(ThinJarLauncher.java:140)
        ... 6 more
Caused by: java.lang.ClassNotFoundException: javax.servlet.MultipartConfigElement
        at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:94)
        at org.springframework.boot.loader.thin.ThinJarLauncher$ThinJarClassLoader.loadClass(ThinJarLauncher.java:459)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 14 more

my build.gradle is

buildscript {
	ext {
		springBootVersion = '2.0.0.RELEASE'
		wrapperVersion = '1.0.17.RELEASE'
	}
	repositories {
        mavenCentral()
	}
	dependencies {
		classpath("org.springframework.boot.experimental:spring-boot-thin-gradle-plugin:${wrapperVersion}")
		classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
	}
}

apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'org.springframework.boot'
apply plugin: "io.spring.dependency-management"
apply plugin: 'org.springframework.boot.experimental.thin-launcher'

group = 'com.dcmd.service.demand'
version = '1.0.0-SNAPSHOT'

sourceCompatibility = 1.8
targetCompatibility = 1.8
tasks.withType(JavaCompile) {
	options.encoding = 'UTF-8'
}

thinResolvePrepare {
	into new File("${buildDir}/thin/deploy")
}

repositories {
             mavenCentral()
}

configurations { compile.exclude module: 'spring-boot-starter-tomcat' }

dependencyManagement {
    imports {
        mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Finchley.RELEASE'
    }
}

dependencies {
    compile group: 'com.company.common.core', name: 'company-common', version:'1.0.0-SNAPSHOT', changing: true
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
dsyercommented, Nov 26, 2018

I don’t know. What is a “gradle cache”? Is that related to #50? For the best results you need to use the maven local cache I think so that you actually generate a pom.xml, but if you are a gradle expert you might know a better way. Please open another issue if you have any ideas (PR more than welcome).

0reactions
rickywucommented, Nov 26, 2018

I found the problem is my build.gradle removed this line: apply plugin: ‘io.spring.dependency-management’ that caused thinResolve task not download dependencies

Another problem is thinResolve not use gradle caches but use maven local repo, how can I use gradle caches?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to handle Task.Run Exception - Stack Overflow
When a task is run, any exceptions that it throws are retained and re-thrown when something waits for the task's result or for...
Read more >
Exception handling (Task Parallel Library) - Microsoft Learn
Exceptions are propagated when you use one of the static or instance Task.Wait methods, and you handle them by enclosing the call in...
Read more >
How to properly handle exception in Task.Run | TatLead
Basic Solution. Catch and return the exception inside Task.Run , throw the exception outside. public static async ...
Read more >
8. Errors and Exceptions — Python 3.11.1 documentation
8.3. Handling Exceptions¶ · First, the try clause (the statement(s) between the try and except keywords) is executed. · If no exception occurs,...
Read more >
How to Throw Exceptions in Python - Rollbar
Using structured exception handling and a set of pre-defined exceptions, Python programs can determine the error type at run time and act ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found