Tomcat couldn't see servlet - java

When I run my webapp with Netbeans it works perfectly, but I can't everytime for using this webapp open netbeans and run it. I download netbeans with apache tomcat, and with netbeans it works fine. But then when i need to run tomcat separately, i have problems. I run it, open webb app manager, deploy war file of my project. Then i try to run it, so i have first index.jsp page without problem, then it should do smth in servlet pages, this things doesn't work. So tomcat couldn't see servlet. I know that problem may be because I don't have web.xml file, it wouldn't generated automatically, because of mine is servlet 3.0 or smth, so i have this annotations #WebServlet(name = "zakaz", urlPatterns = {"/zakaz"}) but it still doesn't work. I can't understand why, do you have any ideas?
I get null pointer exception in Tomcat

Related

Cant get tomcat to show webapp from deployed .war file

I followed a tutorial and am trying to learn to make my own web app. I am using Tomcat 8.0.47 and Spring MVC. Issue is I can go to localhost:8080 and see that the server is on but I cant see my basic webapp running when visiting localhost:8080/CrunchifySpringMVCTutorial page. I made a WAR file and dropped it into the /webapps/ folder inside tomcat folder and console shows that it deployed the war file. Any help is appreciated.
I am following this tutorial: http://crunchify.com/simplest-spring-mvc-hello-world-example-tutorial-spring-model-view-controller-tips/
rather than paste all the files I decided to link the guide. My set up is the same but cant figure out why it is not working. thanks.
Looks like the issue was that I needed to add the CATALINA_HOME system variable to properly setup my tomcat server

Run JSP from netbeans project in Tomcat Server

Hi I already develop my application using Netbeans IDE.
Now I want to run my application in Tomcat server for actual use. I already copy my project to tomcat/webapps.
But when I tried to run my application:
http://localhost:8081/myAppFolder/
it gives me an error message :The requested resource (/Opportunities-Registration/) is not available.
I should change the url to make it work:
http://localhost:8081/Opportunities-Registration/web/index.jsp
How can I open my application using http://localhost:8081/myAppFolder/ insteand of http://localhost:8081/Opportunities-Registration/web/index.jsp ?
Update:
All my servlet is also become 404 not found
Thank you
SOLVED
Solution:
1. copy .war file which is contained in dist folder of your netbeans project
2. Place your .war file to tomcat/webapps
3. Start your tomcat
4. You are good to go

Cannot deploy using Apache Tomcat but deploying with Eclipse works

I'm trying to deploy my java app as a web service using Tomcat Apache. I put the .war file under the /webapps directory, run Apache, and when I try to access the url I get a 404 error.
I've created my app on Eclipse, and if I try to deploy it from Eclipse using a Tomcat server, it works, I can correctly access all my servlets.
What might I be missing / doing wrong?
Thank you,
You either have the wrong URL when you run outside Eclipse or the WAR file that you deploy is incorrect.
You should look at the Tomcat logs and console to see what messages it gives to explain what you did wrong.
Eclipse is just an IDE. Your code won't have access to it in production. Put aside that it works there and figure out what you did wrong with the package.

How Tomcat Notify about When New Jsp being uploaded

when we directly upload JSP page into tomcat where application deployed directory then why we don't need to restart Tomcat? how tomcat know that it has new JSP page?
when user hit the url /myapp/mynewjsp.jsp He/She always get new jsp deployed page.
Tomcat has an auto deploy feature. When you update JSP files it detects you have done so, compiles it, and replaces the old compiled JSP page with the new one that it compiles into a java class.
http://tomcat.apache.org/tomcat-6.0-doc/deployer-howto.html
If you don't want that to happen, you can turn off the auto deploy feature for your web application. It is described in the link how you do that.
Hey you can use jetty plugin for auto deploying tomcat folder . You don't need to paste your file on webapps folder. If you using maven project structure then add jetty plugin on pom.xml file . There is some command to run like mvn jetty:run etc... May these solution get you out from these problem

Integration testing with JUnit and Jetty, can't configure url

I have web application that has been developed and run locally using tomcat, the routing has been configured and everything is working fine. Now, i need to run some integration tests using JUnit and Jetty (the plan is to run those before deploying), for that i'm using following code:
server = new Server(2020);
WebAppContext webapp = new WebAppContext();
webapp.setContextPath("/projectName");
webapp.setWar("build/libs/myWarFile.war");
server.setHandler(webapp);
server.start();
Jetty servers starts up just fine, now the problem is that neither of my links are working. So for example when running project on tomcat, i could access some page like this:
http://localhost:8080/projectName/page
But accessing same page from tests returns error code 404:
http://localhost:2020/projectName/page
I've poked around a little and found out that the only page that is "working" is http://localhost:2020/
It shows the content of my WebContent folder (2 folders META-INF and WEB-INF, neither of which can be accessed). So i feel like i've missed some important part of configuration, any help?
I've dealt with the issue, it turns out that the code was correct (besides the setContextPath which was pointed to me (edited now) ). The issue was in .war file that was generated in gradle (a lot of things were missing for some reason, so it had to be built using Eclipse tools Export -> WAR File

Categories

Resources