How to solve the error "Webdriver cannot be resolved to a type"? - eclipse

To clear and run my code.
Webdriver cannot be resolved to a type

Please check and cross-verify the following to resolve the issue.
1: You might have unknowingly removed webdriver jars, try adding the webdriver(ChromeDriver) and selenium jars again.
2: Try using MAVEN and make sure while editing pom.xml you have provided the accurate scope and version of dependencies.
Hope this helps.

Related

Maven error ContextConfigApplicationContext cannot be resolved

I tried to import the spring starter pom.xml in my Eclipse Luna. I was getting the below error. I dont remember getting this error before after I installed and reinstalled it. Any thoughts
The type org.springframework.context.ConfigurableApplicationContext cannot be resolved. It is indirectly referenced from required .class files
I tried the below thread, but didnt help.
https://java.net/jira/browse/PINEAPPLE-764
Your maven cache seems corrupted. You need to purge local repository.
See my answer at this link for the detailed steps to solve this problem.

Cannot connect to RemoteNG Client. Check if old version of testng.jar is being used error-Eclipse Luna

I am getting an error like -
Cannot contact RemoteTestNG Client.Make sure you do not have older versions of testing.jar on your classpath.
Reason:Timeout while trying to contact RemoteTestNG.
I tried various solutions already present in stack overflow:
Check "Use project testng" option
Add latest testing.jar in classpath.
Check for duplicate testng jars in classpath.
Delete old testNG testsets ,clean workspace and restart workspace
But all the above solutions did not work for me and I ended up getting the same error again.
Please help me out here.
the latest release of testng eclipse 6.9.11 should fix this issue, please let me know (or fire an issue here https://github.com/cbeust/testng-eclipse/issues)
Noted: since this version, option "Use Project TestNG jar" was removed, to always respect the Project's TestNG lib.

Lombok and STS issue - Method undefined

I have STS version 3.6.3.SR1 that's based on Eclipse Luna 4.4.1.
I did the following steps:
Download and run the Lombok runnable jar and gave the path of my STS.
I verified the entries of vmargs, but was missing Xbootclasspath and added it resulting in
-vmargs -Dosgi.requiredJavaVersion=1.6
-XX:MaxPermSize=256m
-Dorg.eclipse.swt.browser.IEVersion=10001
-Xms512m
-Xmx1024m
-javaagent:C:\tools\Lombok\lombok.jar
-Xbootclasspath/a:C:\tools\Lombok\lombok.jar
I exit and opened the STS both from shortcut as well as the absolute location of the STS.exe.
I verified the outline of my Java classes that are annotated with #Data and other Lombok annotations. I can see the getters and setters generated. Even auto assist displays the method.
I did Maven → Update Project and even did a Project Clean
Confirmed that the Lombok is installed as well from the 'About STS' of 'Help'.
Even after all the above activities, there are lots of compiler issues that complains undefined method getXXX() and setXXX() on all #Data or #Getter or #Setter annotations.
Maven build runs successfully and the runtime behavior is fine, as the complied class seems to have the getters and setters.
IntelliJ seems to have no porblem with this as other developers are able to use the library.
My pom.xml has the following entry as well:
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.4</version>
</dependency>
How do I resolve?
P.S : I downloaded Eclipse Kepler build on top of STS to enable JBoss Fuse Tooling.
#Karthik R, thanks for your post. The following helped me to solve the issue:
Go to the Lombok page and download and double-click the jar and install in your IDE.
After that, open the .ini file and see if it has javaagent and Xbootclasspath variables.
In my case, Xbootclasspath was missing and when I added that, it worked.
-Xbootclasspath/a:PATH_To_lambok.jar
I added -Xbootclasspath/a:lombok.jar like naga1990 mentioned, however it still didn't solve the issue. After starting STS with -clean it did work.
I had a similar problem which was resolved by changing the scope of the Lombok dependency in the pom.xml file.
Originally, the scope was "provided" and I believe I saw all the strange behaviors you described. For instance, the context-sensitive code completion pulldown included the getter and setter methods. When I chose a getter method from the pulldown, the method was inserted into the source correctly. After insertion of the getter method, STS marked the method invocation as a compilation error because it thought the method did not exist.
After removing the "provided" scope from the Lombok dependency, STS worked correctly and the getter/setter methods could be added to code, the code could be compiled/packaged and executed. Execution of the getter/setter methods worked.
If you already tried other methods but it still doesn't work, you can try this:
If your project is Maven-based project, STS configured it as AspectJ Capability which will conflict with Lombok.
To solve it, remove Aspects Capability by Right-click the project -> AspectJ Tools -> Remove AspectJ Capability. Hope this will work.
I solved it as follows...
1. downloaded UI Swing application of lombok ... namely lombok.jar
2. started it and entered path of sts manually till sts.exe, i.e. complete folder which contains sts.exe
3. clicked on update/install
4. while doing all above 3 steps, make sure that sts is not running at all.
5. start sts
6. clean build the project.
This if for eclipse/STS
1. Close your sdk
2. download lombok jar
3. double click it or run it with java.exe
4. Make sure below line should get added in .ini file
-javaagent:\lombok.jar
5. add below line if missing add yourself
-Xbootclasspath/\lombok.jar
6. Open your sdk. Go to Help->About. You should see below line
"Lombok v1.18.6 "Envious Ferret" is installed. https://projectlombok.org/"
7. Clean your project.
8. Build it again.
Try to close your project, open it again and check. It worked for me.
After adding javaagent and Xbootclasspath values. Close STS completely and start again. Don't try to restart, it will not work
I had the same problem and it turns out that lombok is not working only when I'm starting STS from desktop shortcut which I created earlier (before loombok installed). I removed shortcut and created once again and lombok works fine. Please try this solution if you are using shortcut to run your sts.

Running JUnit Tests from Eclipse gives ClassNotFound Error

I am trying to run JUnit tests from Eclipse but while running these tests, I am getting ClassNotFound Exception
Complete Stack Trace follows:
java.lang.NoClassDefFoundError: of
Caused by: java.lang.ClassNotFoundException: of
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)
Exception in thread "main"
I have searched google for this and have found that couple of guys have faced this issue but none of them seems to be solving my issue. This can probably be due to difference in platforms
My development platform is as follows
OS: Windows XP
Eclipse JUNO
JUnit4
Maven2
Mean while, If I run this project using maven it runs absolutely fine.
The most strange part for me is the name of the class for which ClassNotFound Exception is thrown. Name of the class is of.
This is what blows me completely.
Also, what ever stack trace I have listed above, that is all what I get when I get the error nothing else.
I have been stuck in this issue for 2 days now, any help would be greatly appreciated.
I tried everything mentioned here and in other posts. Some of the solutions that people proffered were:
Change the output folder for the test
Create a custom builder for the project that would run test-compile from Maven
Move the Maven dependencies higher in the Order and Export list in the project build path
There were many, many more but the one that I found to work was as follows: Close the development environment. Delete the jars used by the project from my local Maven repository. Open the IDE. Build the project. Run the test.
After hours of beating my head against my keyboard and following suggested solutions, this one worked! If that doesn't work, you can try searching for the solutions I listed above.
Right clicking on the project name in Eclipse and choosing "Maven --> update project" will often solve this problem.
I know this question has already been answered but I will still share my solution here,
Make sure the output folder of 'src/test/java' has been set to 'target/test-classes', this has been said in many other posts so I will not repeat here.
If it still does not work, it is very likely that there are errors during the compiling of your unit test classes. Go 'Window' -> open 'Error Log' view, you should be able to see the detail of the error message.
For my case, a previously downloaded dependency jar is somehow corrupted due to network problems, so just delete the jar from local repository and use 'maven' -> 'update configuration' to download it again.
Then everything works!
Normally when we build we check "Skip Tests" in "Run configuration tab", instead uncheck "Skip Tests" and build the project the junits should work fine. This solution worked for me.
try switching the perspective to JUnit in eclipse and run the tests again
Despite all the answers and other posts I saw. I will give a summary of my effort:
it is probably this project's configuration doesn't fit with other projects in the same workspace. ( how to solve this is probably another question )
so, close this workspace, start a clean workspace for this project alone.
Was facing the same issue. This simple step solved it for me.
Remove JUnit from the project's Build Path and Add it again.
If set to Build Automatically, your workspace would be built again. If not set to Build Automatically then build your Project. Your issue should be solved.
You should add classes you use for example (spring-boot):
#RunWith(SpringRunner.class)
#SpringBootTest(classes = {DataPoint.class})
public class DataPointTest {
#Test
public void TestBuilder() {
DataPoint.Builder builder = new DataPoint.Builder();
DataPoint dataPoint = builder.withCount(4).withFirst(1).build();
assert dataPoint.getCount() == 4 && dataPoint.getFirst() == 1;
}
}
You can also check the info in POM.xml
I had the same issue. My project name was mismatching while setup the code.
<groupId>CucumberTest</groupId>
<artifactId>com.ProjectName</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>com.ProjectName</name>
<url>http://maven.apache.org</url>
After changing the project name in POM.xml it was working fine.

