I'm working on project which has an existing war file containing java code. Currently this project is deployed on tomcat but war is not placed in webapps, it is in different location and referenced in tomcat using file containing following in Catalina/localhost folder.
<Context docBase="war path/<file.war>" unPackWAR="false"/>
My requirement is to design a restful webservices for this existing project. I have setup a standalone dynamic web project with Jersey REST setup and its working fine. Whenever a rest call will be made it needs to call its underlying api(existing one).
Note: Both the projects are deployed on same tomcat container, but existing war project file is un-extracted and resides in different location.
Also i dont want to combine both the project into single war.
Could some help me figure out how to call the existing java functions from new REST project?
Can JMX connection work in this case or is that recommended?
Appreciate your help!
Thanks,
Related
I am about to create a backend for a web application with Java servlets for a REST Api only, which should base on
Java 11
Maven
Tomcat 9 (externally to project)
JAX-RS
Jersey
Then I am using Eclipse and I have created a dynamic web project and converted it to a Maven project.
Some problems in the project / folder structure might be caused by this. Here is the structure:
When I let the server run and hit localhost:8080/hello_world I can see the index.html in the browser.
I actually have two question:
Having a real WebContent is wrong, isn't it? I should have a real webapps folder, but the WebContent folder should be virtual (from Eclipse), right?
How can I separate the index.html and or at least all other frontend resources (HTML, CSS, JS (React.js etc. pp.)) to a separate folder for heaving one repository for the Java Web Servcice and another one for the frontend? Is this impossible with this tech stack?
I believe that your web service URL is not complete and you have to check your web.xml url-pattern tag and the Path annotation you have defined for your services.
In order to have a better prospect of Restful web services in Eclipse IDE, I suggest you follow these HelloWorld examples (simple hello world rest service and CRUD web services using jersey) to widen your horizon about some configurations in web.xml in which you have to define your container to your application server and corresponding pom.xml for jersey dependencies.
it is ok to have the WebContent folder in Dynamic Web Applications and there is nothing wrong with your project / folder structure
For the past couple of days I've been playing with EJB's and trying to deploy my project to actually see if it works..
What I'm trying to do is this:
I created an EJB project in which I have two Entities (Student and Grade) and the local and remote bean.
Now, I want to create a Servlet along with a jsp file to add Students and Grades into the Database through a web form.
I feel a little lost in this steps of working with EJB. Should I create another project in which I integrate the ejb jar in order to work with it in a Servlet?
Also, how to I deploy a project like this on a Glassfish / wildfly server independent from an IDE?
If someone can bring some light on what are the steps of doing this, it will be much appreciated.
You don't need to have a separate project for EJBs.
Create a web application project and put your EJB classes along with your Servlet classes.
Compile and put the war (eg. mywebapp.war) file into the standalone/deployment directory of your wildfly installation.
Now, access your servlets from a browser:
http://localhost:8080/mywebapp/servlet/path
I have created application in Dropwizard, which is serving REST API to my clients. I used to run this from .jar file on server, everything worked fine.
Now I have requirement to move my application to WildFly, so now I assume that I need to have a WAR instead of JAR, and here comes my problem:
How to write web.xml to my application? What to include in there? Could anyone give me any template or tutorial or some example how it is done in Dropwizard?
I found what I was looking for. It's wizard-in-a-box project that do all the necessary things to build a WAR file.
I'm trying to run a website using Tomcat and Eclipse. I created a Dynamic Web Project, I configured web.xml file and I also used Maven. In a directory src/main/webapp I put an index.html file. I also made a simple REST service in the same project. So this REST service is working for me (for example, when I put "http://localhost:8080/RESTfulService/rest/item" in an address bar. But what is the address that I should write to get an access to a website I put in a webapp folder? I thought "http://localhost:8080/RESTfulService/" should be working, but it's not.
From what i understand of your setup, try "http://localhost:8080/index.html". Do you have a context path called 'RESTfulService' setup?
Do you have a context element listed in your server.xml? If so, what does it say?
I implemented a custom login module I want to use with the JBoss AS 6. I followed some tutorial guidelines on the internet, namely http://x-techteam.blogspot.com/2007/04/jboss-custom-login-module-simple.html.
They write about configuring ${JBOSS_HOME}/server/default/conf/login-config.xml and deploy a JAR with the custom login module, but I don't like the idea of changing a configuration within the JBoss folder.
I really would like to have ALL configurations within my WAR file. The EE application I write will be sent to some customers and they should not have to worry about configuring some security contexts or roles via XML.
So my question is:
Can I have a local login-config.xml within my war that will be picked up by JBoss?
Can the custom login module class remain within my war, without having to deploy it to some JBoss folder?
Thank you in advance.
Use dynamic security domains:
link