Liberty on Windows/Linux - websphere-liberty

I try to deploy a JAVA application on Liberty (I will use <> as place holder)
On Windows:
If I add my application in Eclipe with the help of the Add and Remove.. Ressource, the application runs successfully on Liberty. In \wlp\usr\servers\<ServerName>\apps a new file <MyAppName>.war.xml is created:
<dir sourceOnDisk="C:\<MyAppName>\<MyAppName>-source\src\main\webapp" targetInArchive="/"/>
On Windows:
If I create in \wlp\usr\servers\<ServerName>\apps the file <MyAppName>.war.xml manually and link it to the <MyApp>.war directory:
<dir sourceOnDisk="C:\Users\<userName>\Desktop\<MyAppName>.war" targetInArchive="/"/>
the application runs successfully.
On Linux:
I want now to deploy the same war on a Liberty server on linux. The problem is the structure of the directories- it is completely different than in Windows.
In the appl directory, there are the following subdirectories:
appl_dropins
wl_config
Where do I have to put the file <MyAppName>.war.xml? And the server.xml? Why is so different on Linux?
On Windows the structure was for the <ServerName> apps, dropins, logs,resources, tranlog, workarea + the File server.xml
Thank you in advance.

When you deploy directly from Eclipse it is pointing to the workspace by default, which is good for development, but not for deployment to other environments.
You have following options:
change publishing options in Eclipse to publish war by unchecking 'Run applications directly from workspace'
Export application from Eclipse using Export > War file
or create packaged server - right click on your server select Utilities > Package server and then use 'usr' option.
Packed server option is quite good for moving between environments, as it gathers all - application, server.xml, and any other files you had in the server folder. Then you just unzip archive on your target host and run the server.
As Alasdair said there is no difference in directory structure between Win and Linux, so either you have some different product on Linux, or it was heavily customized by someone or some tool.

Thank you for the fast answer.
I did as you said. I created the war <MyAppNewName.war> file, unzip it <MyAppNewName> and put it in the dropings directory. When I start the server, I get among other exceptions the following one:
[ERROR ] CWWKZ0005E: The server is not configured to handle the resource at location C:\kits\wlp-webProfile7-18.0.0.1\wlp\usr\servers\newTest\dropins\<MyAppNewName>\index.xhtml.
For the App in the orginal question, the file <MyAppName>.war.xml contained
<?xml version="1.0" encoding="UTF-8"?>
<archive>
<dir sourceOnDisk="C:\Users\userName\Desktop\MyAppName.war" targetInArchive="/"/>
<dir sourceOnDisk="C:\MyAppName\MyAppName-source\target\classes" targetInArchive="/WEB-INF/classes"/>
</archive>
In C:\MyAppName\MyAppName-source\target\classes there are the .class files and the war does not contain them.
So how do I add the .classes to the war?

Related

Running Spring application outside of an IDE (preferably OS shell)

https://www.pegaxchange.com/2018/01/24/java-web-project-with-spring-framework/ has instructions for creating a Java Web Project with Spring, without Maven. I am able to get it working in an Eclipse environment. It works as expected by doing “Run As” --> “Run on Server”.
When I kill Eclipse I get the Status 404 error (“The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.”). I have verified that the Tomcat Server is running from the XAMPP Control Panel.
How do I launch the application from an OS shell (Windows & Linux) so that I don't see the 404 error?
Its been a long time I haven't used java web projects without maven but if my memory serves me right, you should first export your project as .war file. Then deploy it to tomcat.
In eclipse right click your project select export and then select WAR file.
Copy your WAR file into webapps directory which is located in tomcat installation directory.
Rename the WAR file as you like if you want to serve you web app with a specific context name something like http://localhost:8080/myapp. If you do want to serve as root without a context name just rename it as "ROOT".
Run tomcat by command line <your-tomcat-installation-dir>\bin\startup.sh or it will be a .bat file for windows so you should end your command with .bat.
Or if you can start and stop by XAMPP panel this should do the same as well.
Also you can see this article for details on how to deploy a war file to tomcat.
I hope this helps. Cheers!

Websphere 8.5 context root change not applying to war file

I need a little help changing the context root of my war in my Websphere 8.5 appserver.
I have a war file called test.war When I deploy it to websphere the context root is /test
However I want to change this to be /example
When I looked online I read I need to include WEB-INF/ibm-web-ext.xml within test.war so I added that and enter the following:
<web-ext
xmlns="http://websphere.ibm.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-ext_1_0.xsd"
version="1.0">
<context-root uri="/example"/>
</web-ext>
When I deploy again the context-root is still /test That file has had no effect.
Is there something I am missing?
The easiest way after installation, is to open web admin console and change the context-root via:
Applications > Application Types > WebSphere enterprise applications > application_name > Context root for web modules.
You could do it also via wsadmin script.
You can provide context name, during application installation via admin console or you can change file name before installation as default context, when you install war is taken from the file name.
The last option would be to create EAR and define application.xml with web module like this:
<web>
<web-uri>test.war</web-uri>
<context-root>example</context-root>
</web>
"When I deploy again"
Did you perform an update, or an uninstall & reinstall?
When you update an application, WebSphere doesn't necessarily update the existing application's bindings (you need to explicitly ask WebSphere to discard binding information during an update). You have to select "Use new bindings" during installation in order to force WebSphere to pick up the bindings changes.
When you uninstall an application, all bindings information is lost, so when you re-install the same application, the bindings information included within the WAR file is used.

how to set java class loader PARENT_LAST

