I am trying to run a project generated using jhipster. I opted to use Spring Websockets while generating the project. However on running the mvn command on the folder. I get the following error:
[ERROR] diagnostic: C:\java_dev\workspaces\pmilive\pmi\trunk\src\main\java\id\co\allianz\pension\config\WebsocketSecurityConfiguration.java:10: error:
cannot access org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer
public class WebsocketSecurityConfiguration extends AbstractSecurityWebSocketMessageBrokerConfigurer {
^
class file for org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer not found
[ERROR] error on execute: error during compilation
Is there any other additional setting that I should add?
No nothing special is required, I suspect that you had an error during maven dependency resolution phase. maybe something is wrong in your ~/.m2 local repository: try deleting ~/.m2/respository/org/springframework and re-run mvn.
If you're on Windows, path is %USERPROFILE%\.m2\repository\org\springframework.
Related
I have a Intellij plugin project that I can successfully build without using the PsiMethod class. I've generated this project using this intellij plugin guide
As soon as I add in code using PsiMethod class
(from the Intellij SDK code_samples directory)
The intellisense cannot find any GOTO information for the class.
I can then switch my project settings module from JAVA_1.8.0 to
by adding it into the platform settings SDKs:
This now adds intellisense, and gives me the ability to navigate to the PsiMethod class by CMD+click.
However, If I try and run my "plugin" gradle configratuion. it halts with an error running :runIde.
Running compileJava command from bash I get:
$ ./gradlew compileJava
> Task :compileJava FAILED
/Users/cody/IdeaProjects/plugintest/src/main/java/com/plugintest/TestClass.java:104: error: cannot find symbol
PsiMethod containingMethod = PsiTreeUtil.getParentOfType(element, PsiMethod.class);
^
symbol: class PsiMethod
location: class ParticleContainerManager
/Users/cody/IdeaProjects/plugintest/src/main/java/com/plugintest/TestClass.java:104: error: cannot find symbol
PsiMethod containingMethod = PsiTreeUtil.getParentOfType(element, PsiMethod.class);
^
symbol: class PsiMethod
location: class ParticleContainerManager
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 errors
The gradle source sets in intellij are as follows:
And when I CMD+Click the PsiMethod class, it shows the following JAR source:
This source is in the following parent folder:
How can I add this source into my gradle configuration? shouldn't it be autodetecting what my projects intellisense is tapping into?
Do I need to change something in the gradle.* files inside the project directory?
EDIT:
Using Yann's Answer:
I've added the following line to my build.gradle file:
intellij {
version '2019.2'
plugins 'java'
}
and it works!
Please make sure to add Java plugin as separate dependency. This is now necessary starting with 2019.2: https://blog.jetbrains.com/platform/2019/06/java-functionality-extracted-as-a-plugin/
I am using the Play framework (which uses SBT build tool) with Java where I need to consume a Protobuf. So I have xxx.proto file. I got binary protoc compiler and added to class path. so I see -
protoc --version
libprotoc 3.1.0
I have compiled the xxx.proto file using -
protoc -I=$SRC_DIR --java_out=$DST_DIR $SRC_DIR/xxx.proto so it has generated xxx.java file.
Now when I am compiling this xxx.java file ( the project using sbt build tool)
[error] /my_project/app/helpers/xxx.java:7: package com.google.protobuf does not exist
[error] com.google.protobuf.ExtensionRegistryLite
[error] /my_project/app/helpers/xxx.java:11: package com.google.protobuf does not exist
[error] com.google.protobuf.ExtensionRegistry
[error] /my_project/app/helpers/xxx.java:6182: package com.google.protobuf.Descriptors does not exist
[error] com.google.protobuf.Descriptors.Descriptor
[error] /my_project/app/helpers/xxx.java:6185: package com.google.protobuf.GeneratedMessageV3 does not exist
[error] com.google.protobuf.GeneratedMessageV3.FieldAccessorTable`
I see in my installed library - com.google.protobuf jar is there.
My xxx.proto looks following -
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: xxx.proto
public final class xxx {
private xxx() {}
public static void registerAllExtensions(
com.google.protobuf.ExtensionRegistryLite registry) {
}
public static void registerAllExtensions(
com.google.protobuf.ExtensionRegistry registry) {
registerAllExtensions(
(com.google.protobuf.ExtensionRegistryLite) registry);
}
......
Is there anything I have missed while generating the xxx.java file?
How should I fix these compilation error?
You need to make sure that you're using the exact same versions of protoc and libprotobuf.jar. From what you wrote, it sounds like you're using protoc version 3.1.0 but libprotobuf 2.5.0. You need to use libprotobuf 3.1.0 instead, otherwise you will get compile errors like the ones you quote.
Re-stating Kenton's answer with some more instructions:
In Intellij, click on External Libraries and find the jar for protobuf.
Check the version of protoc:
If they don't match, (as shown above) then you will get the compilation errors.
I've seen similar issue with maven after changing some field type in my proto schema and then building without doing a clean first. However, doing a clean and build fixed it every time.
I have Issue with using database
I was going with this tutorial
http://vimeo.com/58969923# (one from playframework.com page)
in the model:
play-2.2.1/jcirs/app/models/MedicalIncident.java
public class MedicalIncident extends Model{}
I am trying to use Entity. For that I have to import:
javax.persistence.* and play.db.ebean.*
but none of them can be found.
The error is
package javax.persistence does not exist
What should I do?
Use any other database engine? Or should download some dependency.
I would like to go with playframework best way.
Please help.
My configuration
application.conf:
db.default.driver=org.h2.Driver
db.default.url="jdbc:h2:mem:play"
ebean.default="models.*"
stack trace:
[jcirs] $ run 8081
--- (Running the application from SBT, auto-reloading is enabled) ---
[info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:8081
(Server started, use Ctrl+D to stop and go back to the console...)
[info] Compiling 5 Scala sources and 5 Java sources to /home/daniel/play-2.2.1/jcirs/target/scala-2.10/classes...
[error] /home/daniel/play-2.2.1/jcirs/app/models/MedicalIncident.java:4: error: package javax.persistence does not exist
[error] import javax.persistence.*;
[error] ^
[error] /home/daniel/play-2.2.1/jcirs/app/models/MedicalIncident.java:6: error: package play.db.ebean does not exist
[error] import play.db.ebean.*;
[error] ^
[error] /home/daniel/play-2.2.1/jcirs/app/models/MedicalIncident.java:14: error: cannot find symbol
[error] public class MedicalIncident extends Model {
[error] ^
[error] symbol: class Model
[error] /home/daniel/play-2.2.1/jcirs/app/models/MedicalIncident.java:13: error: cannot find symbol
[error] #Entity
[error] ^
[error] symbol: class Entity
[error] /home/daniel/play-2.2.1/jcirs/app/models/MedicalIncident.java:15: error: cannot find symbol
[error] #id
[error] ^
[error] symbol: class id
[error] location: class MedicalIncident
[error] /home/daniel/play-2.2.1/jcirs/app/controllers/MedicalIncident.java:21: error: cannot find symbol
[error] MedicalIncident medical_incident = Form.form(MedicalIncident.class).bindFormRequest().get();
[error] ^
[error] symbol: variable Form
[error] location: class MedicalIncident
[error] 6 errors
[error] (compile:compile) javac returned nonzero exit code
[error] application -
! #6gfjpj0cf - Internal server error, for (GET) [/] ->
play.PlayExceptions$CompilationException: Compilation error[error: package javax.persistence does not exist]
at play.PlayReloader$$anon$1$$anonfun$reload$2$$anonfun$apply$14$$anonfun$apply$16.apply(PlayReloader.scala:304) ~[na:na]
at play.PlayReloader$$anon$1$$anonfun$reload$2$$anonfun$apply$14$$anonfun$apply$16.apply(PlayReloader.scala:304) ~[na:na]
at scala.Option.map(Option.scala:145) ~[scala-library.jar:na]
at play.PlayReloader$$anon$1$$anonfun$reload$2$$anonfun$apply$14.apply(PlayReloader.scala:304) ~[na:na]
at play.PlayReloader$$anon$1$$anonfun$reload$2$$anonfun$apply$14.apply(PlayReloader.scala:298) ~[na:na]
at scala.Option.map(Option.scala:145) ~[scala-library.jar:na]
[warn] play - No application found at invoker init
Have you updated your project dependencies in Build.scala?
Not sure if anything has changed in Play 2.2.1 but for Play 2.1.3 dependencies in Build.scala would look like this:
val appDependencies = Seq(
javaCore,
javaJdbc,
javaEbean
)
EDIT:
Once you update your dependencies in Build.scala don't forget to update dependencies in your IDEA or Eclipse by running corresponding play command, e.g.
play idea
Playframework is generating the IDEA specific files when you run "play idea" (if you're using Eclipse, run "play eclipse"). If you imported the project in the same way the tutorial explained, you should have the necessary JARs already available in the project.
If it's still not working, verify if IDEA correctly assigned a JDK to your project.
Try to understand what this framework is doing under the hood, don't just try to make it work and ignore the important stuff.
I had the same problem and I was using Eclipse. I included #Entity, e.g. and in my project console I typed eclipse with-source=true. After a "Refresh" in my Eclipse project and a "Clean", it brings me all JARs and then I clicked on the issue and the IDE offered the possibility to include javax.persistence.*, play.db.ebean.Model, etc.
I was having the same problem, while using a heavily modified version of Eclipse Neon. The clue to solving it for me, was that the only place I was seeing the errors was during a Maven build. The Eclipse IDE was able to compile and run the program just fine.I was able to solve it by adding a couple of dependencies to the project's pom.xml file. See below for the xml code for the dependencies.I was able to get the groupId's and artifactId's versions by drilling down the directories out on Maven Central. I just walked the tree until I found the metadata.xml files for the persistence.core and the persistence.jpa artifacts.
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.core</artifactId>
<version>2.6.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa</artifactId>
<version>2.6.4</version>
<scope>compile</scope>
</dependency>
I have the following setup, grails 2.0.3, STS, and I'm doing this in one of my controllers:
render(['car': contactL] as JSON)
When I run the application I get the following error:
I have read about the error, but none of the solutions have worked for me, I have tried cleaning, upgrading, using the Grails Tools -> Refresh dependencies but it gave me:
grails> | Error Error running script null: Cannot invoke method trim() on null object (Use --stacktrace to see the full trace)
I'm also getting this error in my project:
The project was not built since its build path is incomplete. Cannot find the class file for groovy.lang.GroovyObject. Fix the build path then try building this project Ristretto Unknown Java Problem
What's you diagnose?
To fix the "unable to resolve class JSON" error, you should just have to import it:
import grails.converters.JSON
...
class MyController {
...
render [car: contactL] as JSON
I finally managed to get it working, I switched workspace, and added my project - problem solved.
In eclipse when I compiled my GWT-modules then I got successful
compilation but when I tried to run my ant script for gwt compilation
I got the following error messages :
[ERROR] Errors in 'file: ../../../... .java'
[java] [ERROR] Line 19: The import com.ensarm.......
cannot be resolved
Finding entry point classes
[java] [ERROR] Unable to find type .....*
[java] [ERROR] Hint: Previous compiler errors may have
made this type unavailable
[java] [ERROR] Hint: Check the inheritance chain from
your module; it may not be inheriting a required module or a module
may not be adding its source path entries properly..
Any idea/suggestion guys ?
Thanks,
Sachin.
Looking at the error it seems that you are missing some jar containing containing the missing classes. You need need to add that jar to the class path. Eclipse can find it but for the ant target the 'compile path' provided should include that jar.
Can you make sure it is there in your compile path.