Debug Solr code in Eclipse - eclipse

New to Eclipse and Solr, I imported apache-solr-3.6.0.war into Eclipse and run Solr with tomcat plugin. Now i want to debug some existing code, however how do i import the Solr source code?

Without knowing how you imported it exactly: sounds like you are looking for Source attachment.
It might be better if you use the Solr source code directly. Check the README file included in the release, there is an ant task to init eclipse:
To setup your ide run [...] 'ant eclipse'.
Then all dependencies are loaded using ivy and you can run it from within the IDE.

You can also check out the whole Lucene/Solr source:
install Subclipse add-in
choose New... > Project...
SVN > Checkout projects from SVN...
add this link as new repository
select branch /branches/lucene_solr_3_6 (if you want last stable version. Use trunk if you want to use cutting edge source)
choose Check out as a project in a workspace and leave everything else default
Then, after the checkout completes, to complete setup, you don't have to fiddle with JARs manually, simply:
right click on main build.xml, the one in your project's root
choose Run As... > Ant build... select (in this order)
ivy-bootstrap and resolve tasks (which will download all JAR dependencies)
then run in this order: validate, clean-idea, eclipse, compile, get-maven-poms, generate-maven-artifacts (the last two only if you plan to use Maven).
And that's it, you should now see no redness in your workspace and have Lucene and Solr JARs built.

Run solr like this:
java -jar -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=1044 start.jar
Solr will start, but wait you to connect from Eclipse to continue.
Then in Eclipse, go to:
Run / Debug Configurations...
Select Remote Java Application
Press New button to create a new remote configuration
put 1044 on port
Click on Debug
This is the standard way to debug remote applications in Java

./solr start -p 8983 -f -a "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=0.0.0.0:8000"
Start solr with
provide app run on port 8983
provide Xrunjdwp:transport=dt_socket
remote ip address 0.0.0.0:8000
and then go to eclipse

Related

Configuring Eclipse CDT for Apache Mesos

