Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

java.lang.NoClassDefFoundError: javax/xml/ws/Service

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good Morning,
first of all, I am not very knowledgeable in JAVA, this is not my usual development language, however I have to resolve this situation:
The Java version is 11 and I am using eclipse with jdk 1.8, which was the standard for developing this API. I have already imported the JAR and changed it to maven project and added the dependencies in pom.xlm
<dependency>
         <groupId> javax.xml.ws </groupId>
         <artifactId> jaxws-api </artifactId>
         <version> 2.2.8 </version>
     </dependency>
     <dependency>
         <groupId> com.sun.xml.ws </groupId>
         <artifactId> jaxws-rt </artifactId>
         <version> 2.1.4 </version>
     </dependency>
It still doesn't work.

Someone can help me ???


Exception in thread "main" java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:61)
Caused by: java.lang.NoClassDefFoundError: javax/xml/ws/Service
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:550)
at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:458)
at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:452)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:451)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at pt.xxxxx.it.eurolinea.elintegrator.APIXXX.sendSetValuationRequest(APIXXX.java:111)
at pt.xxxxx.it.eurolinea.elintegrator.X123.bCASendRequest(BCA.java:144)
at pt.xxxxx.it.eurolinea.elintegrator.X123.elBCA(BCA.java:157)
at pt.xxxxx.it.eurolinea.elintegrator.ElIntegrator.execute(ElIntegrator.java:444)
at pt.xxxxx.it.eurolinea.elintegrator.ElIntegrator.main(ElIntegrator.java:161)
... 5 more
Caused by: java.lang.ClassNotFoundException: javax.xml.ws.Service
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
 
Saloon Keeper
Posts: 12165
258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try replacing your two dependencies with these two:

If it doesn't work, then tell us how you're running your application exactly.
 
vitor henriques
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It still doesn't work.
I hope I can answer in an enlightening way:

The JAR file is being called (serverside) by a batch file and
the manifest has:

Manifest-Version: 1.0
Rsrc-Class-Path: .


do I need to include in the manifest the files that I mention on the pom.xml file?
 
Stephan van Hulst
Saloon Keeper
Posts: 12165
258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean, "export to JAR file"? Are you not using Maven to build your JAR?

If you want to build a fat JAR, you should use the Maven Shade Plugin, not whatever export method Eclipse provides.
 
Stephan van Hulst
Saloon Keeper
Posts: 12165
258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you building a JAR instead of a WAR?
 
vitor henriques
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes compiled in maven - Maven builds before putting into production. Why in JAR and not in WAR?
Because the application is already like this, I didn't create it, and as I said,JAVA it's not my thing.
What I realized was that the JAVA version was updated to ver11 and since then these errors started.

- well, it seems to me (and I don't make any statements because I'm not sure) I can't use maven dependencies because they ignore everything in the manifest.

Assuming that I cannot use war files (I am running a script that executes jar file) and that I cannot use maven dependencies, how can I solve this?
 
Sheriff
Posts: 7108
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

vitor henriques wrote:It still doesn't work.


Does that mean it gets the exact same error message as the one you first posted?  If not, post the entire new error message.
 
vitor henriques
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It still doesn't work.
the error is:
Could not find or load main class or.eclipse.jdt.internal.jarinjarloader
 
vitor henriques
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in pom.xml do not need to reference the other classes that are in the manifest?

<configuration>
           <archive>
             <manifestEntries>
               <Main-Class> org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader </Main-Class>
             </manifestEntries>
           </archive>
         </configuration>
 
Knute Snortum
Sheriff
Posts: 7108
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post the full error message and stack trace (all the verbage after the error message).  But notice that this is a different error than the first.
 
Knute Snortum
Sheriff
Posts: 7108
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure it matters, but try removing the whitespace at the beginning and end.
 
Stephan van Hulst
Saloon Keeper
Posts: 12165
258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It appears that you're trying to build a web service that has an embedded web container. That's why it's an executable JAR and not a WAR. This is fine, but the problem is that you're mixing build systems. You're using Maven to compile your application, but you're telling Eclipse to package your application as a fat JAR with dependencies.

I'm not too familiar with how Eclipse creates fat JARs. Can you tell us the exact steps you performed to export your application as a JAR in Eclipse? Can you also please show us your entire POM if possible?
 
vitor henriques
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

C:\new>java -jar BCAws-.jar
Error: Could not find or load main class org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader
Caused by: java.lang.ClassNotFoundException: org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader

is not loading the classes that are in the Manifest, my doubt is:
I must include all classes and pom.xml.
because since I converted the jar file to maven it ignores the manifest.
The manifest is at the beginning of this post
 
vitor henriques
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:It appears that you're trying to build a web service that has an embedded web container. That's why it's an executable JAR and not a WAR. This is fine, but the problem is that you're mixing build systems. You're using Maven to compile your application, but you're telling Eclipse to package your application as a fat JAR with dependencies.

I'm not too familiar with how Eclipse creates fat JARs. Can you tell us the exact steps you performed to export your application as a JAR in Eclipse? Can you also please show us your entire POM if possible?




1 - import the JAR file that contains
appClientModule
JRE System Library
Referenced Libraries
ImportedClasses
2 - convert to Maven project
3 - I create it depended on pom.xlm as suggested to solve the problem in the link below
https://www.studytonight.com/post/solved-caused-by-javalangclassnotfoundexception-javaxxmlwswebservicefeature-in-java-11
4- Maven Install



