Handling libraries in correct way - servlets

I'm new to Intellij. I've created a maven project and I'm playing around adding different kind of frameworks to the project. I'm using JBoss wildfly.
I'm having problem with the web application framework. Its creating web.xml and all the necessary folders. But when I try to create a Servlet I get an error saying that "javax.servlet.http" does not exist upon trying to compile the application.
I'm pretty sure the JBoss Wildfly application has the serlvet api but I'm not sure how to add all those libraries to the project. I could add them manually but I don't think that is the correct way to do it. All the necessary web application api should be available by default give that you have chosen the right frameworks.
What am i doing wrong?
Edit: Ok I've managed to find all the API inside of the wildfly folder. But It feels very clunky to be forced to add servlet API manually. Intellij adds all the api for web application when you create a project and add application server - > Wildfly. But you when you create a maven project and add web application framework servlet api is not added to project libraries.

You should configure your dependencies using Maven if you have a maven project. IntelliJ only adds libraries for projects that use IDEA to build (because it has to download the jars, build libraries, and get that all into the class path).
Since maven is your build tool, you are responsible for setting up the dependencies in your pom.

As said in sylvanaay's answer you have to add servlet-api in your pom but it should be in provided scope as follows.
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
If you add the library mannualy in Intellij IDEA the build may fail when you do maven build.

Related

How to use Spring 5.0 in NetBeans 8.2?

When I create a Java Web project in NetBeans and select a Framework, in this case Spring Web MVC, only two options appear:
Version 4.0.1
Version 3.2.7
You can do this in Netbeans:
Download the Spring Framework you need from here
Extract the contents of the archive and copy the contents of the lib directory to your netbeans location e.g /home/stanley/netbeans-8.2/java/modules/ext/spring-(version) e.g 5.1.4
On your netbeans go to Tools > Libraries > New Library
Name your Library as Spring Framework (version) e.g 5.1.4 and add all the jars from the location in 2 above.
Restart your netbeans application.
You should have the new Framework as shown in the diagram below:
TL;DR
The easiest way to create a new spring project is using Spring Initializr. All you need to do is fill in the form, download the project, unzip it and open in NetBeans.
Explanation
Regardless of a language and IDE, it is usually good idea to create a new project based on a standard build-tool for the language's ecosystem and avoid creating an IDE-specific project. That makes it easier to share the project with people who use a different IDE and switch your IDE in the middle of the project.
There are several build-tools for Java ecosystem but I'd suggest to pay attention to two of them: Maven and Gradle. Those are most widespread and supported by IDEs.
NetBeans supports Maven out of box. It supports Gradle too but in 8.2 you are supposed to install a support plugin for Gradle (from Tools -> Plugins menu).
You can generate a new Maven or Gradle project using NetBeans. Select corresponding menu item when selecting the type of the project.
Then you will have to add the dependencies of the project to its descriptor (pom.xml for Maven or build.gradle for Gradle). See the documentation for the build-tool of your choice to understand how exactly to do that.
Spring provides Spring Initializr service to generate a new project based on spring's libraries. It is the easiest way for a quick start.
Since you are using Netbeans and it supports Maven out of the box, you can get an existing Maven archetype to setup a basic Spring application for you to start from.
Although there isn't any official archetype, there are a lot of really nice 3rd party ones like https://github.com/kolorobot/spring-mvc-quickstart-archetype
The steps to start a new project are quite fast and straight forward (Netbeans 11)
File -> New Project -> Java with Maven -> Project from archetype
In the search filter enter spring-mvc-quickstart-archetype, enter your project details and click Finish

Spring-boot plugin for sbt

My goal is to package an executable spring-boot jar - a web app with tomcat embedded. I would like to use sbt but I don't find a straight forward way to do this. There are maven and gradle spring-boot plugins, but I don't see anything even close in sbt. My question is - is there a spring-boot sbt plugin, if not, is such functionality planned?

Unable to configure NLog Logging in MVC 6 ASP vnext starter project

Added to project.json file for logging:
"Microsoft.Framework.Logging.NLog": "1.0.0-beta1"
The Framework.Logging.NLog depends internally upon NLog, which I tried installing via Nuget, project.json, Package console. It doesn't help.
Also wasn't able to find a way to configure NLog logging and a tutorial/guide to place the config sections of NLog.
NLog does not ship for CoreClr hence you need to define the dependency under aspnet50. Do look at the sample https://github.com/aspnet/Logging/blob/dev/samples/SampleApp/project.json

Share proxy/sequences references between ESBConfiguration projects

We have the following problematic :
we have an ESB Configuration project containing proxies/sequences that we want to reuse inside an other ESB Configuration Project (we just want to reference them not to copy) and finally build them inside the same CAR.
How can we do it with DeveloperStudio/maven ?
Tks
Nicolas
All developer studio projects are fully maven comfortable . Please follow the following steps to create projects
Create maven multi-module project.
Then create the ESB configuration project(As a best practice do it inside the
Multi-module project.).
Create relevant ESB artifact(Proxy/Sequence) inside that ESB config project.
Finally create the Composite application project (As a best practice do it inside the
Multi-module project too).
Now go to the maven multi-module project location and build it(mvn clean install)
Once build succeed ,you can find the Car file inside composite application target directory
You not need to build project by project just build the multi-module project only.
Hope this help !!

Using XCore generated classes in a war aggregating multiple Maven projects

I have a maven project called myproject.app. I also have another project using vaadin and gwt called myproject.ui and another project, which is an Xcore-Project converted to Maven called myproject.model.
I want to aggregate them all in a war. For this I have a myproject.war with a pom declaring the dependencies.
For Vaadin and GWT everthing is working fine as these projects are pure maven projects. The Xcore project gives me headaches because I can't manage to provide the Plugin Dependencies declared in this project in the war.
I have tried to add the needed libraries in the pom but I can only get old versions (2.2.3) from Central - the XCore project uses 2.8./3.8..
How can I solve this?
The answer is to convert the eclipse dependencies (EMF, XCore ...) to maven artifacts using the Maven Tools 4 Eclipse.
http://wiki.eclipse.org/MT4E_FAQ
For professional usage it is necessary to setup a maven repository, I used Nexus with success (if you are developing locally and alone it would be enough to install the artifacts in you local repository).
http://www.sonatype.org/nexus/
You can get it working by setting up a hosted repository with the converted Eclipse artifacts (documented in the mt4e reference) and creating a repository group aggregating the preconfigured maven central proxy and the hosted repository with the eclipse artifacts.
You need to setup your local settings.xml to use the nexus and you're good to go. Eclipse's artifacts are usable via maven coordinates.
Keep the orbit artifacts in mind and design your patch files carefully.

Resources