Liferay 6.2 GA5: error with building services - java

I'm trying to do some modification to the service layer of my portlet (e.g adding a column or a finder to a table in the service.xml). No matter what I do, when I build services it all goes good(no errors) but when I try to deploy or make the war, many errors appear. In this case I was just adding a new column (note2) to an already existent table
The method getNote2() is undefined for the type ESFShooterAffiliationChrono
or this:
The method getNote2() of type ESFShooterAffiliationChronoModelImpl must override or implement a supertype method
I'm working on Eclipse Luna 4.4.0, liferay IDE 3.1.2, Java JDK 1.7.0 67. I've set Compliance to 1.7 in eclipse and both "ant.build.javac.source" " ant.build.javac.target" to 1.7 in build.properties.
I think there must be something wrong with the service builder. I tried starting over with a new workspace and a fresh Plugin SDK, even with the 6.2 GA6 but with no avail. I've also tried deleting all generated service class before doing the service build but without success.
Can you give me any advice on how to solve this?

Most likely, you have some old code around and embedded in your dependencies. Search for a -service.jar named after your plugin, e.g. your-portlet-service.jar.
This might also happen when both a your-portlet-service.jar and the WEB-INF/services folder are on your build path. The compiler and the editor might pick up different versions. And when you build through Ant, Ant might pick a third variation for the precedence.
Check your eclipse and your Ant build path.

Related

SpringToolSuite is unable to recognize spring boot annotations

I got a project from GitHub which is a Java spring boot application running with Maven dependencies.
I am so confused why I can't run the application successfully on STS.
There's no longer a problem on my old laptop. Because I just changed my laptop, this problem only occurred on this laptop.
The details / symptoms of the issue are:
When I typed "SpringToolSuite" on my start panel, no applications were being recognized. So I have to open STS manually from Downloads (ie. its original file location). But anyways, it is just a minor issue.
In STS, annotations such as the lombok log and most of the getter/setter methods were unrecognized.
Failed to perform "Run as Spring Boot App" from STS, but it is successful when I tried to perform "mvn clean install" to create a Maven build from command prompt.
Error message: "log cannot be resolved"
I tried finding results from other posts here but to no avail.
The steps that I import the project is:
Create another folder as the workspace.
Open STS by selecting the created folder as the workspace.
Click File > Import and import as existing Maven project (as it is a Maven-built application).
I also tried to create a Maven build from command prompt, which is successful eventually.
As the situation was so strange here, please advise further what I can do. Thanks.
Lombok has a plugin for Eclipse (and therefore STS as well) that enhances the IDE with direct support for Lombok: https://projectlombok.org/setup/eclipse
Without that extension the IDE is not really able to recognize and support Lombok.
Thanks so much for your suggestions.
First of all, I've made sure my STS the latest version. I installed it from the official site https://spring.io/tools.
I downloaded the Windows one. See image.
I executed the spring-tool-suite-4-4.16.1.RELEASE-e4.25.0-win32.win32.x86_64.self-extracting.jar file afterwards. A folder with STS application inside has been generated.
Referring to your second question, I am sure I have the lombok dependency.
This is part of my pom.xml. See image.
I also performed again the "mvn clean install". It is success and error-free.
Fyi, I also make sure every setup is right, such as:
It is pointing to the same java version as what Maven points to.
In STS, the Java compliance level is the same as the java version I defined in PATH environment variable.
Also in STS, the Installed JRE is pointing to the right folder.
But as the STS is still not recognizing Spring Boot annotations. That's why it seems weird here. For example, logs are underlined red with an error message on the IDE. Getters and Setters of #Data fields are not implicitly referenced with that spring boot annotation since they're also underlined with error.

How do I get Netbeans to use the specified Gradle version?

I've come back to project after a long diversion, and upgraded tooling. This means Netbeans 12.5, Java 17, Gradle 7.3… at least allegedly. For some reason, despite setting the Gradle version to 7.3, it appears to build with 7.0.
Per the image below, setting the Gradle version to 7.3 doesn't seem to be picked up. (That is immediately after hitting Apply.) It still tries to build with 7.0. And – for some indeterminate reason – it can't.
Restarts don't help; I can't get the configuration to be picked up. (Searches for reference to similar issues provide 5-year-old answers that are no longer relevant.) I've even tried deleting the 7.0 distribution; to no avail, it comes right back.
Can anyone provide guidance on getting this to work properly?
Netbeans 12.6 fully supports Java 17 and Gradle 7.3. Gonfiguring the Gradle wrapper for 7.3 gets picked up correctly, eliminating all errors I was experiencing.
Don't bother with gradle in Netbeans. It's a horrible, buggy disaster and 12.6 just seems to want to up the ante.
Netbeans does NOT support gradle in a meaningful way for normal users.
You now get complex multi-projects whether you want them or not.
When creating a Java Application you don't get a choice at what the Main class is called. It will be App with app.java and you will like it.
If you try to rename app.java to something useful. It will not change "Class App" to "Class Useful" it will instead change it to "ClassUsefulp". It will not rename the test file and you will be left with several syntax errors that you can have fun cleaning up.
No, you cannot rename the subproject itself. That will continue to be the extremely descriptive and useful "app" subproject. The IDE will not provide you a way to rename that.
There is no meaningful, intuitive way to create/delete/modify subprojects.
If your gradle version is somehow out of sync there is still no useful way to reset/recreate the gradle wrapper other than creating a whole new project and moving your source code over to the new project.
Oh, so you gave in and accepted the multi-project structure. You noticed that if you go through the multi-project creator GUI then you can create multiple subprojects. Yeah, good luck with that. They won't have gradle build.scripts or wrappers. You won't be able to build your awesome creation.
Want to use command line arguments? Forget it. There is no "run" element in the project properties. You cannot create different run configurations.
Want dependencies? Or any other project configuration? It's all manual editing of gradle files. There's no GUI to assist non-gradle-wizards.
Yeah. you can probably work around a lot of this by dropping to a command line shell and editing the gradle scripts/files manually and running gradle commands manually. A) you're going to need to be a gradle wizard, and B) why are you using an IDE in the first place? you've got gradle, you've got vi available. Bathe in the nostalgia because you'll have to anyways.
Do you like the idea of gradle? Do you use Netbeans? Stick with Ant, or Maven if you need external dependencies; you'll thank me later.

