I am on Intellij 2016.2.4
I have imported a project from Git (I am new to that). I do now want to run a Module. I added to this Module every other Module Dependency and JAR Files needed. Their Scope is Compile.
The project is running for others without changes.
If I make the Module I get:
java: cannot find symbol ; location: class utils.MyRandom
The method which cannot be found is in the other Module. Interestingly, if I click on the Classname and go to the definition, Intelij does decompile an .class file for that Class, and that file is missing two methods - those which cannot be found.
Furthermore an other Module needs that Class. But not the same Methods! If I make this Module it succeeds, but if I add for testing purposes the Methods, which are not available in the other Module, they do not work here too.
I have seen that there are already some Questions about that here, but there Answers doesn't help me.
The "wrong" Class is in COMMON. While any is not working here, other Methods from that Class are working in CLIENT.
Seems like the dependency for the module where you are calling the method, MyRandom is not properly defined,which is usually a issue when git repo is cloned, when some IDE specific dependencies are ignored while pushing.
This might be conflict due to cache.
Go to File -> Invalidate Caches/Restart.
This should work.
Thanks
Related
I have recently migrated my project from Java8 to Java17. I wanted to try out the module system and added a module-info.java to my existing Eclipse project. As it caused several issues, I decided to revert back the change and to proceed without declaring modules. I deleted the file, but now I am getting compile errors. It is stated that LibX11 and libvlc_instance_t cannot be resolved to be a type and that they are not accessible. Why is that? It was working fine before. It seems that adding and removing the module-info.java has somehow messed up my configuration.
I need to access libvlc_instance_t because I need to subclass MediaPlayer, which requires a reference to libvlc_instance_t in the constructor. If libvlc_instance_t is really not meant to be used, how can I solve this? Thank you!
I occasionally get name clash errors in a java project built with Jenkins.
I've seen it in a couple places, and it both places it follows the following format:
public class Foo {
public enum FooEnum {
VALUE1("Val1"),
VALUE2("Val2)
private FooEnum(String) { /*code*/}
}
}
And the error output would say:
[javac] /path/Foo.java:6: error: name clash: FooEnum(String) and FooEnum(String) have the same erasure
[javac] private FooEnum(String)
^
Note that there is only one method named FooEnum, so its not a case of type erasure issues or anything like that. The method seems to be somehow conflicting with itself.
I develop the code in Eclipse and my codebase spans multiple Eclipse projects in the same workspace. For my Jenkin's pipeline, I have a job for each Eclipse project.
When each project finishes, it archives the whole project directory (which includes the source and the .class files). Downstream projects then copy the archived objects from the previous builds so that they can use them as dependencies.
I am using ant build.xml files which are auto-generated from eclipse.
These errors don't show up super often, but when they do, they usually persist for a few builds and then go away. I have not been able to figure out any pattern indicating when they occur and when they don't.
I have never had any issues when building within Eclipse, so I think the issue must have more to do with my Jenkins setup or the build files.
Unfortunately, do to my companies strict proprietary information protection policies, I'm a little apprehensive about sharing any actual code or actual ant files here, but I was hoping someone would have an idea they could share with me.
I was able to fix this by explicitly copying in the dependency projects required for each job and making sure that I only copied in those projects.
Previously, I would sometimes copy in all of the artifacts from a few jobs that had the dependencies I needed. I think that something weird was happening in the cases where a dependency was found in multiple jobs that I copied in. I still haven't figured out exactly what's going on, but this seems to have fixed it.
I have imported apache nutch from http://svn.apache.org/repos/asf/nutch/trunk/ through SVN on eclipse; however, the project I have imported has 10k+ java errors:
Some errors are due to source files being in a package different from what is specified in their source, (e.g. classes in java.org.apache... but it is declared in source that they should be in org.apache..., this is observed in many other packages)
Unimported classes, for example the Class "Context" is used in many of the classes however when looking at the import list, "Context" is not declared there.
Missing classes, though imported, classes still not resolved to a type, most probably because my imported project lacks many of the needed libraries such as hadoop,gora,witty,etc.
(Not familiar with this) Bound mismatch errors like: The generic method createDataStore(Configuration, Class, Class) of type StorageUtils is not applicable for the arguments (Configuration, Class, Class). The inferred type WebPage is not a valid substitute for the bounded parameter
What is the correct way of importing a nutch through eclipse without encountering the errors specified above? Thanks!
Refer to http://wiki.apache.org/nutch/RunNutchInEclipse
These should be followed to the "T" and it works fine.
Specially, pay attention to the manual configuration of the build paths for the plugins.
You may also notice that some library dependancies are not set even after setting the build path,within certain plugins. .. you will need to manually add the ivey dependancies for these plugins into the build patch as well.
I'm trying to instantiate an object using a class in an external jar. This is a jar that a team-member is developing and recently changed the interface methods.
The problem is that IntelliJ still thinks class constructor should take 4 arguments (the old interface) rather than 3 (new interface).
I can guarantee that the jar in the module dependencies is the new version. This is further confirmed by the fact that the code does successfully compile.
So my question is, why does IntelliJ still think I should have the old interface? Does it have some sort of cache that is not updating properly?
Attached screenshot demonstrates the problem.
Thanks.
Right-click on your project and select Refresh. Your project is using the compiled jar, which has changed, but your IDE is still using the old compiled jar as it was when it loaded it (even though the new source may be visible in the relevant project).
Eclipse has the same issue.
try move the cursor in the constructor, then press ctrl + b, it will jump to the declaration of constructor, which will get you a chance to double check if the constructor is correct or not.
also you can try "invalidate cache" under "file" menu, this will clear cache and rebuild index for your project.
Possibly IntelliJ's indexing info is out of date as it didn't notice that you switched a jar dependency.
This may be resolved at least by restarting the IDE, which then rescans and rebuilds indexes.
You can also remove all files from folders caches and index located for example here c:\Documents and Settings\User.IntelliJIdea\system\ (of course you may have another path) and try to start IDE again.
In IntelliJ I get this weird error when I try to compile.
Cannot find annotation method 'cascade()' in type 'javax.persistence.ManyToOne': class file for javax.persistence.ManyToOne not found
I know, it seems pretty obvious what the problem is, but having spent too much time on this problem I now turn my trust to you!
I use ideaCommunity-9, where I have created a global library for JBoss, which contains all JBoss jars including ejb3-persistence.jar. My module includes this library, and I have moved it to the top of dependencies.
No otherwhere in classpath I have a javax.persistence.ManyToOne class, and it also opens up in IntelliJ without problems.
If I open the file where I get the compile error, IntelliJ shows no problems and also navigates to the class file on pressing Ctrl+B.
The code is also build with ant and here it works fine.
Besides the above error I get six others along the same path (name in Table, etc.) - all related to JPA. I also get a message saying "Please file a bug to JDC yada yada yada."
Try to tick a checkbox "export" in your dependencies.
I mean: "File" menu -> Project Structure -> Modules -> Dependencies, and there you can see libs included to the module. You should also see a checkbox near each lib in column 'Export'.
Just got this myself but non of those things were my issue. I downloaded a project from github, then opened in intelli J with the problem after trying to run a junit test.
Solution: Project Structure -> Modules -> 'Project_Name' -> Sources (tab) -> click src folder -> Mark as: Sources
This should highlight src to be blue and all the class files should be the circles with C instead of looking like normal files. Try running a test again and see if that does it.
I'm sure, it is too late to answer, but I had to follow a different approach for this error to resolve this issue.
I had to create this as global library and add that library to the module, then only the error is resolved.
Isn't that similar to this SO question?
The solution there was to add all JBoss jar (which you did), but also all persistent-related libraries (like Hibernate)
See this JBoss project configuration for example:
alt text http://jdick.co.uk/blog/wp-content/uploads/2008/12/projectstructure1.jpg
In short, ejb3-persistence.jar might not be the problem here, just a symptom of other elements missing.
Or, if it is the problem, it may be related to the fact that it is not deployed correctly (for the WebApp configuration).
Here's an idea:
Maybe you have multiple versions of your jar file.
Search your folder hierarchy for the file ejb3-persistence.jar,
using a file management tool such as Total Commander.
Multiple appearances of the file in your classpath may confuse IntelliJ Idea
into not recognizing the proper class in the proper jar.
had a similar problem ("cannot find class spring...DefaultResourceLoader even though it was in my maven dependencies) and no amount of tweaking of revalidating caches seemed to help. Blowing away my $HOME/.Idea* paths and (basically) starting from scratch fixed it for me. At least for now...
I was getting the class not found error message when trying to execute a .groovy test class, which referenced a .groovy file (located in the root of the source directory of a submodule - i.e. no packages).
Moving the source file .groovy into a package, fixed the issue for me.
Move:
src/main/groovy/RunMe.groovy
to
src/main/groovy/somePackage/RunMe.groovy
In intelliJ I got this problem when I built (ctrl+shift+F9) at the file level.
The reason is, I had changes in other files in the same maven project, that were not getting picked.
I solved it by building at the project level (Select the Maven project in intellij and press ctrl+shift+F9)