What page to open when running Maven-based EAR from Netbeans - maven-2

Is there an easy way to tell Netbeans (6.9) what page to open when I "run" my Maven Enterprise project? It opens a totally wrong context path. I guess there are some options I can specify on the Project Properties | Actions page -> "Run project" action, I just can't find it anywhere as documentation seems to be nonexistent for Netbeans...

you are running into http://netbeans.org/bugzilla/show_bug.cgi?id=176096. I haven't found a fix for it yet.

Did you specified relative url in Project properties / run?

Related

Play Framework 2.4 and IntelliJ Idea

I am trying to open a play 2.4 project in IntelliJ but since things have changed I don't know how to do this.
In previous versions I could just run
activator idea
Or use the activator UI and click on generate intelliJ project, but in 2.4 the idea command doesn't seem to exist
[error] Not a valid command: idea (similar: eval, alias)
[error] Not a valid project ID: idea
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: idea (similar: clean)
[error] idea
[error] ^
And the UI seems broken, when I click on generate intelliJ project it tries to compile the app and gives this error:
play/Play$
java.lang.NoClassDefFoundError: play/Play$
Use 'last' for the full log.
Failed to load project.
I created the project from scratch using the play java template with:
activator new
I have also tried importing the folder as a project but intelliJ doesn't seem to identify it as a project
I run into the same problem, as I used IDEA to open a project folder, it had an play 2 app in a sub folder, then I import module (play 2 app) to the system.
And it works well.
After that I have changed the module folder name, then when I run the app, it displayed:
Not a valid project ID: "project team"
I re-checked the folder, and found that in the File -> Project Structure option, the name of module is "root", and the "team" is the module for whole project (not the module imported by SBT), so apparently, the module wasn't functional after I changed the module folder name.
So I found and removed all .idea folder, which is IDEA configureation, then re-open/re-import the module, still not work. I thought it's IDEA cache issue, it do have cache for the opened project, so I changed the project folder from team to something else, clean the .idea folders, and re-open/re-import it. It worked.
If the play app is in the project folder as a sub folder, to import the module at File -> Project Structure.
The project name should be "root" when running it in IDEA. So in this case, you should rename "project team" to "root" in the name field.
Solution 1
In my case (IDEA 2018.2), I changed the lazy val variable in build.sbt, it had the name "root" when my project name was "top", changed "root" to "top".
Before:
lazy val root = (project in file(".")).enablePlugins(PlayScala)
After:
lazy val top = (project in file(".")).enablePlugins(PlayScala)
Change project variable
Solution 2
The method proposed by Tom solved my problem partially, because after rebooting the IDEA I returned the project name back, it was necessary to change the variable from "top" to "root" in build.sbt.
Before:
name: = "top"
After:
name := "root"
Intellij IDEA lets you quickly create a Play application without using a command prompt. You don’t need to configure anything outside of the IDE, the SBT build tool takes care of downloading appropriate libraries, resolving dependencies and building the project.
Before you start creating a Play application in IntelliJ IDEA, make sure that the latest Scala Plugin is installed and enabled in IntelliJ IDEA. Even if you don’t develop in Scala, it will help with the template engine and also resolving dependencies.
Basically, install Play Framework, Scala plugins and import project into Intellij as SBT project. Don't use activator to create IDEA project files. More details here.
It seems I had not updated scala/sbt to the latest version in intelliJ
Once I had done this it noticed that it was a valid project, though the docs don't seem to mention you can import it as an SBT project, just how to create it as a new sbt project (which I did not want to do as I wanted to create it via activator)
I also had the project/play-fork-run.sbt file issue
I use Intellij Idea 16.3.3 and this problem appears sometimes. How I fixed it? You just need to open your SBT plugin and under your project get the context menu then you should choose "Ignore SBT project". After a current process is finished you should turn on this option again. This is work for me:)

IntelliJ IDEA Report Highlighting error when using routes in Controller

