AWS Java - Referencing file included in my .War package not found - java

I need this file to authorize my API request to an external service. My app is deployed in Elastic Beanstalk with a WAR package and my file is stored in WEB-INF/lib but when I route my service to this address nothing is happening. My java classes are stored in WEB-INF/classes and its subfolders (due to packages). Should I use any absolute address instead of a relative one? Any ideas about what may be happening?
My build.xml file to generate War package with ant:

Looks like you are missing dependencies. I have never seen this issue when building a web app using Spring BOOT and Maven. As well, when building with Maven/Spring BOOT, I always ensure to use spring-boot-maven-plugin that builds an executable JAR file which includes the dependencies.
TO learn how to create a basic Java app with Dependencies and deploy to the Elastic Beanstalk, see this AWS tutorial.
Creating your first AWS Java web application

Related

Using azure to run java app but access not working

I just started to work with the azure platform and I have a Question.
I upload my app to azure and run it but when I try to access it, it does not work but returns a 404 not found.
Maybe I did something wrong?
This is the repo that I connected:
https://github.com/idanovadia/ServerAlgoSearchImplementation_v2
for example when I run it on local host :
http://localhost:8080/getMaze/prim
now I tried :
https://searchnow.azurewebsites.net/getMaze/prim
I see that you try to package your java app to a jar file, and run the jar with a web.config in web app. This is the old way to run spring boot application.
In fact, there is a common and better way. It is just to package your spring boot application to a war package. And then you can deploy it to Azure web app with tomcat container.
1. You need to choose to package as war when you initialize the spring boot project:
2. Set the packaged file name to ROOT.war
Open the pom.xml, add the following line:
Then you will get a ROOT.war file if you run mvn clean package
3. Create a web app with Tomcat
4. Deploy ROOT.war under \site\wwwroot\webapps folder in web app
5. Restart your web app.

How to add Opneshift config maps files to a spring boot web built in tomcat

Below my project structure
I have multiple modules in one parent maven project.
Many of above modules can also run as independent project including some of them as Openshift applications. These are spring boot applications
Now I want to add one more module as Spring boot web application on Openshift that uses Spring web in build tomcat.
Also I have multiple property files which are specific to environment and I load them as Configmaps on Openshift.
Now when I am trying to deploy the new web application, it is not able to use the Configmaps. It error says property file not found. I am sure this is because the Configmaps are outside of the tomcat and application.
Can I have any work around as I don't want to put those property files in the war while building but should get added when I deploy or start the pod on Openshift.
In short I want something like I can put configmaps as files into the class path spring boot web application that uses in built tomcat.
Mount the ConfigMap-s as volumes at some path and then configure Spring Boot as described here.

Deploy a war file in the application?

I am trying to integrate the monitoring tool JAMon into my current Spring application. Everything is fine except I don't know how to establish the monitoring information on UI or log file. What is more confusing, is from here
under the section "Setting up the JAMonAppender - Default Behaviour", I see this line:
Install JAMon.war in your application, so you can view your Log4J
statistics and log records.
is there anyway that I can install a war file in current application or there is something wrong with above description?
My understanding is the war file should deployed in an application server. Can I use it as a dependency?
My understanding is the war file should deployed in an application
server. Can I use it as a dependency?
Any WAR file must be deployed in an application container. It cannot be used as a dependency. For your sake, you missed point 1, where you can download the API with all its dependencies here.

How to filter webapp src/main/resources and see replaced values with JBossTools

I have a maven web application which has the file src/main/resources/appContext-ejb.xml file which has the ${version} placeholder in it.
I want that placeholder to be replaced by the version of the maven project, so I 've configured the maven resources plugin to enable filtering of the file.
After compiling with eclipse I can see the file under the target/classes directory with the correct (replaced value).
Also when packaging the war archive the file is being replaced without problems.
My problem is that I want to use the JBoss Tools eclipse plugin to start my web application, so I create a jboss server, and add my web application to it. When I start jboss (from within eclipse using jboss tools) and try to use my application the piece of code which needs that file with the replaced value fails telling that ${version} was not replaced.
Does JBoss Tools plugin use src/main/resources instead of the contents of target/classes?
How could I configure or make Jboss Tools use the already replaced file in target/classes?
I 've searched the web for this and I 've found a lot of information on how to enable filtering to web resources so that jboss tools takes changes on the fly, but I believe that that's not helpful for me because this file should not be used as a web resource because it shouldn't be served as web content.

Create webservice from jar file that used maven

I am developing a project(Spring+Hibernate+Maven+Intellij Idea for develop) without any application server such as tomcat. Now I don't know how create Web Service from my project to use it in other projcets ?! My Question is how to create Web Service from jar file that created by maven?
You can embed Jetty in your application or use Restlet which provides an embedded server.
Simply add them as dependencies and have all the resolved jars on your classpath (the maven assembly plugin may help you package your application)

Categories

Resources