Migrating an Enterprise app from JBoss to WebSphere - java

I am trying to migrate an enterprise application from JBoss to Websphere 8.5. The application is configured with Spring MVC and tiles. The application is hosted in the server root of the JBoss Server, i.e. to access the application we just type https://localhost/ in the browser.For this reason all the links and association in the applications are currently written as follows:
<link href="/resources/jQuery.js" .../>
...
Home
etc.
But in WebSphere the application needs to be in a context root viz. https://localhost:9443/MigratedApplication.
The problem is that all the links and resources mapped in the application now are inside https://localhost:9443/MigratedApplication/resources but they are still looked for in https://localhost:9443/resources resulting in errors on the application throughout.
Any ways to resolve the issue by configuration in WebSphere?

Unfortunately you have hardcoded paths in your application, so you have 2 choices:
change the context root of the application on WebSphere to / as in JBoss (probably easier one, as doesnt require changes in application)
change all links to relative ones (this should be done in the first place during application development to make it independent of context root)

Related

Issues deploying a Java application to Tomcat

I built a simple Java web application. It provides a series of RESTful APIs for the user to carry out certain operations on a Java DB through a web interface. I used NetBeans environment during the development, and Glassfish for testing.
Now that I finished it, I would like to be able to deploy it on another machine using binaries (although as for now I use the same machine until I learn how to do it).
I installed Tomcat 7, and moved the .war file into Tomcat's webapp folder. The application deploys. Thereafter I try to read some data from the databse using a button I created just for this, but get the following error
I am not sure what went wrong, but I have two theories.
1) The web application cannot connect to the database. Yet when I attempted to run the application again, after starting JavaDB from NetBeans, there was no difference.
2) Somehow, the application cannot reach the Node service. I assumed that there will be no need to change the API links while moving the app, but perhaps I was wrong.
Or maybe there is some other issue I did not consider? I will be grateful for any advice about how to properly deploy such an application.
EDIT: The issue was solved by using TomEE.
The error is come from your application server of choice.
TomCat is only a servlet container (means it only support Servlet/JSP).
Any other feature (JAX-RS, CDI etc) require a Java EE certified server e.g. GlassFish, WildFly,Payara, WebLogic, OpenLiberty or TomEE.
TomEE could be your best bet if you want to use TomCat in your production or test environment, it is basically TomCat + Java EE other feature.
EDIT:
TomEE don't have a GUI for JNDI datasource configuration like GlassFish, you need to edit conf/tomee.xml
<Resource id="myDataSource" type="javax.sql.DataSource">
jdbcDriver = org.apache.derby.jdbc.ClientDriver
jdbcUrl = jdbc:derby://localhost:1527/dbname
userName = app
password = app
</Resource>
And in your java code:
#Path("resources")
#Stateless
public class MyResources{
#Resource(name="myDataSource")
DataSource dataSource;
#GET
public Response SomeMethod(){
//Do stuff here
}
}
You can check here for more detail configuration on data source.

How to deploy a non-Liferay web application to tomcat bundled with Liferay

I have decided to use Liferay for my next project and I'm trying to somehow get an old non-Liferay web application deployed on tomcat 8 that was bundled with Liferay. The application uses servlets.
After some googling I got the impression that it should be possible to simply deploy the application on tomcat which I did. Liferay does pick it up from the /deploy folder but there is an error while deploying it saying web.xml needs to be upgraded to 2.4. My web.xml is almost empty because I use #WebServlet annotatations for servlet mapping.
So my question is, is it possible to deploy a non-Liferay application to tomcat that comes with Liferay without making any changes to it?
You should only place Portlet-WARs into LIFERAY/deploy, as Liferay will try to convert such WARs into a Liferay specific Portlet-WAR, before deploying them in Tomcat.
If you need to deploy a legacy WAR you should place that into LIFERAY\tomcat...\webapps\ and Tomcat will start it without any modification.

Java Web Container implementation independant development

