Couldn't find type java.sql.Date. Are you missing a dependency on your classpath? - mongodb

I'm trying to run my application in Spring Boot using MongoDB with spring-data but I can't because IntelliJ shows me this error during build:
Error:java: Couldn't find type java.sql.Date. Are you missing a
dependency on your classpath?
I'm using mongo java driver version 3.8.2, spring boot 2.1 and project is in Java 11. I have no idea what is wrong here could someone help me please?

Settings -> Build, Execution, Deployment -> Build Tools -> Maven/Gradle -> Runner -> tic on "Delegate IDE build/run actions"

IDEA > File > Settings > Build, Execution, Deployment > Compiler > Annotation Processors
click/select the module in which you're encountering the troubles (middle part of the settings window)
ensure "Obtain processors from project classpath" is ticked (unselect custom "Processor path" option)

the problem came from this settings:
Please uncheckUser'--release' option for cross-compilation(Java 9 and later), it's a common source of problem with the library Date

Related

How to fix the Error: "org.jetbrains.jps.incremental.scala.remote.ServerException java.lang.StackOverflowError"

I'm trying to run the main class in the scala-sbt project. Running the class is resulting in stackoverflow Error, StackTrace pasted below.
I am sure this is not a code Issue because for the same project I was able to run sbt package by setting the memory in sbt conf file as described here: https://stackoverflow.com/q/55874883.
I tried to set the params in Intellij> Settings> Scala Compile Server, but it didn't help to overcome Error.
JDK: Profile Default
Jvm maximum heap size, MB: 2024
JVM options: -server -Xmx2G -Xss20m -XX:MaxPermSize=1000m -XX:ReservedCodeCacheSize=1000m
IntelliJ:
IntelliJ IDEA 2019.1 (Community Edition)
Build #IC-191.6183.87, built on March 27, 2019
JRE: 1.8.0_202-release-1483-b39 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
Sbt Version: 1.2.8
Scala Version: 2.11.8
Error:scalac: Error: org.jetbrains.jps.incremental.scala.remote.ServerException
java.lang.StackOverflowError
at scala.tools.nsc.transform.TailCalls$TailCallElimination.transform(TailCalls.scala:273)
at scala.tools.nsc.transform.TailCalls$TailCallElimination.transform(TailCalls.scala:209)
at scala.tools.nsc.transform.TailCalls$TailCallElimination.noTailTransform(TailCalls.scala:214)
at scala.tools.nsc.transform.TailCalls$TailCallElimination.transform(TailCalls.scala:403)
at scala.tools.nsc.transform.TailCalls$TailCallElimination.transform(TailCalls.scala:209)
at scala.tools.nsc.transform.TailCalls$TailCallElimination.noTailTransform(TailCalls.scala:214)
at scala.tools.nsc.transform.TailCalls$TailCallElimination.transform(TailCalls.scala:403)
at scala.tools.nsc.transform.TailCalls$TailCallElimination.transform(TailCalls.scala:209)
redacted...
I've had the same issue with Intellij IDEA Ultimate 2020.1.1.
None of above options worked for me. But with a hint of the above answer, I found there was also different setting for the Scala compiler, after changing it the error stopped.
I increased the size of stack trace of the Scala compiler server: Preferences -> Compiler -> Scala Compiler -> Scala Compiler Server. Then, change the JVM options accordingly (In my case, -server -Xss1024m).
I've had the same issue with Intellij IDEA Community Edition 2019.3.4.
In the end, what worked for me was this solution. Basically, go to Settings -> Build, Execution, Deployment -> Compiler
Then, on "User-local build process VM options" set the stack size to a greater value with -Xss
In my case, I finally managed to run the tests setting it to -Xss2048m
I hope this helps.
Go to Configure → Edit Custom VM Options and add your changes there
If you're able to do sbt package (so you have sufficient heap size and -Xss configured for sbt) but running class still throws java.lang.StackOverflowError try going to
Settings -> Build, Execution, Deployment -> sbt
and tick
sbt shell -> use for: project reload and builds
try those options

Changes to kotlin class not recognized by Spring Boot?