i have a spring mvc web application that I need to change the class loader on. I need to change the class loader to be equal to PARENT_LAST. I am using WAS 6.1 and already have a jacl script from a previous web application I can copy to do the job.
In the last application Apache ant was used and what they did was to make the deploy dependent on running the jacl script.
In my new web application I am using maven install to create a war file and am deploying that war file to my application server.
How can I set the class loader to be PARENT_LAST using maven? I know how to do it in the console but if there was a way to do it using scripting that would be nice.
Also will this setting be placed somewhere in the war file so that on deploy of the application the setting will be picked up. This question comes from my lack of understanding of how jacl scripts work?
thanks
If you are only deploying the WAR file itself you can't control this, but if you have your WAR file in an EAR file you can use the deployment.xml solution. The deployment.xml file would look something like this:
<?xml version="1.0" encoding="UTF-8"?>
<appdeployment:Deployment xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:appdeployment="http://www.ibm.com/websphere/appserver/schemas/5.0/appdeployment.xmi" xmi:id="Deployment_1347529484613">
<deployedObject xmi:type="appdeployment:ApplicationDeployment" xmi:id="ApplicationDeployment_1347544766353" startingWeight="99" warClassLoaderPolicy="SINGLE">
<modules xmi:type="appdeployment:WebModuleDeployment" xmi:id="WebModuleDeployment_1347543866613" startingWeight="1" uri="YourWebApp.war" classloaderMode="PARENT_LAST"/>
<classloader xmi:id="Classloader_1347543866613" mode="PARENT_LAST"/>
</deployedObject>
</appdeployment:Deployment>
Once you are done all you need to do is to add the file in the correct location of your EAR project build assuming you are using src/main/application that would be src/main/application/META-INF/ibmconfig/cells/defaultCell/applications/defaultApp/deployments/defaultApp/deployment.xml and build the EAR using Maven as normal.
During server deployment this will be picked up by WAS.
AFAIK there is no way to preconfigure WAR for PARENT_LAST during assembly. Classloading policy is specified during deployment, thus the way of setting it depends on how application is deployed.
Changing the policy using the script is straightforward. Scripts are run using wsadmin tool. The Jython snippet below does the job. It can easily be converted to Jacl.
dep = AdminConfig.getid('/Deployment:app_name/')
depObject = AdminConfig.showAttribute(dep, 'deployedObject')
classldr = AdminConfig.showAttribute(depObject, 'classloader')
AdminConfig.modify(classldr, [['mode', 'PARENT_LAST']])
AdminConfig.save()
Websphere uses deployment.xml file to govern deployment setting of each module in an ear file. You can change the classloader setting in deployment.xml at the following path:
/MyTestEAR/META-INF/ibmconfig/cells/defaultCell/applications/defaultApp/deployments/defaultApp/deployment.xml
I do not know how you can configure that in Maven.

jboss-as-maven-plugin: which directory does command "jboss-as:deploy" deploy an .ear to?

I am running jboss 7.1, maven 3, and a java ee6 application that generates an .ear
I am doing a mvn clean package jboss:as-deployand Jboss-as-maven-plugin 1.5 does its thing--I can view my app using http://localhost:8080...
just fine, but I want to know where the actual .ear is being put.
It is not in my jboss7.../standalone/deployments folder. So where is it? My app is obviously running in jboss 7.1 just fine, but I can't find the .ear file. I know that there is an .ear in Eclipse's 'target' directory, but that wasn't produced by jboss-as-maven-plugin is it? I hope you can understand my confusion--don't all .ear files need to be in the deployments directory? I also do see my .ear file inside my hidden .m2/repository directory, but does this have any interaction with jboss-as-maven-plugin? Maybe there is some hidden sym-linking between my Eclipse project's 'target' directory and the jboss7.1 standalone/deployment directory?
p.s. I am used to using a hard-deploy option with the other plugin jboss-maven that requires you to say jboss:hard-deploy which just copies the .ear to your deployments folder. Then jboss would pick up the new .ear and redeploy automatically. I get the sense that jboss-as-maven-plugin is the preferred plugin so that's why I am bothering.
The jboss-as-maven-plugin uses the deployment API so it doesn't copy the file to the deployments directory for the scanner to pick it up. It deploys just as if you deployed it from the web console or via CLI. The files should be located somewhere in the $JBOSS_HOME/standalone/data/ directory.
You're welcome to open an issue, for a discussion around it at least. I'm not sure how I feel about adding a goal for it, but here isn't the place to discuss that :)

Deploy Vosao in eclipse in windows

I am using google app engine in eclipse in windows OS. I want to used Vosao CMS(which is develop for GAE). But i can't deploy in eclipse in windows and easily deploy in eclipse in windows.So how vosao(content management system) deploy in eclipse in windows OS.
There is not direct way to deploy the Vosao in eclipse in windows. But there is a alternate solution.
For- Eclipse IDE for Java Developers
1.Unzip the war file.
2.than create a project in eclipse.
3.Than copy the contain of unzip folder one by one & paste in proper position in your project.like servlet paste in src & jsp pages paste in war folder.
4.care fully read this point
In unzip folder there is a web-inf folder & also in your project there is web-inf folder. So copy the contain of web-inf folder carefully in project web-inf folder.
For-Eclipse IDE for Java EE developers
File-->Import-->web-->war
It may be work. In my project both are work.
There is a very good tutorial on this.
http://www.rarejava.com/blog/2011/07/deploying-vosao-from-eclipse
I had do minor modifications on my side for Maven and Subclipe 1.8. Other than that the Blog worked like a charm

Resources