Cloning Eclipse project from BitBucket causes unexpected code errors

I have uploaded my Eclipse project to BitBucket and decided to test how the cloning function works as I am quite new to using repositories. So I deleted the project from Eclipse and then used the "Clone a Git Repository" function to import my project back into Eclipse which worked correctly. However, there are now a few errors that pop-up in my code (errors that did not exist before) and I am trying to figure out what is causing this. Specifically:
- The method getSubmittedFileName() is undefined for the type Part
- The type ActiveSessionListener must implement the inherited abstract method HttpSessionListener.sessionCreated(HttpSessionEvent)
I thought it might be caused by using an older version than Servlet 3.0 but that doesn't appear to be the case (it's configured to Servlet 3.1 as shown in the screenshot below). What could be causing these unexpected errors in my code and how can I resolve this?
From this question, this is a Tomcat version issue.
Do check your Targeted Runtimes and Java Build Path, in order to reference Apache Tomcat v7.0.

Frege can't find classes in referenced project or external jar

I think I'm making a simple mistake here, but I can't get Frege to find any classes outside of the local Eclipse project.
I have a working non-trivial Java project (that's not mine), that I do not want to modify. I want to have a new clean Frege enabled project that makes use of classes from the original project.
I tried marking the original project as a dependency of my Frege project, and I tried packaging the original project into a JAR, and listing the JAR as an external dependency of the Frege project. In both cases, a Java file in the Frege project can access the classes, but the Frege compiler says "class org.foo.bar.Class is not a known Java class". This seems like a bug, but I am not confident that I have not missed a simple configuration step.
I have not tried setting arguments in the project configuration as I wouldn't know what to set.
I did quickly discover that I can make a new Java file in the Frege project with a blank subclass of whatever class I need and use that in a Frege file. I have successfully compiled and run a simple program like this. The program just makes a new object, gets a field, and prints the correct value, so I believe my Frege is installed and working properly.
More info:
Eclipse Luna 4.4.0
Java 7
No Maven
Official eclipse-ferge plugin installed through Eclipse
It should be enough to have your library listed in the build path and under "Referenced Libraries". Your recent comment indicates that the compiler does indeed find the class in question.
However, when you have an open editor tab it will not take notice of changed dependencies. Also, especially in recent eclipse versions I have observed that resolved error markers are sometimes not cleaned up correctly.
Please close the editor tab that has the false errors shown, and reopen it.

eclipse external tools configurations -> referenced library in classpath does not exist: org.eclipse.swt

After updating to the latest eclipse mars release
Version: Mars Release Candidate 1 (4.5.0RC1)
Build id: 20150521-1252
I am not able to start any Ant Script. It always results in the following error:
First I checked if the path is really correct, and made sure that the specific jar org.eclipse.swt.win32.win32.x86_64_3.104.0.v20150513-1901.jar exists at the given location, which it does. After some digging I noticed the following within the external tools configurations:
Somehow I think eclipse is not able to resolve the classpath with the given '%20' tag within the url to the library. Usually there is just a blank. Restoring the defaults always fills in the '%20' for this specific library.
So I created a copy of eclipse at a location without blanks and all works fine again.
Unfortunatly I would prefer keeping the location at it is, so is there a way to correctly resolve the classpath for Additional Tasks & Support?
There is one other "fix" that's basically an easier workaround.
If you go to your Ant build configuration (under External Tools, then highlight your configuration and select the JRE tab) and change from running an external JRE to the top button, that is, "Run in the same JRE as the workspace", this will make it work.
This is a known bug in Eclipse Mars:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=470390
Update: Eclipse 4.5.1 was released on October the 2nd and the bug has been fixed. An Eclipse update will resolve this issue.
I resolved this by moving C:\Program Files\eclipse to C:\eclipse
Answer also found here, Eclipse Mars: ANT Task references missing SWT library

Categories