Debugging java web application with secondary tomcat folder serving static content - java

I have a java web application which I can debug using IntelliJ or Eclipse through a local machine tomcat 7 configuration (localhost:8080/javaapp)
I was hoping to be able to reference static content not part of the java application - installed locally at /staticapp. However, IntelliJ launches tomcat with only the java application available, the other application is not launched or serving the files.
Is there a way to configure tomcat so that either:
- the /staticapp is also started when the /javaapp is launched so it may be accessed from /javapp pages
- tomcat will always serve the static content from the /staticapp folder while running... the staticapp folder tree is not a real "web application", it only contains folders with javascript/css/images
Thanks

In eclipse, open you Tomcat server settings and go to the "Server Locations" option. Choose "Use Tomcat installation".
Next, change the deploy path to Tomcat's (original) /webapps folder, instead of the eclipse setting wtpwebapps.
Add your static app manually (folder or .war file) or though eclipse to the webapps folder, then when you publish your "javaapp" Tomcat should start each web application in its deploy path.

Related

Can't get a Java Spring webapp to deploy to Tomcat

I've got a project in Eclipse, with a .war file inside it. I'm using Spring for the project, with the help of Maven too.
I've installed Tomcat 8, but I'm having trouble deploying the webapp to Tomcat. The Tomcat runs without errors and the console output of launching the Tomcat looks like it is successfully deploying it, however when I go to localhost is just displays the generic Tomcat home page saying I have successfully deployed Tomcat.
I've tried changing my server location to use the tomcat installation, I've changed the location in the properties of my server to not be the workspace metadata.
When I add jars to the tomcat, I click on my project, and under it it lists the Spring jar if that is of any relevance.
I don't really know what else to put here at the moment, but I'm at hand to respond immediately to any questions or any more info that you require.
Thanks.
EDIT:
http://localhost:8080, it leads me to this: http://i.imgur.com/82lmpai.png
My tomcat console output is: https://gist.githubusercontent.com/J-Owens/8164b3ec6dbed9986322/raw/6756486aad0092647bbea8f315c42ac5ba9550b1/tomcatconsole
Each war file will have a name associated with it. When you use localhost:8080 as the URL, Tomcat will use the war with name ROOT under tomcat/webapps to display on the browser. By default, Tomcat will have a ROOT war that comes with the tomcat bundle. If you need to open your project, you will need to use localhost:8080/<your-war-name> to open your project's page. Alternatively, you could remove everything under tomcat/webapps and rename your war to ROOT to be able to access your project pages with the localhost:8080.

How to start tomcat server outside netbeans IDE

I have created an application in Java EE, I have learned how to deploy it in the tomcat server using the manager app or by copying the war file to the webapps folder. Now I can start the tomcat server only from the Netbeans IDE.
I want to know how to start the apache tomcat server without using the IDE and run my web application from the war file deployed. If I'm headed in the wrong direction please correct me. I'm asking this to gain knowledge of how to deploy the .war file in another server system without using the IDE only the tomcat server.
The shell scripts located in "CATALINA_HOME/bin" are the most bare-bones way of getting Tomcat up and running. The two scripts capable of starting Tomcat in this directory are named "catalina" and "startup", with extensions that vary by platform.
In your tomcat installation directory, there would be a startup.bat/sh file which will start the server for you. Moreover you can see the conf folder as well if you want to change any configurations. Whatever war you copy to the webapps folder will be automatically deployed

Tomcat 6 is running in Eclipse but localhost:8080 never responds in browser

I integrated Tomcat 6 into Eclipse Indigo. When I start the server in Eclipse, it shows that Tomcat is up and running, but when I go to localhost:8080 in my browser, it does not respond at all.
I have Tomcat server entry in the Servers tab with "Use Tomcat Installation" and it didnt help me.
I have removed my entire projects from eclipse and started importing it again to set it up from the beginning and it didnt help either.
Could you please some help me out?
It is most probable that you are running Tomcat from eclipse as Use workspace metadata (does not modify Tomcat installation). While running under metadata, tomcat's default welcome page is not deployed. So you wont be able to view the welcome page under localhost:8080/ but you can access your application with the application context in the url ( something like localhost:8080/yourApplicationContext/hello.jsp)
See below the image where you can set the server location. If you change it to Use Tomcat Installation, eclipse will use the actual installation of tomcat. You can even see this by deploying the application and then open up your file browser, navigate to tomcat directory and you will see your application deployed there in the webapps folder. But if you use use workspace metadata option, eclipse makes a stripped copy of your tomcat's installation and places it in the .metadata folder of the workspace. Something like eclipse_workSpace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\
The question as to which technique is better totally depends on your use.

Auto start glassfish with RESTless service

I've been looking for instructions on how to automatically start my GlassFish server with my RESTful application on top of it. I have it installed via the NetBeans IDE and I normally control it through NetBeans but I need to transition away from the dev environment to a test environment. Links to tutorials would be appriciated.
How to start a Glassfish instance when the server starts: that's operating system dependent, on Windows it involves registering Glassfish as a service, for Linux you can follow this tutorial.
How to start an application with Glassfish, or how to migrate an application from the instance embedded in Netbeans to a production server: two easy ways
register your production server in Netbeans, in project properties change the Run target to that newly registered server and deploy via right click on the project in the Projects view, option Deploy.
When you Build a project in Netbeans, a dist subdirectory will be created in the project directory - switch to the Files tab to see it. That directory will contain the compiled and packaged projet (jar, war or ear depending on the project type). Point your browser to the administrative interface of the production Glassfish (in most installations http://yourproductionserver:4848 ), select the correct application type in the tree on the left, click Deploy and upload the file from the dist subdirectory.
Personally I prefer option 2 but that may be a matter of taste. Thorbjørn already explained yet another possibility, via the autodeploy folder. Whichever you choose, the application will start once deployed and will automatically start every time the Glassfish server starts.
Create a WAR or EAR and put it in the autodeploy folder in the domain.
Then it will start every time Glassfish is started.
Additionally under Windows you can use the asadmin create-service facility to create a service (.NET required).

Glassfish v2.1.1 and java-web-start

I've started a job that uses Glassfish 2.1.1 app server and noticed there's a java-web-start directory under the domain1 folder. In That folder there are empty directories which correspond 1:1 with ear (and other files) files deployed under ....\domain1\applications\j2ee-apps.
What is the purpose of the java-web-start folder and why does it have those empty directories in it?
New to Glassfish.
TIA
Glassfish allows the user to launch a local client which can access the application inside Glassfish directly. The launching happens with Java WebStart.
See http://java.sun.com/developer/technicalArticles/J2EE/jws-glassfish/ for an introduction.

Categories