java.lang.NoClassDefFoundError: org/apache/cxf/service/invoker/Invoker - java

Does anyone know how to fix this?
I created a client to consume a webservice. The client code is:
package cliente;
import java.util.List;
import handler.HeaderHandler;
import webservice.BoletinOficial;
import webservice.BoletinOficialService;
import petanuncio.PeticionAnuncio;
import respanuncio.RespuestaAnuncio;
import org.apache.cxf.jaxws.binding.DefaultBindingImpl;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.handler.Handler;
import java.util.ArrayList;
public class Cliente {
/**
* Main
* #param args
*/
#SuppressWarnings("rawtypes")
public static void main(String[] args) {
String endpointURL = "";
try {
BoletinOficialService service = new BoletinOficialService();
BoletinOficial proxy = service.getBoletinOficialSoap11();
//rest of code
} catch (Exception e) {
e.printStackTrace();
}
}
The problem is when running the program and get the following error anc cannot even create "service":
Exception in thread "main" java.util.ServiceConfigurationError: javax.xml.ws.spi.Provider: Provider org.apache.cxf.jaxws.spi.ProviderImpl could not be instantiated
at java.util.ServiceLoader.fail(Unknown Source)
at java.util.ServiceLoader.access$100(Unknown Source)
at java.util.ServiceLoader$LazyIterator.nextService(Unknown Source)
at java.util.ServiceLoader$LazyIterator.next(Unknown Source)
at java.util.ServiceLoader$1.next(Unknown Source)
at javax.xml.ws.spi.Provider.getProviderUsingServiceLoader(Unknown Source)
at javax.xml.ws.spi.Provider.provider(Unknown Source)
at javax.xml.ws.Service.<init>(Unknown Source)
at webservice.BoletinOficialService.<init>(BoletinOficialService.java:46)
at cliente.Cliente.main(Cliente.java:35)
Caused by: java.lang.NoClassDefFoundError: org/apache/cxf/service/invoker/Invoker
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
... 8 more
Caused by: java.lang.ClassNotFoundException: org.apache.cxf.service.invoker.Invoker
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 12 more
This class and others were created via wsimport from a wsdl file, althoug I don't think this is related to the error I am getting.
The class org.apache.cxf.jaxws.spi.ProviderImpl is in cxf-rt-frontend-jaxws-3.1.1.jar file whis is added as referece to the project.
Is there anything I am missing? Thank you in advance.

Add the compile dependencies you find at https://mvnrepository.com/artifact/org.apache.cxf/cxf-rt-frontend-jaxws/3.1.1
Better, switch to Maven.

Invoker is part of the CXF API. Looks like the cxf-api is missing.
If you use maven, add the dependency :
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-api</artifactId>
<version>YOUR_VERSION</version>
</dependency>
Else add the jar to your classpath.

Related

Could not instrument class IllegalArgumentException

While learning and exploring Java 9 from eclipse. I create a simple project in eclipse, Although when I compile the project, it prints the program's expected result but along following exception too.
Could not instrument class mymodule/App: java.lang.IllegalArgumentException
at org.eclipse.jdt.launching.internal.org.objectweb.asm.ClassReader.<init>(Unknown Source)
at org.eclipse.jdt.launching.internal.weaving.ClassfileTransformer.transform(ClassfileTransformer.java:25)
at org.eclipse.jdt.launching.internal.javaagent.Premain$1.transform(Premain.java:51)
at java.instrument/java.lang.instrument.ClassFileTransformer.transform(Unknown Source)
at java.instrument/sun.instrument.TransformerManager.transform(Unknown Source)
at java.instrument/sun.instrument.InstrumentationImpl.transform(Unknown Source)
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(Unknown Source)
at java.base/java.security.SecureClassLoader.defineClass(Unknown Source)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(Unknown Source)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(Unknown Source)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(Unknown Source)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Unknown Source)
at java.base/sun.launcher.LauncherHelper.loadMainClass(Unknown Source)
at java.base/sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Java code:
package mymodule;
import java.util.List;
public class App {
public static void main(String[] args) {
List<String> immutables = List.of("Food", "Water", "House");
System.out.println(immutables.get(0));
}
}
module-info.java file
module mymodule {
}
Seems like Eclipse is yet to migrate to ASM_6.0 which is completely Java 9 compatible.
On the other hand you're looking at the stacktrace which is similar to BUG#526383 and you can follow the same for updates.

Error message in simple selenium code

I'm trying to learn selenium. So I installed the below tools:
Firefox V 31
Selenium-firefox-driver-2.0b3
And I used the code below to run it and got a error message. Not sure what it means. Any help will be good.
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Sele {
/**
* #param args
*/
public static void main(String[] args) {
// Create webDriver reference
WebDriver driver;
// Launch FirefoxDriver
driver = new FirefoxDriver();
// Open the web page
driver.get("http://google.com");
// Enter the text in the search box
WebElement searchText = driver.findElement(By.name("q"));
searchText.sendKeys("FirefoxDriver");
// Close the driver
driver.quit();
}
}
Error message :
Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/RenderedWebElement
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at Sele.main(Sele.java:17)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.RenderedWebElement
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 13 more
It seem you have a dependency missing as explained on their main site you need to install the selenium server as well not just the browser driver.

