I have a project that I'm trying to play around with the Immutables Criteria: https://immutables.github.io/criteria.html
I added the following to my pom.xml:
<dependency>
<groupId>org.immutables</groupId>
<artifactId>criteria-inmemory</artifactId>
<version>2.8.2</version>
</dependency>
Everything seemed fine. However, I am having some issues getting things imported and working. I have no issues with Immutables.Value that works fine. When I import Criteria Eclipse complains about:
The type org.immutables.criteria.Criteria is not accessible
So I tried adding the module to my module-info.java as follows:
requires org.immutables.criteria-common;
Also tried:
requires org.immutables.criteria-inmemory;
I'm using Eclipse suggestions to auto-complete the module name because I don't really know what the module name should be but, when I add the above Eclipse says there is a syntax error with the "-" in the requires statement. So at this point I am kinda stuck! If anyone has any suggestions I would love to hear them!
Thanks!!
I was able to track down the issue with the Immutables Library and I posted the following issue: https://github.com/immutables/immutables/issues/1223
Basically, the library was creating an invalid Automatic-Module-Name tag in there pom.xml's when building the jar files. The values that we being set contained a "-" which is invalid.
Shoutout to #Naman for pointing me in the right direction! Thanks!
I am still wondering if it is possible to override the jar files module-name. It seems like it could be useful for users of a library to somehow override a libraries jar files module-name for situations like this.
from the beginning, while trying to deploy a war under Jetty, I have an error, and in order to understand from where the error is comming, I would like to put a breakpoint in a class (SimpleCDI) located in a dependency (a jar which is downloaded by MAVEN). I work under MAC and when I hit Command + Shift + T and look up "SimpleCDI" class, it points that the class is within org.jboss.weld package
Here is a printscreen of my research
And when I click on the "C SimpleCDI org.jboss.weld" line, it returns an error message
org.eclipse.core.runtime.CoreException: The class file is not on the classpath
at org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditor.doSetInput(ClassFileEditor.java:694)
at org.eclipse.ui.texteditor.AbstractTextEditor$5.run(AbstractTextEditor.java:3154)
at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:437)
at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:353)
at org.eclipse.ui.internal.WorkbenchWindow$14.run(WorkbenchWindow.java:2195)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:2191)
at org.eclipse.ui.texteditor.AbstractTextEditor.internalInit(AbstractTextEditor.java:3172)
I checked that I have the right dependency (weld-servlet-2.4.5.Final.jar) with
SimpleCDI" in it.
I noticed that the eclipse icon of my dependency "weld-servlet-2.4.5.Final.jar" is the following
It is a jar file without attached source. Actually, I can see this dependency in Eclipse in one of my module "Tourism-Services" (I have a Maven multi module project) in the "Referenced Librairies" folder with the icon mentioned above, but the Maven dependency that import this jar is located in another module "Tourism-Core" which is imported itself in "Tourism-Services" module. I notice in passing that I cannot see "weld-servlet-2.4.5.Final.jar" in "Referenced Librairies" folder of "Tourism-Core" module (why ?)
My main question is : why cannot I edit "SimpleCDI" class and put a breakpoint in order to debug upstream
I've also been using the CodeMix plugin, have you tried to remove the Open Type binding from the CodeMix preferences? Preferences -> Codemix -> Bindings. From there uncheck the "Open Types on COMMAND+SHIFT+T" and do apply and close. This will get you to use the regular Open Java Type from Eclipse.
Cheers
a plugin was causing the error. It is CodeMix plugin
I tried to uninstall it : help->Eclipse Marketplace->Installed
I obtain the following screen
I chose uninstall in the dropDown
But it doesn't work.
I have found a workaround : https://www.genuitec.com/forums/topic/uninstall-codemix/
But it is temporary. I tried to find CodeMix in Eclipse plugin folder (I work under MAC), but there is nothing. Do you see another way ?
I've added following into dependencies section of my pom.xml:
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.4.1</version>
<scope>test</scope>
</dependency>
But when I add the 1st line of "Quick start guide" (http://hc.apache.org/httpcomponents-client-4.4.x/quickstart.html):
CloseableHttpClient httpclient = HttpClients.createDefault();
IntelliJ IDEA highlights "HttpClients" and tells me:
Cannot resolve symbol 'HttpClients'
It looks like I have mistake with configuration. What exactly is wrong? please advise how to add support for HttpClients into the project?
Thanks!
P.S. Learned a bit more, looks like "" is redundant and wrong for this case, I removed it but that didn't help: still non-compilable.
EDIT: If I put cursor to 'HttpClients' and hit "Alt-enter" the pop-up doesn't contain any class to import. See screenshot:
It looks like my IntelliJ had issues with caching, cleaning cache with following re-importing of the project helped.
I found tips on that here: IntelliJ inspection gives "Cannot resolve symbol" but still compiles code
P.S. Though few other project were broken as a result of this action. Looks like I need to keep learning :)
Download the jar file from
https://jar-download.com/artifacts/org.apache.httpcomponents/httpclient/4.5.6/source-code
Extract the .jar file name httpclient-4.5.6.jar. Form a directry name lib under your project and import this .jar file to it. Right click your .jar file and click addtolibrary.
I have a problem setting gradle project with absolute paths of already existing java projects.
So, I have a new gradle project admin-tool, but somewhere on my file-system I have existing java eclipse projects say ejb-services, dao-services (which are not gradle projects) so I want to integrate them in my new gradle project.
Is there any solution, that will give me freedom ejb-services and dao-services projects to be on any file-system location and integrate them in my new gradle project.
I have try with
project("dao-services").path = new File(/*absolute path*/)
include "dao-services","admin-tool"
also
project("dao-services").projectDir = new File(/* absolute path */)
include "dao-services","admin-tool"
But they all give me error that project dao-services could not be found.
From what I have search it's seems to me that gradle only uses relative paths to root project and you can't go out that scope, but I haven't found any information regarding this to be sure.
Best Regard and thanks in advance
You forgot about the ':' in the module name, as in the
project(":dao-services")
I'm working on a simple JSP/Servlet/Tomcat webapp for my class. The professor asked us to use a folder structure that is slightly different than the default dynamic web project structure. Rather than using the webcontent folder he wants all of our source code under src/main/java and src/main/webapp.
When I run the app my welcome file displays fine, but when I try to access my servlets I get:
Http 500 SEVERE: Allocate exception for servlet InitDb
java.lang.ClassNotFoundException. I'm pretty sure it's a build path error. I have final/src on the build path but I am receiving the warning
"Cannot nest 'final/src/main/webapp/WEB-INF/classes' inside 'final/src'. To enable the nesting exclude 'main/' from 'final/src'
I have this in my deployment assembly:
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
When I exclude main/ the warning goes away, but it doesn't fix the problem. I would appreciate any advice. Thanks.
I had the same problem even when I created a fresh project.
I was creating the Java project within Eclipse, then mavenize it, then going into java build path properties removing src/ and adding src/main/java and src/test/java. When I run Maven update it used to give nested path error.
Then I finally realized -because I had not seen that entry before- there is a <sourceDirectory>src</sourceDirectory> line in pom file written when I mavenize it. It was resolved after removing it.
I wanted to throw in a non-mavenish answer to this thread.
Due to version control and strict directory structure reasons, I was unable to follow Acheron's answer (the best answer) of doing something similar to removing src/ and adding src/main/java and src/test/java to the build path.
I had actually been off-and-on battling this nested build path issue for a couple weeks. The answer to the problem is hinted in the error message:
To enable the nesting exclude 'main/' from 'final/src'
Fix
In your build path, you need to edit your Inclusion and Exclusion Patterns by clicking on Excluded: (None) and then Edit...:
Go to the navigator and press right click on the project
Build Path
Configure Build Path
Source (tab)
There you can add main/webapp/WEB-INF/classes as an Exclusion Pattern. Then it should allow you to add main/webapp/WEB-INF/classes to the build path as a separate source folder.
Here is a simple solution:
Right click the project >> properties >> build path;
In Source tab, Select all the source folders;
Remove them;
Right click on project, Maven >> Update the project.
Try this:
From the libraries tab:
Eclipse -> right click on project name in sidebar -> configure build path -> Libraries
Remove your web app libraries:
click on "Web App Libraries" -> click "remove"
Add them back in:
click "Add Library" -> click to highlight "Web App Libraries" -> click "next" -> confirm your desired project is the selected option -> click "Finish"
Highlighting "Web App Libraries":
I had the same issue and correct answer above did not work for me. What I did to resolve it was to go to Build Path->Configure Build Path and under the source tab I removed all the sources (which only had one source) and reconfigured them from there. I ended up removing the project from eclipse and import the maven project again in order to clear up the error.
In my case I have a gradle nature project in eclipse, the problem was in a build.gradle, where this sourceSets is specified:
sourceSets {
main {
java {
srcDir 'src'
}
}
}
This seems to works well with intelliJ,however seems than eclipse doesn't like nest src, src/java, src/resources. In eclipse I must change it to:
sourceSets {
main {
java {
srcDir 'src/main/java'
}
}
}
You have to separate your sources and your target directory where the build output goes. It's also important to note that no class files ever can end up in the source directory. This is not against your professor's advice - actually he's promoting the maven standard source structure going for ./src/main/java and ./src/main/webapp. The second one should hold eg. the mandatory WEB-INF/web.xml file but you will never put actual classes there.
What you need to change is your target directory. I suggest going with the same standards and choosing the name "./target" for this. All the built files will go in here and packaging that up will result a correct deployable artifact. Should you migrate to using maven later, it'll also help doing this in a scripted, repeatable way.
Hope that clears up your issue.
The accepted solution didn't work for me but I did some digging on the project settings.
The following solution fixed it for me at least IF you are using a Dynamic Web Project:
Right click on the project then properties. (or alt-enter on the project)
Under Deployment Assembly remove "src".
You should be able to add the src/main/java. It also automatically adds it to Deployment Assembly.
Caveat: If you added a src/test/java note that it also adds it to Deployment Assembly. Generally, you don't need this. You may remove it.
This started taking me down a huge rabbit hole of fixing glitches with Eclipse, however I just deleted the project from Eclipse and reimported it to fix it.
Got similar issue. Did following steps, issue resolved:
Remove project in eclipse.
Delete .Project file and . Settings folder.
Import project as existing maven project again to eclipse.
For Eclipse compiler to work properly you need to remove final/src from the source path and add final/src/main/java instead. This may also solve your problem as now the build directory won't be inside the Java source folder.
It depends on which folder one is telling "Use as Source Folder" to. In the structure on the picture if one says it to the folder "target" or "generated", he gets the "nested" error. But on "cxf" folder, which is the last, mentioned in the pom.xml's 'plugin' section and where from the package structure begins (as shown on .wsdl file), i.e. - the right folder to do it 'source' one, then there is no error
If other solutions did not work and you are using any plugin adding sources in your pom.xml check it. I used build-helper-maven-plugin to add classes generated from openapi specification with incorrect configuration:
<source>${project.build.directory}/generated-sources/openapi/src</source>
instead of correct:
<source>${project.build.directory}/generated-sources/openapi/src/main/java/</source>
So after correcting:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/openapi/src</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
Make two folders: final/src/ to store the source java code, and
final/WebRoot/.
You cannot put the source and the webroot together. I think you may misunderstand your teacher.