Hi I am working on Java & am using HtmlUnitDriver.I have created the object
`WebDriver webDriver = new HtmlUnitDriver(true);`
I am using selenium-htmlunit-driver-2.24.1.jar & selenium-java-2.24.1.jar.
When I run my code I am getting following exception.
Exception in thread "Thread-5" java.lang.NoClassDefFoundError: org/openqa/selenium/internal/FindsByCssSelector
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Please guide me how to solve this issue.If there is jar for this Exception then which Jar should I use?
Make sure that all the relevant jars (such as package and library jars) are in the class path. Always make sure to clean and recompile the project once you copied jars.
[You can use a jar search engine to find jars of missing classes.][1]
[http://www.jarvana.com/jarvana/search?search_type=class&java_class=org.openqa.selenium.internal.FindsByCssSelector][1]
Note : It is always advisable to use jars from official release, because of possible compatibility issues due to version difference.
Related
I am working on map reduce join problem using joiner and splitter functions. I have searched a lot on Google and finds about adding guava-18.0.jar file in the referenced libraries of the project. I also attached the javadoc location to the jar file but still getting this error mentioned below:
Error: java.lang.ClassNotFoundException: com.google.common.base.Splitter
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at edu.cs.okstate.cs.Partitioning.Partition_Mapper.setup(Partition_Mapper.java:29)
at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:142)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:764)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:364)
at org.apache.hadoop.mapred.Child$4.run(Child.java:255)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:415)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1190)
at org.apache.hadoop.mapred.Child.main(Child.java:249)
I'm guessing you're using your IDE to manage your project and not a dependency management tool (Maven, Gradle, Ant+Ivy...), and the Guava jar doesn't actually end up in the classpath of your Hadoop job.
Make sure it gets bundled with what's deployed.
I'm struggling with a Java/Maven/Jetty problem that I can't solve.
I have a Java Jetty server that starts up correctly but as soon as an HTTP request is sent to it, it aborts showing this stacktrace:
2013-09-30 08:40:24,534 [qtp297240915-11 Selector0] WARN org.eclipse.jetty.io.nio - java.lang.SecurityException: class "javax.servlet.AsyncContext"'s signer information does not match signer information of other classes in the same package
at java.lang.ClassLoader.checkCerts(ClassLoader.java:806) ~[na:1.6.0_37]
at java.lang.ClassLoader.preDefineClass(ClassLoader.java:487) ~[na:1.6.0_37]
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:625) ~[na:1.6.0_37]
at java.lang.ClassLoader.defineClass(ClassLoader.java:615) ~[na:1.6.0_37]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) ~[na:1.6.0_37]
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283) ~[na:1.6.0_37]
at java.net.URLClassLoader.access$000(URLClassLoader.java:58) ~[na:1.6.0_37]
at java.net.URLClassLoader$1.run(URLClassLoader.java:197) ~[na:1.6.0_37]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.6.0_37]
at java.net.URLClassLoader.findClass(URLClassLoader.java:190) ~[na:1.6.0_37]
at java.lang.ClassLoader.loadClass(ClassLoader.java:306) ~[na:1.6.0_37]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) ~[na:1.6.0_37]
at java.lang.ClassLoader.loadClass(ClassLoader.java:247) ~[na:1.6.0_37]
at org.eclipse.jetty.server.AbstractHttpConnection.<init>(AbstractHttpConnection.java:157) ~[jetty-server-8.1.9.v20130131.jar:8.1.9.v20130131]
at org.eclipse.jetty.server.AsyncHttpConnection.<init>(AsyncHttpConnection.java:50) ~[jetty-server-8.1.9.v20130131.jar:8.1.9.v20130131]
at org.eclipse.jetty.server.nio.SelectChannelConnector.newConnection(SelectChannelConnector.java:285) ~[jetty-server-8.1.9.v20130131.jar:8.1.9.v20130131]
at org.eclipse.jetty.server.nio.SelectChannelConnector$ConnectorSelectorManager.newConnection(SelectChannelConnector.java:325) ~[jetty-server-8.1.9.v20130131.jar:8.1.9.v20130131]
at org.eclipse.jetty.server.nio.SelectChannelConnector.newEndPoint(SelectChannelConnector.java:272) ~[jetty-server-8.1.9.v20130131.jar:8.1.9.v20130131]
at org.eclipse.jetty.server.nio.SelectChannelConnector$ConnectorSelectorManager.newEndPoint(SelectChannelConnector.java:331) ~[jetty-server-8.1.9.v20130131.jar:8.1.9.v20130131]
at org.eclipse.jetty.io.nio.SelectorManager$SelectSet.createEndPoint(SelectorManager.java:836) ~[jetty-io-7.6.5.v20120716.jar:7.6.5.v20120716]
at org.eclipse.jetty.io.nio.SelectorManager$SelectSet.doSelect(SelectorManager.java:491) ~[jetty-io-7.6.5.v20120716.jar:7.6.5.v20120716]
at org.eclipse.jetty.io.nio.SelectorManager$1.run(SelectorManager.java:285) [jetty-io-7.6.5.v20120716.jar:7.6.5.v20120716]
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:603) [jetty-util-8.1.3.v20120416.jar:8.1.3.v20120416]
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:538) [jetty-util-8.1.3.v20120416.jar:8.1.3.v20120416]
at java.lang.Thread.run(Thread.java:662) [na:1.6.0_37]
Clearly there is something odd going on within the jars included to run it, and in Google I could find some references to this problem but without a clear solution.
Anyway, the strangest thing is that the same application runs perfectly in another machine. To make sure that there were no differences between the two, I copied the directory of the project (including compiled classes, the maven dependencies jars, configuration files, etc) from the machine where it runs fine to the other where it doesn't. The error keeps showing up.
I've also deleted the maven local cache for the machine (~/.m2/), although it shouldn't matter. Java and Maven versions are the same in the two machines.
Clearly, there has to be some environment difference among the two but I don't know where else I should look for apart from the aspects I've just mentioned.
Any ideas?
EDIT: The project was including two conflicting versions of javax.servlet.servlet-api. Excluded the older one from the pom fixed the issue.
Either way, it remains to me a mystery why in one machine although both the jars were loaded (double checked with lsof) the server was running just fine. Maybe the order of the class loader was taken into consideration?
Blockquote
java.lang.SecurityException: class "javax.servlet.AsyncContext"'s signer information does not match signer information of other classes in the same package
This Exception thrown in my project too. At last i find out the solution. The exception thrown because of referring same dependency with different version. So the java code signature mess up with the dependency.
Add proper dependency
Check with dependency version
Avoid multiple dependency of same jar
javax.servlet
servlet-api 2.5
provided
Only one dependency is needed
You shouldn't need to exclude it; any reference to the servlet-api for a project that will be deployed in a container should use <scope>provided</scope> to ensure that only the container's version is present at runtime (how to add the servlet api to my pom.xml).
Good morning every body ,
I have java code that alllows me to create an excel file from xml flie.. But it can not create correctly the file, i have this exception that I do not inderstand its meaning :
Exception in thread "main" java.lang.NoClassDefFoundError: org/dom4j/DocumentException
at org.apache.poi.openxml4j.opc.Package.init(Package.java:145)
at org.apache.poi.openxml4j.opc.Package.<init>(Package.java:132)
at org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:67)
at org.apache.poi.openxml4j.opc.Package.create(Package.java:271)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.newPackage(XSSFWorkbook.java:245)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:145)
at escel1.Escel1.main(Escel1.java:104)
Caused by: java.lang.ClassNotFoundException: org.dom4j.DocumentException
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
If someone knows what that means , it will be very helpfull for me :)
I have found the key about your problem. you shouldn't add the jar file of dom4j-1.6.1-sources.jar but dom4j-1.x.jar into the project library. Because the jar file's name with sources is pure java file(xx.java), that means it's not compiled at all.
then rebuild your project, it'll work fine.
Hope to help you :)
Apache POI have a handy page listing all the components and their dependencies, you should start by reading that!
Secondly, if you downloaded the binary zip/tarball of Apache POI, then it comes with all of the dependencies you need in the /lib/ and /ooxml-lib/ directories. Make sure you include all the dependencies required from there on your classpath! (You've missed some out, hence the error)
I am running some unit tests within Eclipse and I am using Mockito to mock as follows:-
HttpServletRequest mockRequest = mock(HttpServletRequest.class);
When I run the test from within Eclipse I get the following stack trace
java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/servlet/ServletException
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
However I do not receive any such errors when run from the command line using maven
I have seen similar questions posted elsewhere and I have made sure I have the implementation jars and not just the API jars. My maven dependency is as follows
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.servlet</artifactId>
<version>10.0-b28</version>
<scope>test</scope>
</dependency>
I have spent way too much time on this, fiddling with my classpaths and cleaning my workspace multiple times but to no avail.
I just created a simple test:
#Test
public void test(){
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
System.out.println(request);
}
with my Helios eclipse and with dependency provided by you - everything works as expected, no exceptions.... You might have something else on your classpath in eclipse or the problem might come from a different line.
You can try checking which jar is used using (for example)
HttpServletRequest.class.getProtectionDomain().getCodeSource()
You could also consider using httpunit instead of mocking request.
I'm using Jersey for REST apps, i'm getting this NoClassDefException for the class AbstractRuntimeDelegate
though i have the following Jars in my classpath....
commons-httpclient-3.1.jar
List item
javax.ws.rs.jar
jersey-core-1.9.1-sources.jar
jersey-server-1.1.2-ea.jar
That class is in the jersey-core-1.9.1-sources.jar as i can see from here
http://www.jarvana.com/jarvana/inspect/com/sun/jersey/jersey-core/1.9.1/jersey-core-1.9.1-sources.jar?folder=com/sun/jersey/core/spi/factory/
Have you ever had this kind of issue?
Any advice?
Thank you
Piece of exception:
Exception in thread "bq-main" java.lang.NoClassDefFoundError: com/sun/jersey/core/spi/factory/AbstractRuntimeDelegate
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
I think you should use jersey-core-1.9.1.jar instead of its source jar.