ClassNotFoundException: org.apache.xerces.parsers.AbstractSAXParser when using boilerpipe

I am very new to boilerpipe and I am trying out the following basic code:
package contentExtraction;
import java.net.URL;
import de.l3s.boilerpipe.extractors.ArticleExtractor;
public class ContentExtractor {
public static void main(String[] args) throws Exception {
final URL url = new URL(
// "http://www.l3s.de/web/page11g.do?sp=page11g&link=ln104g&stu1g.LanguageISOCtxParam=en"
"http://www.dn.se/nyheter/vetenskap/annu-godare-choklad-med-hjalp-av-dna-teknik"
);
System.out.println(ArticleExtractor.INSTANCE.getText(url));
}
}
But I am getting the following error when trying to run the above piece of code:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xerces/parsers/AbstractSAXParser
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at de.l3s.boilerpipe.sax.BoilerpipeSAXInput.getTextDocument(BoilerpipeSAXInput.java:51)
at de.l3s.boilerpipe.extractors.ExtractorBase.getText(ExtractorBase.java:69)
at de.l3s.boilerpipe.extractors.ExtractorBase.getText(ExtractorBase.java:87)
at contentExtraction.ContentExtractor.main(ContentExtractor.java:16)
Caused by: java.lang.ClassNotFoundException: org.apache.xerces.parsers.AbstractSAXParser
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 16 more
I googled the error and came across this link. I thought that I was missing xercesImpl.jar in my dependencies. I included the same, still my code is giving the same error. What is the issue?
I figured the solution myself. The boilerpipe jar has further dependencies. I converted my project to maven project, included the dependency:
<dependency>
<groupId>com.syncthemall</groupId>
<artifactId>boilerpipe</artifactId>
<version>1.2.1</version>
</dependency>
When I build the above project, I can see there are actually 4 jars that are imported in Maven Dependencies folder:
boilerpipe-1.2.1.jar
nekohtml-1.9.18.jar
xercesImpl-2.11.0.jar
xml-apis-1.4.01.jar

noclassdeffounderror in a simple networking program. I am using Eclipse IDE to run java programs

import java.net.InetAddress;
import java.net.UnknownHostException;
class IpAddr {
public static void main(String arg[]) {
System.out.println("Hello Jagadeesh...>!!");
try {
InetAddress ia=InetAddress.getByName("www.facebook.com");
System.out.println(ia);
}
catch(UnknownHostException uhe) {
System.out.println("ip address of facebook is not found. :(");
}
}
}
In console: while running
E:\myworkspace\network_practice\src\stage1>javac IpAddr.java
E:\myworkspace\network_practice\src\stage1>java IpAddr
Exception in thread "main" java.lang.NoClassDefFoundError: IpAddr (wrong name: s
tage1/IpAddr)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
E:\myworkspace\network_practice\src\stage1>cd..
You did not declare a package in your class so it goes to default package.But you have stage1 folder.
NoClassDefFoundError in Java comes when Java Virtual Machine is not
able to find a particular class at runtime which was available during
compile time.
Source: http://javarevisited.blogspot.de/2011/06/noclassdeffounderror-exception-in.html
Therefore I would check if you have added everything neccessary to your class path.
Jagadeesh,
it might be the case that your InetAddress jar version might not be supported

Can't compile a simple JFACE program; java.lang.NoClassDefFoundError

I am trying to run a very simple JFace program:
import org.eclipse.jface.window.*;
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
public class HelloSWT_JFace extends ApplicationWindow{
public HelloSWT_JFace(){
super(null);
}
protected Control createContents(Composite parent){
Text helloText = new Text(parent, SWT.CENTER);
helloText.setText("Hello SWT and JFace");
parent.pack();
return parent;
}
public static void main(String[] args) {
HelloSWT_JFace awin = new HelloSWT_JFace();
awin.setBlockOnOpen(true);
awin.open();
Display.getCurrent().dispose();
}
}
As far as I know, all the libraries are installed and the code, in Eclipse, gives me no errors. Nonetheless, when I run I get
and the long error report:
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/core/runtime/IProgressMonitor
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.eclipse.core.runtime.IProgressMonitor
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 6 more
Does anyone know what could be causing this?
Please note; I took a look at THIS question and followed the solutions, but installing Equinox plugins did not work.
Thanks to the links Baz provided, I found the solution by making sure all the necessary Jars were added (I was missing a couple).
The necessary jars are:
org.eclipse.core.commands_<version info>.jar
org.eclipse.equinox.common_<version info>.jar
org.eclipse.jface_<version info>.jar
org.eclipse.osgi_<version info>.jar
org.eclipse.ui.workbench_<version info>.jar
More info can be found at the link Baz provided: "Identify the Required External JAR Files for SWT and JFace"

Categories

Resources