One of the most important non-functional requirements of any project is the build process in my opinion and that's where I kinda get stuck in my java project, which has just one external dependency, a jdbc compatible database. All the tutorials about spring and deployment out there; I've read them all, but they either say:
run it with gradle bootRun applications.properties (yes works but on a webserver I'm not going to have any properties-files, but JNDI resource for example) or
build a deployable war file with JNDI resources (yes it works on the webserver, but not in my embedded webserver or I'm doing it wrong, but I cannot find any doc about how an embedded tomcat loads a context.xml from outside the jar file).
Now I tried to use the same setup as my server and installed tomcat7 and the #Asyc #Scheduled services run, but no servlets, like a simple /status page should return "OK" just for checking. catalina.out does not show any errors. My /manager from tomcat7-admin says deployment ok, and when I click start: "FAIL - Application at context path /xyz-0.1.0 could not be started
FAIL - Encountered exception org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/xyz-0.1.0]]"
And now I want to make a cut here and throw every "bootstrap" stuff away and start from zero.
So my question is, am I wrong when I say, that the big deal of my deployment is a jdbc JNDI resource provided from the web container, which is called 'jdbc/xyz' and everyone who wants to deploy my war needs that JNDI. That means so matter if you're using wildfly, jboss, tomcat, glassfish or any embedded server: your server impl has to provide that web container and jndi resource to make it run. And I don't want to configure any tomcat, glassfish or whatever implementation in my war.
Is that wrong?
It would be great, if you could help me. I'm playing around with that many weeks now :( and if A works B does not and vice versa. Would it be easier to use JEE?
Thank you.

Deploying a Spring app to Weblogic with no web components - war, rar, or ejb?

I'm deploying a new Spring JMS application to Weblogic 11g. What is the accepted way to deploy a Spring application with no web components to Weblogic?
Historically the apps I've been working on have used a WAR to load the application context. This does not seem like an acceptable solution now since this new application does not have any web components. Wrapping the deployment in an EJB does not seem acceptable either since Spring is supposed to be a replacement to EJB. A RAR does not seem to fit either, since the new application is not supplying any resources to other applications.
What options do I have, what is the accepted deployment method here?
Actually RAR archive is used for resources.
Firstly you should create the components of JMS in WebLogic side (JMS server, JMS module, JMS connection factory, queue or topic) that your application may use. When this components are integrated all that you need to create the EAR archive and deploy it. EAR can be created without any EJB modules.

Difference between an Enterprise application project and a Web project application in Netbeans IDE

Please I would like to know the major difference between a Jave EE project and a Java Web project in netbeans IDE with respect to the EJB. In fact you can create a web application based on EJB, JPA and JavaServer Faces in Netbeans IDE if you choose the Java Web category.
On the other hand you choose the project category as Jave EE project, NetBeans IDE will create 3 sub-projects, e.g: StoreApp (Enterprise Application project), StoreApp-ejb (EJB project), and StoreApp-war (Web project).
The first one will be packaged as a single .war file, the second one will be packaged as an .ear file, containing the web .war and the EJB .jar.
The difference between these is a bit broad to handle here, but I wouldn't advise on creating EARs unless you know that you want/need to.
I think you should learn firstly about web server and a application server..
well i'll happy to help you.
1) we cannot run enterprise application in web server.. i.e. if u are using EJB etc. to run this EJB project you have to use Application Server like JBoss and many more.
2) while using web server it cannot load any heavy application means if your application having multiple users , in that case connection pooling will come into the picture. for connection pooling Application server much better then web server.
For more you can visit below link:-
What is the difference between application server and web server?
I hope it'll helps you
Thanks!!!
There are 3 kinds of project/application:
Standalone Java application and sometimes call it as swing application. Bundle it in the form of Jar and you can run this application without any web or application server.
Web-application: Basically we have to create a war which is combined with html/jsp,jar etc. This war file has to deployed into webcontainer.
Enterprise Application: We have to create a EAR file which is combined with war, EJB & jar. This has to deployed into application server.
A very helpful tutorial https://www.youtube.com/watch?v=6vMB3rzN_Xw
Hope this helpes... cheers!!!

Categories

Resources