I have a Scala Play project. I'm using Play 2.2.1. I downloaded Scala, Play 2 supported and SBT plugins. Everything is OK, but When I call route on Action in the Controller appear following error(Look screenshots):
I'm using IntelliJ IDEA 12.1.6 Ultimate version. Scala version 2.10.2
Anybody know how to fix this problem?
Thanks in advance!
Edit
When I generate my project to Intellij IDEA via "play idea" command in play console, and I opened project in IDEA project structure was such:
Then I saw answer #millhouse and discussing on this githup([Play 2.2] "play idea" creates not working source mapping in target) and I removed following folders from Sources Folders:
target\scala-2.10\src_managed\main\controllers
target\scala-2.10\src_managed\main\views
and "Report highlighting error" disappeared, but now there is another error:
and
my route:
And I've changed "Sources Folders" as shown below:
But it doesn't help me. And remains "Unspecified value parametrs" error.
millhouse's answer helped me find the right answer. Play 2.2 (and perhaps earlier versions, haven't checked) output a scala version of the routes file to project_dir/target/scala-2.10/src_managed/main So for IntelliJ to get the highlighting right you need to make sure that src_managed/main is added as a source folder. The reverse routes for javascript are for some reason included in project_dir/target/scala-2.10/classes_managed so you'll have to add that as well. (In your screenshot it looks like classes_managed is set to excluded so you'll want to un-exclude it by pressing the x button on the right hand side.)
Here's a screen shot of my project structure:
Update:
In Play 2.3 (or perhaps recent versions of IntelliJ) adding the classes_managed no longer fixes the problem. Instead of adding classes_managed to the project's sources add it to it's dependencies. By doing that IntelliJ should be able to pick up the compiled routes.class.
This is a common problem, it's because IntelliJ needs to be shown where to look for the compiled Scala templates and routes file. Here's how I fixed it on my IntelliJ 12.1 installation:
Go to the Module Settings for your project in IntelliJ (select the top-level, hit F4)
Choose the Modules item in the Project Structure window that appears
Select the projectname item (as opposed to the projectname-build item)
Add the compiler's output directory to the Source Folders items;
For Scala 2.10 it's target/scala-2.10/classes
I personally find the IntelliJ UI for this to be very non-intuitive; you might need to take the target directory and/or one of its subdirectories out of the Excluded Folders first
After applying that change, IntelliJ should see the results of compiling each routes and .scala.html file as just-another source file, so they won't show as "broken" and auto-complete should work for them.

In Intellij, right click on a test does not present a "Run" option