Changes are not reflected in the service response from http://localhost:8080/hi after:
Modifying the response string of SomeController in the code below
Spring Tool Suite automatically compiles the changes
Spring Boot DevTools automatically restarts the server
Request to http://localhost:8080/hi still gives the old response
Somehow they're getting cached, even after running ./gradlew build manually.
Totally different issues: I have Java 1.8 JRE and JDK installed into two directories under Program Files\Java. The project shows the JRE dependency and running build from STS Gradle Tasks window yields the JRE instead of the JDK, even though JAVA_HOME is properly set to the JDK, STS is configured to use the JDK by default (JRE unchecked), and the Spring Boot Project is configured to use the workspace settings (JDK). It seems to be picking up the JRE from the IDE runtime itself, instead of from the settings? I found a work-around by right-clicking the build task and selecting build -> Open Gradle Run Configuration -> Java Home and manually setting this to the same directory as the JDK. I also found a workaround for the project with right-click on project Properties -> Java Build Path -> Libraries, removing JRE System Library and adding the JDK (Add Library... -> JRE System Library -> Workspace default JRE (jdk1.8.0_144)). But, sometimes the project resets itself to the JRE somehow.
Gradle Distribution: Gradle wrapper from target build
Gradle Version: 4.5.1
Java Home: C:\Program Files\Java\jre1.8.0_171
Code
package com.example.demo
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RestController
#RestController
class SomeController {
#GetMapping("/hi")
fun hi(): String {
return "hey"
}
}
#SpringBootApplication
open class DemoApplication
fun main(args: Array<String>) {
runApplication<DemoApplication>(*args)
}
Configuration
Windows 10 Pro
Spring Tool Suite 3.9.4.RELEASE
JDK 1.8
Kotlin 1.2.41
Gradle Wrapper 4.5.1
Spring Boot + DevTools 2.0.3.RELEASE
Setup Steps
New workspace in STS with Gradle Buildship and Kotlin extensions
Add JDK 1.8 as default
Create project File -> New -> Spring Starter Project
Gradle (Buildship 2.x)
Java 8
Kotlin
Reactive Web
DevTools
Actuator
Right-click project Configure Kotlin -> Add Kotlin Nature
Start service Boot Dashboard -> local -> demo [devtools] [:8080]

Error: Could not find or load main class while trying to run spark from eclipse(scala ide 4.3)