Groovy/Grails - Unable to Resolve Class

I am trying to build a Grails project in STS and am getting many error messages of the form: Groovy:unable to resolve class org.codehaus.groovy.grails.commons.ConfigurationHolder as well as others like Groovy:unable to resolve class org.grails.plugins.springsecurity.service.AuthenticateService
. I have Grails 1.3.7 selected in the Project Properties, but I don't see an item for 'Grails Depedencies' like I do when I create a sample project. Is this the problem? How can I add it back in?
I don't know why, but here are the steps I took to solve the problem:
Right click on the project and go to Grails Tools -> Enable Dependency Management
Grails Tools -> Refresh Dependencies. This correctly added the 'Grails Dependencies' library.
I still had plugin errors. I for some reason had to uninstall them and then reinstall them for the project to realize they were there.
For anyone who is using Grails >= 2.4
If you are using Grails 2.4 and above, use grails.util.Holders instead of org.codehaus.groovy.grails.commons.ConfigurationHolder.
Read the doc here section 'Static Holder'
Classes The following deprecated classes have been
removed from Grails 2.4.x:
org.codehaus.groovy.grails.commons.ApplicationHolder
org.codehaus.groovy.grails.commons.ConfigurationHolder
org.codehaus.groovy.grails.plugins.PluginManagerHolder
org.codehaus.groovy.grails.web.context.ServletContextHolder
org.codehaus.groovy.grails.compiler.support.GrailsResourceLoaderHolder
If you or any plugins you have installed are using these classes you
will get a compilation error. The problem can be rectified by updating
to new plugins and using grails.util.Holders instead.
If "Refresh Dependencies" has done all it can for you (as you indicate in your comment on the question), try disabling and re-enabling dependencies. You might try refreshing dependencies again afterward if the Acegi plugin still isn't recognized.
there is another way solved me this issue when i moved my workspace from Windows OS to Ubuntu , go to
yourWorkSpace -->yourGrailsProject-->setting folder --> org.grails.ide.eclipse.core.prefs,
then check all the grails paths are correct or not , because in my case all were pointing to windows paths ..
Hope this solve.
I faced a similar issue: "Unable to resolve class GrailsTestCase". I checked Grails Tools of my project and observed Dependency Management was already enabled (IDE - GGTS). I just disabled Dependency Management, refreshed and enabled it again. This solved the issue for me.