In IntelliJ when I right click on a test I dont see a "Run ClassX or MethodY" anymore. In fact there is no "run" window and when I right click I cannot run any class.
It was all working fine about 3 hours ago so I am not quite sure what has changed.
IntelliJ 10.5.1 (Licensed and NOT community edition)
Java 1.6.0_24
This happens for all projects.
Update 1
I installed IDEA 11 and imported settings from 10 and then saw that it was not a free upgrade close IDEA 11 and started using IDEA 10. I am fairly certain things stopped working from that point but not sure. Is that a problem? Can I somehow delete IntelliJ configuration directory somehow and restart?
Adding a screenshot when I don't get Run option on right click:
My problem was that my test class wasn't public. I needed:
public class MyTest {
#Test
public void testMethod() {
instead of:
class MyTest {
#Test
void testMethod() {
If your project is a maven project then you can just right-click on the pom.xml file and select "add as Maven project".
This approach worked for me. (green plus third from the bottom)
I had the same problem. To fix it, I had to ensure that my class had a proper main method:
public static void main(String[] args) {
}
Every keyword in the above statement is critical. If you omit one, IntelliJ wont' recognize it. Easy-to-forget keywords are static, void, and the String[] args argument.
I had forgotten the arguments in mine ;-)
Also make sure your source code is inside a src folder which is marked as such by IntelliJ.
In my case, the cause was disabled JUnit plugin. (File — Settings — Plugins — JUnit, check, OK)
If you're using JUnit 5 (Jupiter), this happens when you use the old #Test annotation from JUnit 4. Just replace
import org.junit.Test;
with
import org.junit.jupiter.api.Test;
and IntelliJ should show the "Run" button again.
Ok after tremendous amount of eyeballing I located a {HOME}/.java directory which seemed to contain some Jetbrains related preferences. I deleted that directory plus {HOME}/.IntelliJ* directories. Then deleted all my intellij installations and downloaded it again from scratch and it now works fine..
Sigh....
Disabling gradle plugin solved the issue for me (community edition 2018.2)
In my case i right clicked the src folder and went to -> mark directory as -> sources root.
I had the same problem. I solve it by
File -> Invalidate Caches / Restart
right click on the top pom.xml -> Maven -> reimport
There should be no need to delete any configuration files.
I found that I used to have the Run option in the context menu to select either run tests or run Scala tests, etc. After I had selected an option for the first time, my options were no longer there.
I was able to resolve this issue and select the type of tests I wanted for that folder by creating a Run/Debug configuration following the instructions found in the documentation here...
https://www.jetbrains.com/help/idea/2016.1/creating-run-debug-configuration-for-tests.html?origin=old_help
As i had the same issue , i could clearly See that #Test is not providing any hint when i press control key and hover , and the same was confirmed as External Libraries was not having Gradle Dependencies added so i had to update the project as gradle project suggested by a pop up when you start Intellij.
I could resolve the issue by disabling the Gradle plugin from the Plugin menu and restart.
If the project is already added as a Maven one, unlink it.
right click on the project -> Maven -> Unlink Maven Projects
Then link it again:
right click on pom.xml -> + Add as Maven Project
I've just had the same problem and solved it in the following way.
Go to your $USER/$INTELLIJ directory e.g. $USER/.IdeaC2018.3 then find config/plugins. Rename the plugins directory and restart IntelliJ.
My guess is that the problem was caused when I upgraded IntelliJ and incompatibilities with the cucumber plugin.
For me this happened after updating Idea, and then updating all Plugins. Apparently Idea had not restarted yet. Going to File -> Settings -> Plugins and clicking 'Restart Idea' solved the problem
if you can see the play button in left side of the main function then click right click and press run.
in my case, I did not have an output folder.
file -> project structure -> under 'project' tab there's 'Project compiler output' -> define your folder.
Unfortunately, none of these worked for me. I had to
'File' -> "Invalidate Caches / Restart"
Click on pom.xml file, and then 'maven' -> "Generate Sources"
Search for pom.xml file --> Right Click on pom.xml --> Click on Add as Maven Project.
You should get a pop-up, saying downloading Mavin Plugin.
Wait till it gets completed. It takes some time depending on the number of content in pom.xml.
In the below screenshot, "BackendApp.java" is Driver Java file that contains
public static void main(String[] args){}
Right Click on such driver java file and you see Run option in green color.
I had this problem with a Kotlin project. Following action solved it:
right click on test folder -> select Mark Directory as -> choose Test Sources Root
So I had this problem on pycharm and the problem was that there was already a run configuration (in the dropdown next to the play button) that had the name of the file. When i deleted that run configuration it would create a new one that was correct.
I had the same problem and I tried all the above solutions nothing worked for me but after I install TestNG plugin it's started working since there are some TestNG annotations used in my unit tests
I had the same problem on my Intellij 2019.3 after that I updated from 2019.2.4. I thought that the problem came from the updated first, but the rollback didn't fix, so I tried de solution above e the problem was fixed. After configuring all my projects from scratch the problem get back, so I started to check everything I did. I discovered that an old project from Eclipse that uses files .launch to run and need some plugins to be able to execute on Intellij was causing the problem, after disable the following plugins the test option return.
In my case, my project is using Bazel.
The solution was to sync Bazel from Bazel plugin.
Since this is a top Google result when trying to figure out how to run a Scala project, and since for some reason IntelliJ (I'm on 2020.1.2) doesn't automatically create a run configuration for a Scala project (in contrary to a Java project), it's worth laying out the basics for future readers:
Click on "Edit Configuration" on the top right of the screen.
Inside the opened window, click the + button its top left.
Choose "Application".
Now, let's go through the required fields:
in the "Name" field, enter a name for this configuration, e.g. "run".
in the "Main Class" field, enter your main class name.
Alternatively, use the ... button to the left: inside the window that opens, click the "Project" tab, navigate to your main class, pick it and click "ok".
Note: If your main class doesn't have a main method, IntelliJ would show an alert. see listing 9 below.
Make sure the value in "Working Directory" field is correct (it should be the project folder).
in "Use classpath of module", select your module (see project vs module in IntelliJ)
That's it for configuring. Click "Apply", and close the window. Here's an example final result:
Note that my Main class is part of a package named Demo, but having a package is not necessary.
Inside the main class, make sure there's a main method.
See #Josiah Yoder answer for java, and for Scala it's:
def main(args: Array[String]): Unit = {
}
That's it. You should now have the green run and debug buttons enabled.
Seems there are version conflicts between plugins and IDEA itself that commonly break this functionality. Many of the solution here indicate people manually trying to identify the plug in, I found that to be impossible. So here is a generic way, without having to uninstall IDEA as one solution proposed:
File > Settings > Plugins > gear icon > disable all downloaded plugins
This fixed it for me.
Make sure the method is not static! JUnit only allows #Test before instance methods but Intellij doesn't complain even if you use #Test above a static method.

How to view JDK external documentation in IntelliJ IDEA?

The shortcut for this action is Shift+F1 but it is always grayed out even though I have pointed JDK documentation path to the docs folder (the docs folder is unzipped from jdk-7u2-apidocs.zip ).
Thanks
You need to specify the docs/api subdirectory of the unpacked documentation or use https://docs.oracle.com/javase/8/docs/api/ URL for the external documentation feature to work.
File -> Project Structure... then here :
I'm using 10.5.4. It was unclear to me from the docs or from resources online that you need to add this at Project Structure > SDK's > (Choose your SDK) > Documentation Paths > Specify URL.
For IntelliJ Idea:
Call "Project Structure" (Ctrl+Shift+Alt+S), go to "Platform Setting - SDKs", choose "Documentation Path" tab on the right, then add url of JavaDoc (http://docs.oracle.com/javase/7/docs/api/) to your project
You can add the external Javadocs API link as shown below:
Go to File > Project Structure...
Then select SDKs (under Platform Settings)
Go to Documentation Paths tab
Select Specify URL button and add the link for JDK 11 API docs (https://docs.oracle.com/en/java/javase/11/docs/api/)
I understand the question as follows:
You would like to see javadocs of classes that are not within JDK. I am a bit uncertain because CrazyCoder's reply is talking about JDK specific javadocs.
I am using Macos 10.8.4 and Intellij 11.1.5
The project I am working on is a mvn based project with many modules which have complex dependencies.
Let me take a concrete example to explain what I did, I am sure it can be reproduced for others: apache sshd
I downloaded the javadoc from maven central stored it stored it somewhere. In intellij I went to the module settings (shortcut F4) and the to Libraries in the sidebar. Maven pulls all dependencies automagically and I can find sshd there. The right side then shows Classes, Sources and JavaDocs. The JavaDocs part in my case had a path linked in that pointed to my local m2 directory. However the directory did not contain the javadoc jar file. So I thought how do I get it:
mvn dependency:resolve -Dclassifier=javadoc
Taken from here
However this failed for because we do not have some javadocs in our nexus (I guess, not sure).
So I ended up linking the file that I downloaded manually in as a javadoc link and this then allown me to use Shift+F1 for the javadoc to open in my standard browser.
Maybe others can elaborate on how to get this done with mvn. I did not have the time to further investigate.
Posting this here in case you're like me and don't necessarily want javadocs, but rather the documentation inside your IDE.
In my situation, I had downloaded OpenJDK 11 and wasn't able to get documentation inside IntelliJ. Instead I was getting decompiled code.
What helped me was the answer at https://stackoverflow.com/a/38413439
i.e.
Go to File > Project Structure > SDKs > Sourcepath > '+' on the right side.
Navigate to your JDK (I'm on Ubuntu so it was located under /usr/lib/jvm/openjdk-11/).
Select the src.zip (for me, /usr/lib/jvm/openjdk-11/lib/src.zip).
Click OK > OK (to "Choose Roots" pop-up) > OK (to Project Structure)
Let Intellij index and it should be available in your IDE.
Java 10 Documentation path
Got to File -> Project Structure Choose External URL
Below Link works Fine... THe default one does'nt work
https://docs.oracle.com/javase/10/docs/api/
Other answers are satisfying but in case you still can't see the documentation, make sure that your java file is located under the src path.

Maven Artifact Search is always empty

When using Alt-Insert to insert a dependency into the POM, the Artifact Search is always completely blank regardless of what I search for.
I tried to add repo1 to Settings->Maven->Repository Services, it says "no repository found." I find that hard to believe.
I've also tried to "update" my local repository but that results in an error.
FYI I'm using Community Edition Snapshot.
Thanks!
If you have a brand new IntelliJ install and have never updated your Maven Repository, notice that there is a little "Update" button to the right that becomes clickable when you click on each repository.
Preferences > Build, Execution, Deployment > Build Tools > Maven >
Repositories
The important one is the https://repo.maven.apache.org/maven2/ remote repository, make sure you update it.
I used Artifactory to generate a settings.xml for me, and by default it pointed me to the "libs-releases" repository.
Instead want my "releases" repository to point to the much larger virtual repository "remote-repos."
All it took was a simple change to the options of the "Generate Settings" function.
Weird. The Artifact Search is working fine for me with IntelliJ Community Edition, at least for artifacts from the central repo that has been indexed:
And as you can see above, all repositories declared in POMs known by IntelliJ are listed.
There might be something wrong with your Maven settings. This is a wild guess but is your Maven home directory properly defined? Same for the user settings file? Is Maven actually working fine under IntelliJ?
Solved - by reinstalling Intellij Idea
Search for class tab in Maven Artifact Search popup was always empty
Solution in linux:
remove idea folder (for me it was ~/idea-YOUR_VERSION_HERE)
remove ~/.IntelliJIdeaYOUR_VERSION_HERE folder (settings)
download new version form jetbrains.com, unzip, run installer from bin
It appears to be a blocked port, as I am using my own artifactory repository. Of course, the port it is using looks to be completely undocumented, but WireShark shows it to be 58754. Sounds random, I hope it isn't!