i have build the project using sbt and imported into eclipse . while trying to execute from run configuration i cannot find my main class and on running the application its prompted with the following error : could not find the main class.i have installed spark-hadoop version 1.4 and scala version 2.10.6 in the local machine also changed the scala compiler version to 2.10.6 in scala ide . The same error is produced while trying build spark from eclipse using maven . Please advice..
Check if Your main class in on build path.
Project -> Properties -> Java Build Path -> Source tab
If not add appropriate folder(s).
Add the folder where classes are generated to build path -> configure build path -> java build path -> source -> "Default Output Folder" text box.
Check if you have .scala files included in compilation path.
Even if you have the source folder included, it may be possible that .scala files are not being picked up.
The following might help, I was facing the same issue and it solved the problem for me:
build path -> configure build path -> java build path -> source -> add **/*.scala in the Included section.

I couldn't build Jhipster sample app

I'm trying to run Jhipster sample app in my Eclipse kepler . I've downloaded the project from here and I've imported it as existing maven project but it couldn't be build . I got this exception :
The type java.util.Optional cannot be resolved. It is indirectly referenced from required .class files AccountResource.java
and many "Undefined CSS file" errors
how can I run this project in my Eclipse ?
Normally you should create your application using the yeoman generator. Install yeoman and execute yo jhipster from your command line.
a)For the java exception basically you need to remove the old version of java from your build path and add support for java 8.
You need to follow these steps
1) Right-click on project » Properties » Java Build Path
2) Select Libraries tab
3) Find the JRE System Library and remove it
4) Click Add Library... button at right side » Add the JRE System Library(Workspace default JRE)
Do not forget to set the Java jdk compiler compliance level to 1.8 (Preference -> Java -> compiler )
b) The jhipster site mentions about the configuration settings(css,javascript and html etc)for eclipse to avoid errors in eclipe. https://jhipster.github.io/configuring_ide_eclipse.html

How do I find the correct Maven archetype project for developing with Scala in Eclipse?

I'm having problems trying to just create a Maven project using Scala (v2.11.6) within Eclipse (Luna). The instructions here says to install both plugins below.
Maven Integration in Eclipse
m2eclipse-scala connector
Both plugins can be installed by using the m2eclipse-scala update site. So here's what I did in my first attempt.
Download Eclipse Luna (for JavaEE developers)
Install "both" plugins above by using the m2eclipse-scala update site.
When Eclipse loads up, I attempt to create a Maven project, and the archetype I want to use is Group Id=net.alchim31.maven, Artifact Id=scala-archetype-simple, Version=1.5. However, this archetype never shows up when I enter in "scala-arch" in the filter text field.
The only project I see is the one with Group Id=org.scala-tools.archetypes, Artifact Id=scala-archetype-simple, Version=1.2. When I select this archetype to use, I get a bunch of error messages in Eclipse.
error while loading ConsoleRunner, Scala signature ConsoleRunner has wrong version expected: 5.0 found: 4.1 in ConsoleRunner.class
error while loading JUnit4, Scala signature JUnit4 has wrong version expected: 5.0 found: 4.1 in JUnit4.class
error while loading Specification, Scala signature Specification has wrong version expected: 5.0 found: 4.1 in Specification.class
In my second attempt, I try to download the pre-packaged bundle (Scala IDE for Eclipse). Again, when I attempt to create a Scala Maven project, I don't see the Maven archetype for Group Id=net.alchim31.maven (only for Group Id=org.scala-tools.archetypes).
Any ideas on what I'm doing wrong here? Or where I can find a vanilla Scala Maven project to import/modify and use for my own purpose?
Here's how I got it to work. It seems all the archetypes aren't available, so based on this answer, I created a remote catalog
Before
So do this
Go to [Windows] → [Preferences] → [Maven] → [Archetypes] → Add Remote Catalog and create the catalog, then Apply
For copy-pasting:
Catalog File: http://repo1.maven.org/maven2/archetype-catalog.xml
Description: Remote Archetypes
Go back to creating a new Maven project. Select the Remote Catalog from the dropdown. It will take a few moments to gather all the archetypes. You can see the progress at the very bottom right of the IDE. When it's done, you should be able to see the archetypes
After
Create your project with groupId and artifactId and such.
Right click the project, then from the context menu [Run As] &rarr [Maven Build]. In the dialog, type clean package into the goals. The run. The project should build and run the tests.
For me at first I got an error on the build. It was because my default environment is using Java 8. I'm pretty new to Scala, so I'm not sure is there is a problem with Scala and Java 8 or not (I think it's the Scala version in the pom (2.10.0)). But what I did to get it to work was just change the Java version used in the IDE to Java 7.
Basically just go to [Windows] → [Preferenes] → [Java] → [Installed JREs] → Add → [System VM] → Next → Directory → Find the directory of the Java home (version 7) → Finish → Then in the list tick Java 7.
Then build again. It should work. Good Luck!
One point I want to add, If you are getting following error while installing the archetype showed in image 1
Can't resolve Archetype
org.glassfish.jersey.archetypes:jersey-quickstart-webapp:2.21
org.eclipse.core.runtime.CoreException: Could not resolve artifact
org.glassfish.jersey.archetypes:jersey-quickstart-webapp:pom:2.21
Image 1:
Then before procedding with the solution specified above, try to complete these steps in eclipse.
I faced the same problem and chanced upon this SO question, as well as the answer, given by #peeskillet (many thanks). I am using:
Maven 3.3.3
Eclipse Luna Scala IDE 4.0.0.-vfinal-20150305-1644-Typesafe
Scala 2.11.6
JDK 1.8
After following the steps exactly as given here, I hit a wall. When I chose the right archetype (net.alchim31.maven), I was greeted with this error:
Could not resolve artifact net.alchim31.maven:scala-archetype-simple:pom:1.5
Suspecting that the maven embedded in eclipse was acting funny, I visited [Windows] -> [Maven] -> [Installations] and added local installation of maven (whatever is set to M2_HOME in my shell). But, no luck!
Exasperated, I visited this site: Scala Doc and switched back to command-line as this page instructs. Surprisingly (to me, at least), it worked. A maven-Scala project was created in the present directory, which I could import into Eclipse.
Just so that I am not misunderstood, I am not suggesting that #peeskillet's answer is wrong. Just wanted to share another way of creating a maven-scala project on Eclipse, in case it helps someone. I have not yet understood, why Eclipse-Scala-IDE is yet to give that 'Aha' feeling.
After you have successfully created the scala-maven project as described above, you will probably see an error "Type not found: type JUnitRunner specs.scala". In that case, manually add the following XML snippet to your pom.
<dependency>
<groupId>org.specs2</groupId>
<artifactId>specs2-junit_${scala.compat.version}</artifactId>
<version>2.4.16</version>
<scope>test</scope>
</dependency>
Moreover, to avoid errors when running mvn test,
[ERROR] scalac error: bad option: '-make:transitive'
You also need to delete the following line from the pom.xml file:
<arg>-make:transitive</arg>