POM

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 <modelVersion>4.0.0</modelVersion>
 <groupId>BCAws</groupId>
 <artifactId>BCAws</artifactId>
 <version>1.0-SNAPSHOT</version>
 <packaging>app-client</packaging>
 <build>
   <sourceDirectory>appClientModule</sourceDirectory>
   <resources>
     <resource>
       <directory>appClientModule</directory>
       <excludes>
         <exclude>**/*.java</exclude>
       </excludes>
     </resource>
   </resources>
   <plugins>
     <plugin>
       <artifactId>maven-compiler-plugin</artifactId>
       <version>3.7.0</version>
       <configuration>
         <source>1.8</source>
         <target>1.8</target>
       </configuration>
     </plugin>
     <plugin>
       <artifactId>maven-acr-plugin</artifactId>
       <version>1.1</version>
       <extensions>true</extensions>
       <configuration>
         <archive>
           <manifestEntries>
             <Main-Class>org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader</Main-Class>
           </manifestEntries>      
         </archive>
       </configuration>
     </plugin>
   </plugins>
 </build>
 <dependencies>
 <dependency>
   <groupId>javax.xml.ws</groupId>
   <artifactId>jaxws-api</artifactId>
   <version>2.3.1</version>
</dependency>
</dependencies>
</project>
 
Stephan van Hulst
Saloon Keeper
Posts: 12165
258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. I'm pretty certain the problem is caused by a mismatch between how Eclipse builds fat JARs and how it converts projects to Maven. I first need to find out of the maven-acr-plugin also creates a fat JAR. If it doesn't, then that is your problem: Maven builds a normal JAR where other libraries are in some folder relative to the built JAR. Eclipse packages all the JARs into the built JAR and uses a custom class loader. You are getting an exception because your application still assumes that it is being packaged by Eclipse, and that it uses the JarRsrcLoader. This is no longer the case.

Here are a few questions for you.

  • Why did you convert the project to Maven? Was it only to add the dependency on JAX-WS?
  • Must the application be a fat JAR? That is, must all libraries be contained inside the executable JAR you're building?

  • If you only converted the project so you could add the dependency, it's probably easier if you just download the JAX-WS API and runtime manually and add them as dependencies to your Eclipse project. Don't get me wrong, I love Maven and I think every new project should use (a build tool like) Maven. But converting an existing project for such a small issue doesn't seem worth the pain.

    If you want to stick with Maven, and the maven-acr-plugin doesn't create a fat JAR, you need to decide whether you want to deploy the application as a regular thin JAR, or whether you want to use the maven-shade-plugin to create a fat JAR.
     
    vitor henriques
    Greenhorn
    Posts: 12
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    good morning Stephan


    first of all, I would like to thank you for your responses to my post,
    I just discovered this link right now, I think maybe the problem resolution will come through this link and not using Maven, as you say and it makes sense
    question:
    how to update and compile these libraries in the eclipse?


    https://mvnrepository.com/artifact/javax.xml.ws/jaxws-api/2.3.1
     
    vitor henriques
    Greenhorn
    Posts: 12
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Stephan van Hulst wrote:Thanks. I'm pretty certain the problem is caused by a mismatch between how Eclipse builds fat JARs and how it converts projects to Maven. I first need to find out of the maven-acr-plugin also creates a fat JAR. If it doesn't, then that is your problem: Maven builds a normal JAR where other libraries are in some folder relative to the built JAR. Eclipse packages all the JARs into the built JAR and uses a custom class loader. You are getting an exception because your application still assumes that it is being packaged by Eclipse, and that it uses the JarRsrcLoader. This is no longer the case.

    Here are a few questions for you.

  • Why did you convert the project to Maven? Was it only to add the dependency on JAX-WS?
  • Must the application be a fat JAR? That is, must all libraries be contained inside the executable JAR you're building?


  • Why did you convert the project to Maven? Was it only to add the dependency on JAX-WS?
    to be able to access the POM, if there is any other way, please say

    Must the application be a fat JAR? That is, must all libraries be contained inside the executable JAR you're building?
    yes

     
    vitor henriques
    Greenhorn
    Posts: 12
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I add manually the jaxws dependencies in the fat jar
    adding external jar - In the project, I right-click on the libraries, go to add external jar, and find the jar

    still not working
     
    Knute Snortum
    Sheriff
    Posts: 7108
    184
    Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    vitor henriques: in general, it is a bad idea to edit old posts.  People will probably not see the change and it can make the current thread seem like nonsense.  If you do edit an old post, be sure to writing in the post what you edited, like:

    [Edit: changed foo to bar]
     
    Stephan van Hulst
    Saloon Keeper
    Posts: 12165
    258
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Vitor, please explain us how exactly you created the JAR in Eclipse for the old working version.
     
    vitor henriques
    Greenhorn
    Posts: 12
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I didn't create the JAR file, the API was created by someone else I don't even know, I'm just trying to solve the problem ... So, I import the jar into eclipse I created the dependency by importing jaxws-api.jar into the library, in the end, I export the file the same way I imported
     
    Consider Paul's rocket mass heater.
      Bookmark Topic Watch Topic
    • New Topic