Spring STS howto add tomcat7 sources - tomcat7

It seems that the configuration wizard for the configuration of servers has no option of attaching sources (namely tomcat7). How can I configure the entire source code for all the used tomcat7 libs ?

Once you have launched Tomcat, there is a launch configuration generated for you. You can access this launch configuration from the "Run..." menu. Once you selected the launch configuration, there is a "Source" tab on the right where you can configure the lookup path for sources. Add the source zips of the libraries to that list and the debugger should find that.

Related

Add log4j.properites as an external file (ouside of jar) in an Eclipse RCP application

I want to build an Eclipse RCP application in a way so that the the end user can configure log levels. I want to do it by exposing the log4j.properties file.
Currently that file gets bundled into a jar that is placed under MyApplication\plugins\MyApplication.jar. While I want it to be directly under MyApplication folder where MyApplication.exe is.
I saw some threads about the subject like Proper way to include log4j in an Eclipse 4 (RCP/SWT/OSGi) application but I couldn't find a good answer there. If I create a fragment project for loading the properties, they will still be jarred up, won't they?
I want to know what I can change in my manifest file or Maven pom files so that the log4j.properties file will be taken out of the jar.
By using the so-called "root files" configuration, you can bring additional files into the installation of your RCP application. In order to do this you need the following steps:
Add an eclipse-feature project to your build (or use an existing one)
In the feature project, create the files you want to have included in the RCP application installation. In your case, you could for example check in the initial log4j.properties at the location src/root/log4j.properties
Edit the build.properties of the feature project and add the line
root = file:src/root/**
Include the feature in your RCP application product.
Then, all files and folders that you have placed in the src/root/ directory in the feature project will be added to the root of the RCP application installation.

Integrating JRebel with custom Ant/Ivy/Tomcat web application with Spring MVC

I am trying to get JRebel working with a fairly large enterprise web application which uses Ant + Ivy for building/dependency management, Spring 2.0 framework and Spring MVC, and all this has to be built and deployed to Tomcat.
I have JRebel enabled on Tomcat and the Project itself. Remoting is not enabled as I assume that if Tomcat and the project are on the same machine, this is not needed. When I start the Tomcat server from within STS, JRebel appears to load fine and I see no (apparent) significant errors.
However, any changes to the project do nothing with regard to deployment, and I see no JRebel messages in the console. The project itself is a somewhat nonstandard layout and does not have the traditional WEB-INF/src structure. When I enabled JRebel on it within STS, it just dumped a rebel.xml file in the root directory.
For reference, the project is based on this codebase and has the same general structure: https://github.com/NCIP/c3pr/tree/master/codebase
While the JRebel guides are good, they only show JRebel being used with very simple projects and do not go into very much depth into exactly how the service works.
Any suggestions, resources, or ideas are greatly appreciated.
thanks
Did you actually recompile (doesn't matter if you use Eclipse or javac) those classes that you changed? It might be a good idea to check if you have "Build automatically" enabled under the "Project" menu.
They way how JRebel works is that it actually monitors the compiler output folder (usually "bin" folder or "build/classes" or something similar).
This folder (or folders) is specified in the rebel.xml file and the file must be in the classpath of your application while you run it (WEB-INF/classes or on the jar file root or in the exploded dir).
Can you make sure, that rebel.xml is actually in the applications classpath?
Also, you should see the message in the console that says something like:
"JRebel: Directory '/path/to/project/bin' will be monitored for changes.".
And also, if you see the JRebel banner in your console, it is useful to check if the license is found (if it is not found then JRebel will not work).
Sometimes there may also be some mismatch when your Eclipse compiles classes to the "bin" folder and your build scripts compile them to under "build/classes" and only one of these locations is specified in the rebel.xml file. In this case, JRebel will monitor only one of them and then it is confusing too.
Wishing the best,
Sigmar

Deploying shared server controls with web.config transforms

I'm using teamcity to deploy our web application to several servers using msbuild and webdeploy.
I have a configuration per customer / environment combination - for example:
Internal-Dev
Customer1-Test
Customer1-Pilot
Customer1-Live
Customer2-Test
Customer2-Pilot
Customer2-Live
I only need these configurations so that the deployment process can use web.config transformations to set the appropriate connection strings and other settings for the installation.
The problem that I have is that I have a shared web server controls project which really only needs two configurations - debug and release - but I need to copy all the above configurations into this project in order to get them to work. If I delete Customer2-Pilot from the shared project, I can't deploy to customer 2's pilot server because it is looking for the Customer2-Pilot configuration for the shared project which doesn't exist.
Currently, I copy the application's configuration names into the shared project but that is impractical as we have several applications each going to different customers so the shared project could get dozens of configurations which are all copies of Release or Debug
I would like to be able to configure the build system so that I can say that the Internal-Dev configuration of the web application project uses the shared project's Debug configuration and all the other configurations use the shared project's Release configuration. This is possible from within the IDE, using the configuration manager which can tie a solution configuration to individual project configurations but I'm not sure how to do this from within teamcity.
My current teamcity configuration is using the MSBuild runner with the web application's project file as the build file path and the configuration parameters set to deploy it to the relevant server with the correct configuration after it has been built. The shared project is in a sub-repository of the web application repository so it is fetched and built automatically.
Is there any way that I can change this set up to get what I want? Do I need to change the build file path to be the solution instead of the project so that I can use the configuration manager settings to configure it?
It turns out that this is as simple as changing the build file path parameter to be the solution file instead of the project file. This means that you specify a solution configuration instead of a project configuration. Solution configurations are managed in the configuration manager and you can specify the configuration of each project in the solution configuration so it all works nicely.
I have two projects that need to be published (a web application and a WCF service application) and they depend upon five other class library projects. I have it set up so that the class library projects are built using either the Debug or Release configurations and the two projects that have config files that need to be transformed have one configuration per system.
One thing of note. In the old set up I had to have two build steps - one to build and deploy the web application and one to build and deploy the WCF service application. When I use the solution file as the build file, I don't need two steps any more as they are both part of the solution and so they both get built and deployed.

How to configure IntelliJ 11 + remote tomcat 6 + maven imported modules?

Here is what I have now:
Imported multiple maven modules into IntelliJ project
Maven targets run OK from the Maven Projects flyout - a war file is created.
Making the project from the "Build|Make Project" is OK too. But here no war is created, just the .class files.
Tomcat 6 running on another machine
Manually deploying the war produced by the package maven goal to the remote tomcat works OK.
A local tomcat 6 instance is configured as an application server. I am not going to use this instance, but the JetBrains documentation says I must have a local instance in order to have an application server configured with the IDE.
No artifacts and no facets are configured for the IntelliJ project.
The remote tomcat is run with JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=1317,suspend=n,server=y
I want to be able to debug my server in the IntelliJ. Which means, that I must have a Run configuration, which does the following:
Produces the respective war file. Making the project does not produce any war, so it should be either modified to produce one or the war should be created as part of a Run configuration. I have no idea which one is the right way.
Deploys or redeploys it to the remote tomcat instance.
Lets me remotely debug the code.
How do I do it?
EDIT
Correction. One of the projects has the Web facet automatically added to it, because IntelliJ has noticed the ...\src\main\webapp\WEB-INF\web.xml file.
EDIT2
Here is my remote tomcat run configuration dialog:
The documentation says I should have the Perform on 'Update' action option in the dialog. Where is it?
EDIT3
I have added Spring support and Spring web services plugins to IntelliJ, since we are using them. Now IntelliJ recognized it and added the Spring facet:
However, there is still no Perform on 'Update' action option in the remote Tomcat Run Configuration dialog.
What am I missing?
EDIT4
The mystery of a missing Perform on 'Update' action option is resolved - How to enable the Perform on 'Update' action option in the remote Tomcat run configuration in IntelliJ?
1) Producing a WAR
To have IntelliJ IDEA produce the war file, you need to have a 'web' facet defined for the module.
Go to File > Project Structure > Modules
Select your module
Add (via the '+' icon or Alt+Insert) a web facet.
Configure the facet. (If you are following standards, the defaults should be OK, but check them.)
Once you have a web facet defined, you can then define a WAR artifact.
Go to the "Artifacts" page in the Project Structure dialog.
You will first need to create an exploded war artifact.
Click the add button
Select "Web Application: Exploded" and then "From Modules"
In the popup, select your module. Verify that the web application artifact is correctly defined. Again, if you are following standards, the defaults should be good.
Once the exploded artifact is defined, click the add artifact button again and select "Web Application: Archie", and then "For {module-name}:war exploded" (or what ever you named your exploded artifact if you did not use the default name).
Verify the configuration.
IDEA will now create a war file when you build.
2) Deploy to Remote Server
You can do this as part of your run/debug configuration. See next section.
3) Remotely Debug
You simply need to create a run/debug configuration to do this.
Go to Run > Edit Configurations from the menu
Click the Add Icon (or type Alt + Insert) and select Tomcat Server > Remote from the pop-up list
Configure the run/debug settings. I recommend clicking the Help button. It will show you what the various options are. (Be sure to pay attention which are available for Local, Remote, or Both.) Take a look at the "Remote Staging" information on the Help page. Also, be sure to select the deployment tab and select the artifact you want to deploy (and specify the context path.) The Startup/Connection tab, "Debug" section will have needed debug connection information that needs to be configured on the remote Tomcat server.
By default, "Make" should be listed in the "Before Launch" section. And once you add the artifact to be deployed, the before launch should also show that the artifact will be built. If not, add it.
Once defined, you can execute this run/debug configuration. To debug, launch using the "debug" button or shortcut (Shift+F9). This will make your project, create the war, deploy it, and then connect the debugger. If you just want to run without debugging, click the Run button, or use the shortcut Shift+F10.

Changing Maven profile while running with JRebel

I started using JRebel just moment ago. In my current setup launch JBoss instance from Eclipse and I use command line maven to deploy. I was wondering whether it would be anyhow possible to avoid redeployment when I need to change from test-A profile to test-B profile. Profiles are used here to set several configuration values.
If you're using JRebel, you should forget about Maven as there's no need to build the package after every change.
If profiles are used only for configurations, why not to make the changes to the configuration files directly? Depending on the nature of the configuration files these can be handled by JRebel. What are those configuration files?
You can't change profiles for already running Maven instance. But you can activate specific profiles on Maven startup using system properties.

Resources