java.lang.noclassdeffounderror甚至在build.gradle中添加依赖项

发布于 2025-01-18 15:18:51 字数 2232 浏览 1 评论 0 原文

美好的一天,

基于, 我用我的 wsdl 文件成功了Web服务。与网站不同的是,我在 jboss EAP 中启动我的Web服务,该教程将使用 tomcat 作为例如。

我可以成功地卷入http:// localhost:8080/eai/services/mydelegatebeanservice。

我想在 myDelegateBeanServicesKeleton.java 文件中进行一些更改,例如,我需要一些第三方库,例如 com.google.guava 。因此,我尝试在此项目上添加Gradle。

我创建一个build.gradle如下:

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'application'

mainClassName = "myeai"

repositories { 
    mavenCentral() 
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
    implementation "com.google.guava:guava:17.0"
    testImplementation "junit:junit:4.12"
}

我可以运行 gradle build gradle eclipse 而无需错误,我可以看到 guava 库出现在参考库中:

在我的Java代码中,我可以看到我的导入也没有编译错误:

import com.google.common.base.Strings;

System.out.println("item is " + Strings.isNullOrEmpty(reader.getText()));

但是,当我再次卷曲时,我会遇到以下错误:

[ERROR] com/google/common/base/Strings
java.lang.NoClassDefFoundError: com/google/common/base/Strings

Caused by: java.lang.ClassNotFoundException: com.google.common.base.Strings from [Module "deployment.allpocEAR.ear.eai.war" from Service Module Loader]
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:412)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:400)
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
    ... 47 more

我可以知道我的错误是什么?

我尝试在JBOSS中重新启动我的EAP服务器也一样:

Good day,

Base on https://www.eclipse.org/webtools/community/tutorials/TopDownAxis2WebService/td_tutorial.html ,
I successful up the web service with my wsdl file. The different thing from the website is, I start my webservice in Jboss EAP, the tutorial was using TomCat as example.

I can curl request to http://localhost:8080/eai/services/MyDelegateBeanService successfully.

I would like to make some changes inside the MyDelegateBeanServiceSkeleton.java file, and I need some third party library, for example, com.google.guava. Thus, I try to add gradle on this project.

I create a build.gradle as follow:

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'application'

mainClassName = "myeai"

repositories { 
    mavenCentral() 
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
    implementation "com.google.guava:guava:17.0"
    testImplementation "junit:junit:4.12"
}

I can run gradle build, gradle eclipse successfully without error, and I can see the guava library appear in the reference library:
enter image description here

In my java code, I can see my import is without compilation error as well:

import com.google.common.base.Strings;

System.out.println("item is " + Strings.isNullOrEmpty(reader.getText()));

However, when I curl again, I will hit the following error:

[ERROR] com/google/common/base/Strings
java.lang.NoClassDefFoundError: com/google/common/base/Strings

Caused by: java.lang.ClassNotFoundException: com.google.common.base.Strings from [Module "deployment.allpocEAR.ear.eai.war" from Service Module Loader]
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:412)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:400)
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
    ... 47 more

May I know what is my mistaken?

I have try to restart my EAP server in jboss also the same:
enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

神爱温柔 2025-01-25 15:18:51

我发现我应该使用编译而不是实现:

compile "joda-time:joda-time:2.2"
compile "com.google.guava:guava:17.0"

I found that I should use compile instead of implementation:

compile "joda-time:joda-time:2.2"
compile "com.google.guava:guava:17.0"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文