The type com.liferay.petra.sql.dsl.query.DSLQuery cannot be resolved. It is indirectly referenced from required .class files - liferay-7

I am following a beginner's tutorial from here in order to create a service and then consume it from another module (eg. a Portlet)
Everything goes well until I try to deploy it - there is an error in the generated classes: The type com.liferay.petra.sql.dsl.query.DSLQuery cannot be resolved. It is indirectly referenced from required .class files

Locate build.gradle file and add the following dependency:
compileOnly group: "com.liferay", name: "com.liferay.petra.sql.dsl.api"
Note: you have to add it in both *-api and *-service build.gradle files

I prefer using a more generic way that will organize all Liferay related imports for you with just a single line:
compileOnly group: "com.liferay.portal", name: "release.portal.api", version: "7.3.5-ga6"

My workspace was working fine and next day when I started my system I faced problem that workspace is invalid, don't know what happened. I took new liferay workspace and then copy pasted my service builder then on deployment I faced this issue.
The type com.liferay.petra.sql.dsl.query.DSLQuery cannot be resolved. It is indirectly referenced from required .class files
I tried to add
compileOnly group: "com.liferay", name: "com.liferay.petra.sql.dsl.api"
but then facing new issue.
I don't think so this import would help, that is something else problem
Luckily I had my current workspace in zip format last week as a backup now again I m imported that zip and retried to build service again, now it is working fine.
thanks

Related

Eclipse Kotlin plugin not compiling Kotlin classes

Using Eclipse 2018.12, I've installed the Eclipse Kotlin plugin (0.8.20.20200316-1305), created a Kotlin project (using the "New..." options under "Kotlin") and wrote a "Hello World!" program:
Test.kt:
fun main() = System.out.println("Hello World!")
However, when I try to run it I get the message
Error: Could not find or load main class TestKt
Caused by: java.lang.ClassNotFoundException: TestKt
Upon further inspection it seems the class has never been compiled. There is no corresponding .class file anywhere. Under the project directory I see Eclipse configuration directory .settings and files .project and .classpath. Besides that, I have an empty bin directory and a src directory with Test.kt only.
I found two similar questions about this in SO:
In Unable to Run Kotlin Application in Eclipse, the accepted answer simply indicates working with a new version of Eclipse and Kotlin plugin, both older than what I have now. Besides, the problem may have been solved in that case due to a new installation rather than the version.
Kotlin - Error: Could not find or load main class _DefaultPackage is quite old and the accepted answer does not apply anymore. It was about not naming the main class properly, but in my case there is not even a byte code file to be found.
Running "Project -> Compile Kotlin classes" had no effect.
How can I get this simple example to run?
Update: I've updated to 2020-06 (not that it should matter since Eclipse Kotlin lists 2018-12 in its requirements) and replaced Zuly by AdoptOpenJDK HotSpotJDK 11. The error persists. The Eclipse log does not show any related messages.
Update 2: re-created the project in a brand-new workspace but the problem persists.

How to resolve reference to twirl generated template class in Scala-IDE?

Using twirl for generating template class. Everything is working fine with sbt and the webpages are rendering.
I am using Scala-IDE for development. And in the Scala-IDE the reference to the template class i.e. "html.test()", test is the template name, is showing as an error.
This is the error:
Description Resource Path Location Type
missing or invalid dependency detected while loading class file 'test.class'.
Could not access term api in value .twirl, because it (or its dependencies) are missing.
Check your build definition for missing or conflicting dependencies. (Re-run with -Ylog-classpath to see the problematic classpath.) A full rebuild may help if 'test.class' was compiled against an incompatible version of .twirl. ApiService.scala /api/src/main/scala/com/komma/api/rest line 97 Scala Problem.
I did a clean and it is giving "not found: value html" error now.
Is there any way to resolve this error in the scala IDE ?
Thanks.
Re-running sbt eclipse added target/scala-2.11/twirl/main as a source folder which resolved the compilation errors for me.
For my twirl configuration, sbt eclipse did not add the twirl output directory as a source folder. Adding
target/scala-2.11/twirl/main to the eclipse project build path through the Add Folder button, under Java Build Path, by hand, was my solution.

Eclipse JAR at runtime

I'm importing several JARs all sitting in the same directory. When my program runs I'm able to access the classes in several of those JARs, no problem. So my classpath is fine (I assume). But there is one JAR giving me trouble. When I try to run:
Configuration conf = new BaseConfiguration();
I get a NoClassDefFoundError error. The searching I did on "NoClassDefFound" typically points to classpath problems but as mentioned above, other JARs in the same directory are being found so I think that's not the problem.
This is in Eclipse 3.8.
The import statements:
import org.apache.commons.configuration.BaseConfiguration;
import org.apache.commons.configuration.Configuration;
And the name of the JAR is:
commons-configuration-1.6.jar
Any ideas?
Tom
Perhaps it's failing to load a dependency of one of the classes in commons-configuration-1.6.jar? Maybe from another commons- JAR? The NoClassDefFoundError should tell you which class the runtime failed to load. Have you checked this?

"Package HttpClient does not exist" when compiling

I am attempting to compile EWSJavaAPI1.5 in Eclipse and in IntelliJ. I have had no luck. I keep getting a org.apache.commons.httpclient does not exist error. Its driving me nuts. I added the four required files:
commons-codec-1.4.jar
commons-httpcliient-3.1.jar
commons-logging-1.1.1.jar
jcifs-1.3.15.jar
The four jar files are being referenced, yet it does not find the httpclient when compiling. It may have to do with the class path but I am not sure if I am adding it to the class path correctly. What to do?
Check that the library classpath is set correctly and this library is added to the dependencies of your module. Another possible case could be corrupted jar file, try to download it again.

Error in Eclipse about type indirectly referenced from required .class file

I'm having this exception with some stubs generateds by Axis2:
"The type org.apache.axiom.om.OMElement cannot be resolved. It is
indirectly referenced from required .class files"
I've been reading many posts, and trying to find a solution. What I've found so far is to add the apache tomcat 5.5 library to the build path. It removed the error in the java file, but then, when I to execute any java program inside the project, I got this error:
'Launching myApp' has encountered a problem Exception occurred
executing command line. Cannot run program "C:\Program
Files\Java\jdk1.5.0_22\bin\javaw.exe" (in directory
"D:\Digicel\workspace\Digicel\myClassSample"): CreateProcess error=87,
The parameter is incorrect
then if I remove the apache tomcat library from the build path, I can run the other java programs, but not the one mentioned initially.
Any thoughts about it?
Okay, I've found the cause of the problem with the help of a friend :)
The thing is that Eclipse is aware that one of my dependencies, depends of another library, and Eclipse is checking for it when it tries to build the code.
So, what I've done is try to check which jar file contains this library: " org.apache.axiom.om.OMElement".
I've googled it and found that it is "axiom-api-1.2.10.jar" and finally my file compiled with 0 errors.
He also explained to me that my original solution of adding the apache tomcat server library is adding all the jars that cames with apache tomcat (which is a big list), and probably there may have been a version conflict with my current list of added jars.
So, the fix was to find the appropriate jar and add it to the project.
This error can also occur when a indirect dependency has a corrupt jar file. This may be caused by problems at the public maven repository.
If this is the case removing the local maven repository to download fresh jar files will fix your problem:
rm -Rf ~/.m2/repository/{enter/path/to/broken/stuff}
Goto Maven >Update Maven project>checkmark the Force update >Then Run
..That error Will gone....