Facing issue while setting up Spring boot application, node application using gulp, spring mvc application, hibernate and
Answered
Hi All,
Please guide me how to setup complex project on IntelliJ Idea, using following components
1) Spring Boot Application,
2) Spring MVC
3) Hibernate Application
4) Gulp based nodejs application (Express Js)
How ever I am able to setup using eclipse but while using Intellij idea it is giving me issue ?
Are intellij Idea is capable to install all in a go or I need to use specific tools for respective purposes ?
Thanks A lot,
Please sign in to leave a comment.
Do you use Maven or Gradle? Did you try https://start.spring.io/?
IDE should be able to import and configure such projects automatically.
Maven, Yes I am able to import the project successfully. But when I tried run application using IntelliJ Spring boot application it is giving me errors.
Although,I tried to run same application Using Eclipse (select run as spring boot application) it run properly without any issues.
Errors :
INFO 88902 --- [ restartedMain] Application : Starting Application with PID 88902
INFO 88902 --- [ restartedMain] Application : No active profile set, falling back to default profiles: default
INFO 88902 --- [ restartedMain] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@2da89754; root of context hierarchy
ERROR 88902 --- [ restartedMain] o.s.boot.SpringApplication : Application startup failed
Do you use Spring Boot Run/Debug configuration?
This issue may affect it: https://youtrack.jetbrains.com/issue/IDEA-107048.
See also https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000088004-Project-with-SpringBoot-and-TilesConfigurer-.
Yes I am using Spring Run/Debug Configuration for Intellij.
Following errors I am getting when I run application using Intellij.
******* IntelliJ Error **** Run Application ****** Using IntelliJ **********
INFO 88902 --- [ restartedMain] Application : Starting Application
INFO 88902 --- [ restartedMain] Application : No active profile set, falling back to default profiles: default
INFO 88902 --- [ restartedMain] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@2da89754; root of context hierarchy
ERROR 88902 --- [ restartedMain] o.s.boot.SpringApplication : Application startup failed
java.lang.NoClassDefFoundError: javax/servlet/ServletContext
at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_74]
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[na:1.8.0_74]
at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[na:1.8.0_74]
at org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(StandardAnnotationMetadata.java:146) ~[spring-core-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:291) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:231) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:198) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:167) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:321) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:243) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:98) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:677) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:519) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766) [spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]
at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361) [spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1191) [spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1180) [spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]
at Application.main(Application.java:63) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_74]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_74]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_74]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_74]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-1.3.2.RELEASE.jar:1.3.2.RELEASE]
Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletContext
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_74]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_74]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_74]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_74]
... 25 common frames omitted
INFO 88902 --- [ restartedMain] .b.l.ClasspathLoggingApplicationListener : Application failed to start with classpath: [file:site/target/classes/, file:cms/target/classes/,util/target/classes/,api/target/classes/,orm/target/classes/,service/target/classes/]
Process finished with exit code 1
Change the scope of the missing dependencies to compile.
how to change the scope of the missing dependencies ?
In pom.xml, like on this screenshot from the thread I've linked.
Thanks for input but still facing issue running spring boot application on intellij.
******* IntelliJ Error **** Run Application ****** Using IntelliJ ********** WARN 22220 --- [ restartedMain] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'xyz': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
INFO 22220 --- [ restartedMain] o.e.jetty.server.handler.ContextHandler : Stopped o.s.b.c.e.j.JettyEmbeddedWebAppContext@6e2e1534
ERROR 22220 --- [ restartedMain] o.s.boot.SpringApplication : Application startup failed
Please share a sample project to reproduce, or at least your pom.xml: https://intellij-support.jetbrains.com/hc/articles/206869619.
Do you want effective pom as well ?
Also I would like to understand gulp project debugging ? I import gulp-node project but unable to put debug breakpoint in node application.
Check the working directory configuration. A complete project would help to understand the problem and suggest a fix. I've asked another support team member to comment on gulp debugging.
Any update regarding GULP Debugging ?
It would help if you share a project and specify what is not working for you with GULP debugging and how you have configured it.
I am able to run the application using gulp but while debugging, breakpoints doesn't work on nodejs and java script.
Run/Debug Configuration
1) Gulpfile : C:\myproject\gulpfile.js
2) Tasks : test
3) Node Interpreter : C:\Program Files\nodejs\node.exe
4) Gulp Package : C:\myproject\node_module\gulp
Thanks
Debugging might fail for multiple reasons - child processes spawned with wrong options, broken sourcemaps, etc. we have no chance to figure out the issue unless you provide a project we can use for testing.
If you need to debug Node.js app run by Gulp, I'd suggest using node.js run configuration rather than Gulp one - the latter is mostly suitable for debugging Gulp tasks rather than for application debugging
Is there any way to debug node+java script+gulp ? I would appreciate, If you can give me any project example where you have tried.
Thanks A lot
I don't have any - Gulp is typically used to build application, not to run it. If you can provide your project, or at least a Gulpfile you use plus your package.json, I would try to advise on proper configuration
I tried to debug using remote node setup but unable to debug java script and also not able to put breakpoints in javascript ? Please let me know How to debug on javascript files ? If possible if you can provide any project source or links that would be great.
Thank A lots
Any update ?
As I wrote, Gulp run configuration is not supposed to be used for Node application debugging - it was designed to run/debug Gulp tasks. To debug your Node.js application, you need to create a Node.js Run configuration and specify the .js file generated by Gulp build as a file to debug.
If you like to debug the Node process spawned by Gulp remotely, you need to make sure that the process is spawned with `--debug-brk`. Like:
and then use Node Remote run configuration to attach to the process:
Awesome, Thanks for input but How to debug java script file? Because with remote debugging only node base debugging will happen, but javascript files unable to debug.
Also HOW to debug your Node.js application,How to create a Node.js Run configuration and specify the .js file generated by Gulp build as a file to debug? Can explain this step as well .
>How to debug java script file
Not sure I follow you... Node.js is also JavaScript:) By 'JavaScript File debugging', do you probably mean debugging client-side code that is run in browser? You need using JavaScript Debug run configuration for this: specify your server URL there, make sure to start the server, then start debugging... See https://confluence.jetbrains.com/display/WI/Starting+a+JavaScript+debug+session#StartingaJavaScriptdebugsession-Startingadebugsessionwhenusingadifferentwebserver
>How to create a Node.js Run configuration and specify the .js file generated by Gulp build as a file to debug?
Sorry, don't understand what should be explained here... Steps are obvious... In my sample from previous message it's shown how to run application through Gulp and then attach to it. To run the same "app.js" file via Node.Js Run configuration, Click Edit configurations, press +, choose Node.Js, specify the path to your "app.js" in 'javaScript File' field. Click Debug