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

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

Related

Tomcat reloading exploded war with spring-loaded

There's alot of questions on different forums [1] [2] [3] about this topic but none seem to provide a definitive answer. I've tried different combinations suggested in the various posts but I have yet to succeed.
My goal is to make compiled source code in a standalone tomcat (8) reloadable - just like the embedded tomcat reloads newly complied sources in e.g. spring-boot or Grails. There are a few constraints that I need to comply with:
No Grails or Spring-boot is available
No Maven or Gradle is available
The tomcat should read the exploded war file from an external location
To keep things simple I use a very simple JEE app with Spring MVC as POC for this before I move on to the real deal. The setup is as follows (for now):
Exploded war builds into directory target/exploded
Tomcat is setup with default settings except from Context.xmlwhere the two lines regarding WatchedResource are removed. Context is not set to reloadable="true".
The Tomcat server is run from within IntelliJ Idea (2016.3) like this:
where the "exploded" folder points to the target described above. And the "Server" tab like this:
The server starts up and the app is running fine. I then try to change some code, save it, and build a new exploded war file. I can see the class files change - but nothing is reloaded in tomcat.
Can anybody please elaborate? Is this approach even possible - in contrary to what many posts suggest? How is it possible in the embedded tomcat in e.g. Grails?

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.

java.io.filenotfoundexception jboss project localhost

I've been working on web project written in jsp and running on jboss. I have problem after deployment of project. I'm getting an error after hitting localhost:8080/Myapp : java.io.filenotfoundexception Null/easyfile.properties <Can't find easyfile.properties>. I have this file in conf folder in my app directory. For sure I need to properly point to this file or place it somewhere in jboss installation folder but unfortunately I'm new to Java and 've been working with PHP but I've been assigned to client who has home site written as one jsp site with some xml. I need to change their frontend a little bit but I'm trying to set up my local environment without success.
Any help would be great.
Regards Adam

Tomcat couldn't see servlet

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

War works fine on local standalone tomcat 7 (no eclipse), does not work when uploaded to ec2

I am able to get the spring blazeds examples and war (http://docs.spring.io/spring-flex/docs/1.5.2.RELEASE/reference/html/#pre-built-samples) working locally in tomcat 7 webapps directory (i initially had problems with this but now it works fine locally), however when I upload the same war file to amazon ec2, tomcats starts up fine and i can see the project's index page but none of the projects scripts are executing. According to the catalina.out log, the server started up successfully without any errors. Please help.
thanks,
tone
*Update
I am assuming that the problem resides in the blazeds portion of the project? Not sure if it is executing properly. i have enabled ports 8080 and 8400 in the security group.
Nevermind I found out the issue. i had to recompile the swf files that comes with the project to point to my ec2 instance url instead of localhost.

Categories

Resources