How do I configure Eclipse CDT Luna to work with Apache Mesos directly?
The steps for building Apache Mesos on a Linux machine are known and provided here:
http://mesos.apache.org/gettingstarted/
(This works on a Mac with Eclipse “Kepler”. I hope it is similar on other platform variants.)
Install Eclipse with CDT
“git clone” a Mesos git repository into a local directory as described in the “Getting started” guide you referenced.
Open eclipse. Select “File->Import…->Git->Projects from Git”.
Select “Existing local repository”.
Click on “Add…” and add your local Mesos git directory. It will show up in the list in the selector box from step 4.
Select the entry for your directory and click on “Next”.
Select “Import as general project” and click on “Next”..
Give your project a name and click on “Finish”. Now you have a project.
Make sure you are in the C++ perspective. Select/highlight your project in the Project Explorer. Then select “File->New…->Convert to a C/C++ Autotools project”.
Edit your project’s properties (Select project, Cmd-I). On the pane “C/C++ Build”, add “/build” to the value of “Build directory”. It should look like this: ${workspace_loc:/myProjectName}/build
Optional: In pane “Autotools” go to “Configure Settings->Advanced”. Under “Additional command line options” you can put “--disable-python --disable-java” if you don’t want to build Python and Java-related stuff every time.
—
As a prerequisite, I am using these values in my eclipse.ini (https://wiki.eclipse.org/Eclipse.ini):
-XX:MaxPermSize=512m
-Xms1024m
-Xmx6144m

Eclipse - Make dynamic web application include other projects in workspace

I'd like the exported .war file to include the other (referenced) projects in the workspace.
When I reference them in the Build Path only, it shows no "Problems", but ClassNotFoundException is thrown later, when I try to "Run on Server" or export.
Using eclipse Kepler, tomcat 7.0.42.
I've seen the solution here: Not able to configure run path for web application project in Eclipse workspace; that's how it works now. Is there a more convenient way?
Are you running Tomcat within Eclipse? Try this:
Run -> Run Configurations... (or Debug Configurations...).
Find Tomcat v7.0 Server at localhost (or whatever it's named for you) under Apache Tomcat on the left-hand side.
Go to the Classpath tab on the right.
Select User Entries and click Add Projects....
Select the projects you wish to include.
That should place that project on Tomcat's classpath.

Associating a Project to Sonar in Eclipse

I have Eclipse Indigo 3.7 base with MyEclipse 10 Java enterprise development plug-in:
I have installed Sonar plug-in for eclipse.
Installed Sonar server and running it locally from localhost (localhost:9000)
Tested the Server connection in Eclipse from
Windows>Preferences>Sonar>Servers. Connection is successful.
For my Project, ran the Maven goal for sonar (sonar:sonar). Build is
successful. I am able to browse the results in localhost. (localhost:9000)
My issue is with Associating the project to Sonar.
When i right click on my project, Configure > Associate with Sonar, I get a screen where nothing happens.
Basically the screen has 2 fields,Project and Sonar Project.
The Project field contains the name of my Project and Sonar Project field lists this message - "click here to start searching for a remote Sonar project"
I click on that field and enter my groupid:artifactid but nothing
happens.
I also tried entering the Project Name listed in Sonar dashboard
but that also does not help.
When i right click on my project, In the context menu i am unable to see 'Sonar' option.
Help me associate my project to Sonar in eclipse. Please let me know what i am missing.
Thanks in advance.
I had the same issue with my Liferay project in Eclipse (liferay-plugins-sdk.6.2.0) and here is how I got it working:
Install the eclipse plugin, and test server connection
Install the Sonar server and start it (for example on yourhost:9000)
Go to yourhost:9000 and login (admin/admin unless you changed it)
Go to Settings -> System -> Provisioning
Create new project (+Create in the top right corner)
I've used key=Liferay6.2 and name=liferay-plugins-sdk-6.2.0
After the above steps I went back to my eclipse project and in Configure > Associate with Sonar I was able to search/find the liferay project.
When using Sonar Eclipse, you can associate Eclipse projects only to the corresponding Sonar modules (unless you are working on a single-module project, which is pretty rare in fact).
This means that you can't associate the root project (which is logical as by definition, a root project has no sources in Sonar). You have to right-click on all the imported Maven modules, and associate them all in a single run.
Go to your project folder in eclipse workspace from the terminal and run following command:
mvn sonar:sonar
This command will create your sonar project. Try associating the project again. Make sure you enter the name associated with your project from your
pom file. (Clear the text field)
BEST ANSWER AFTER SO MUCH ANALYSIS(I have faced the same problem)
Forget to add to associate with SonarQube first
If you want to add sonar group id create sonar-project.properties
Just add below code
# Required metadata
sonar.projectKey=javapractice
sonar.projectName=javapractice
sonar.projectVersion=1.0
# Comma-separated paths to directories with sources (required)
sonar.sources=src
# Language
sonar.language=java
# Encoding of the source files
sonar.sourceEncoding=UTF-8
download sonnar-runner from github.
download sonar example from github
download sonar
run sonar as per your operating system from command prompt
go to sonar example path like c:/sonar example/java/.. /.. *.properties path (beside src)
run sonnar-runner c:/.... / sonnar-runner.bat -e
go to browser http://localhost:9000 after that (login:admin/admin)
your project is displayed in the browser.
Choose Maven on the project and then choose Select Maven Profiles and then choose with-sonar in Eclipse. This will enable the Sonar functionality on projects. Now you will see the Sonar option when you right click on projects.

How to run an eclipse m2e webapp project on a local server?

I'm trying to create a simple webapp as a maven project with m2e to help me manage dependencies, but I'm must be missing something, because I'm not able to run the project from eclipse.
To put a bit more context, here is what I do:
First, I choose to create a "Maven project"
Then, I select the "maven-webapp-archetype"
Finally, I fill the basic project information form of the next step and finalize project creation. Everything looks fine at this point.
The problem is that when I try to run the project, I don't find anything suitable to run the project on a local server:
Also, from the "Add and remove..." context menu entry of the local server, my project doesn't appear in the list of web projects.
Did I miss a step in the setup, or is there an other more suitable way to start the project?
You should install the m2e-wtp connector.
You can install this from: Window, Preferences, Maven, Discovery, click Open Catalog and search for wtp. Check the box next to m2e-wtp, and click Finish.
Once the installation process has completed, allow it to restart Eclipse. After that, you may need to right click on the project, choose Maven and Update project.

eclipse debugger: attaching source-code of maven dependencies?

I'd like to use the source code of maven-managed dependencies when debugging our webapp in myEclipse 8.
I have managed to attach the sources to the libraries in the "Maven Managed Dependencies" classpath container, i.e. when I open a class file from a dependency (e.g. using Ctrl-Shift-T), I see the source code.
However, when I define a server connector for my tomcat, deploy the wepapp to it, and launch it in debug mode and execution halts on a breakpoint in that same class, the editor pane only displays the text "source not found", and a button to edit the "source lookup path". I have attempted to manually add the "Maven Managed Dependencies" classpath container, only to be told "Use maven project settings to configure depedency resolution". However, I see no useful setting in that property pane ...
How can I attach those sources? I am aware that this works with the m2e plugin and wtp, but I'd rather avoid convincing the rest of my team to switch plugins ...
Looks like issue MNGECLIPSE-983
I have confirmed that if I manually pick the External Archive option and find the relevant -sources jar (navigating that big .m2/repository tree to find it) and then add the jar as a sources it does work, and surprisingly it does remember the next time which isn't too bad.
That's at least doable I think for me because we don't often need to step debug through external dependencies, but when we do, it's often frequent, so adding it once while a bit of a pain, can be done on a case by case basis.
I have since discovered that this problem only occurs if the server is launched using a launch configuration.
The problem does not occur if the server is started by:
click the server icon in the toolbar -> context menu appears
mouse over the intended server -> submenu appears
click on "Start"
While this precludes sharing the server configuration by checking the launch configuration into version control, it at least allows seamless debugging.
Please do the following steps in Eclipse IDE(Tested with Version: 3.5.2),
In Package Explorer, Right Click on the Project which integrated with Maven container.
Select Maven 2 and then select "Fetch Source JARs".
The above action wil fetch sources of all the 3rd party jars present in the Maven Classpath.
Regards,
Rajesh.
Just put the .m2/repository/ folder itself with the search subfolders option.