Jruby: How to change the application url in war file deployed on glassfish server - glassfish

I have deployed application on glassfish server. my application is accessible using url localhost:8080/test
Below is the setting in my warble.rb file
Warbler::Config.new do |config|
config.jar_name = 'test'
config.webxml.jruby.min.runtimes = 2
config.webxml.jruby.max.runtimes = 10
config.includes = FileList['init.rb']
end
The above setting create war file with name "test.war" and so it the application url i.e localhost:8080/test . what i want is i want to keep the file name as it is i.e it should be "test.war" but the application url should be localhost:8080/test_application instead of localhost:8080/test

From the Glassfish Application Deployment Guide (PDF)
When you deploy a web module, if you do not specify a context root, the default is the name of the WAR file without the .war extension. The web module context root must be unique within the server instance.
If you want to change the context root, you must do this in your deployment descriptor. There are several ways to do that, but with warbler the easiest is probably the following (although it is specific to Glassfish).
Create a file called 'glassfish-web.xml' in your Rails application root. It should have the following content:
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app>
<context-root>test_application</context-root>
</glassfish-web-app>
Add the following to your warbler config (warble.rb) to ensure that this file gets packaged into your application war's WEB-INFO directory:
config.webinf_files += FileList["glassfish-web.xml"]
Re-warble your application and re-deploy.
It should now be accessible at localhost:8080/test_application.

Related

How to hide context root

I've configured Glassfish 3.1 + Apache 2 with jk_mod.
All is well when I type in http://myserver.com/myapp, it does displays the index page.
I need help to change from http://myserver.com/myapp to http://myserver.com and it should still go to myapp.
Please let me know if this is even possible.?
Thanks.
Yes, this is possible.
You can set a Default Web Module for the default Virtual Server named server.
To do this, deploy your application, open the GlassFish Admin GUI, go to server-config -> Virtual Servers -> server and look for the setting Default Web Module. Select your web application and save. Now you can reach your web application on http://myserver.com. Be aware that your Apache configuration has to be in sync with the new context root.
You can also set it up via asadmin:
set server-config.http-service.virtual-server.server.default-web-module=<YOUR_WEBAPP>
See also:
Oracle GlassFish Server 3.1 Administration Guide - Administering Virtual Servers
Glassfish unable to deploy at root because default-web-module is declared

Deploy idea web module on jetty

I deleted the content of the project's artifacts folder and now the server throws a configuration error:
deployment source 'Hello World IDEA JETTY:war exploded2' is not valid
How can I redeploy the web server module onto the server?

404 Error in running worklight hybrid application on Enterprise Worklight server

I have created a sample project with an SQL adapter and a hybrid worklight application. The application is a simple login form that accept userid and password and validate them against the value stored in database using the SQL adapter.
Now when I tested this application on the default worklight server installed in eclispe plugin for worklight it is working fine.
But when I install the SQL adapter and worklight application on an enterprise worklight server and testing it, I am getting the following error:
NetworkError: 404 Not Found -
http://[localhost:9080]/apps/services/api/SampleHybrid/common/query
The above error I fetched through Firebug.
SampleHybrid is the name of the worklight hybrid application.
SampleHybridAdapter is the name of the SQL adapter.
The server’s response is:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>CWWKT0018E: The application or context root for this request has not been found: /apps/services/api/SampleHybrid/common/query</p><h‌​r /><address>WebSphere Application Server at 127.0.0.1 port 9080</address></body></html>
You mentioned you have moved to running Worklight on an application server - this requires using a context root. I do not see a context root in the 404 error you have provided.
The request to the server was supposed to look like this: http://[localhost:9080]/yourContext/apps/services/api/SampleHybrid/common/query
Because the context root (in this case, "yourContext") is missing, you get a 404 error, since the application is trying to reach a location that does not exist.
The context root value is set in both application-descriptor.xml and worklight.properties.
yourProject\apps\yourApp\application-descriptor.xml
Change the value of the worklightServerRootURL property to include your context root. It should look like this http://your-host-name-here:port/yourContext
yourProject\apps\server\conf\worklight.properties
Set your context root as the value for the publicWorkLightContext property (also make sure to uncomment it)
After doing the above, you need to re-deploy the .war file to your application server. The .war file can be found in the bin folder of your Worklight project.

Steps to execute .ear file from Glassfish server into Tomee+ server

As a newbie to Enterprise Applications I'm trying to get it done.
I developed an Enterprise application in Netbeans 7.1.2. It runs successfully using the default Glassfish server. With the need to change the server, I downloaded and installed Tomee+ server, and made some changes to make Tomee Manager Interface work on my system.
I deployed the .ear file (Glassfish server output) into Tomee+ by placing it in the Tomee webapps folder, with the server in the running state. It gets automatically deployed and appears in the Tomcat Web Application Manager interface.
Then, by providing the suitable path in the address bar, like http://localhost:8080/app-war/faces/app.xhtml, it provides the frontend screen but the backend process is not working if I click the submit button. Instead, it simply provides a status page, like HTTP Status 500 - javax.el.ELException: javax.ejb.EJBTransactionRolledbackException: Transaction was rolled back, presumably because setRollbackOnly was called during a synchronization.
My question is: what went wrong with the steps I took for deploying it in Tomee+ server?
no more verbose stack?
btw can you try to:
1) check you have in tomee.xml the line
2) put your ear in /apps/ instead of webapps/
The point is by default (can be configured with the snapshot/next release) tomee extracts the ear in a folder simply removing the extension (webapps/your-ear/ for instance) and then tomcat takes this folder as a webapp so your deployment is no more the one expected. That's why moving it over a folder not managed by tomcat (apps) is often enough.
That's said, Glassfish transaction management is sometimes too tolerant (why i ask the full stack you got).

No factories configured while using Jetty 7 embedded + Myfaces 1.2

I am using an embedded version of jetty 7 to load a web application using Apache MyFaces 1.2 in a junit 4 test class on the advice from another thread.
While running the test i get this error.
java.lang.IllegalStateException: No Factories configured for this Application. This happens if the faces-initialization does not work at all - make sure that you properly include all configuration settings necessary for a basic faces application and that all the necessary libs are included. Also check the logging output of your web application and your container for any exceptions!
If you did that and find nothing, the mistake might be due to the fact that you use some special web-containers which do not support registering context-listeners via TLD files and a context listener is not setup in your web.xml.
A typical config looks like this;
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
This application works fine with tomcat, weblogic and even oc4j!
How can i get this to work with jetty?
I solved this by adding the myfaces-impl jar which had the .tld file inside the WEB-INF/lib directory.