We recently switched to Glassfish 3.1.2.2 and have several Web-Applications packaged as war files. At times the desired context-root for these applications differs from the filename.
Back when we used Weblogic we achieved this by declaring the context-root in the weblogic.xml like this
<context-root>path/to/our/App</context-root>
We noticed that the same Tag exists in the glassfish-web.xml. But no matter what we define there, the server always determines the filename as the context-root.
Now we find the option --contextroot in the asadmin utility that would allow us to overwrite the filename at deploy time, but we'd prefer to do define it directly in the archive itself so that whoever will deploy it in the end won't need to know the desired contex-root.
Is there any way to achieve this?
In GlassFish 3 and GlassFish 4 the configuration of a web application is done via glassfish-web.xml. In your case the desired configuration file would look like this:
<!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>/path/to/our/App</context-root>
</glassfish-web-app>
You can find further details in section GlassFish Server Deployment Descriptor Files of Oracle GlassFish Server Application Deployment Guide. A online version of this document can be found at http://docs.oracle.com/cd/E18930_01/html/821-2417/.
Normally this should work with a glassfish-web.xml looking like this:
<!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>/path/to/App</context-root>
</glassfish-web-app>
But here it looks like you need a file called sun-web.xml for your task.
Here is an example:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD GlassFish Application Server 3.0 Servlet 3.0//EN"
"http://www.sun.com/software/appserver/dtds/sun-web-app_3_0-0.dtd">
<sun-web-app error-url="">
<context-root>/path/to/our/App</context-root>
</sun-web-app>
Related
I'm trying to use a custom realm into my webapp deployed in weblogic version 12.2.1.4.0 to manage login (through a form based authentication), but even if the new realm is correctly defined and also the SQLAuthenticator provider, when i try to set the realm name, according to Oracle guide, the results is that at deploy or starts of the application weblogic logs that the configuration is ignored:
<Warning: Ignore the realm name: myrealm in
deployment descriptor.>
This problems occurs even when i configure the name of the standard WL realm "myrealm".
The SQLAuthenticator provider (readonly) works good and if i configure it in the default realm the login works, but the users and groups specific of the application are mixed with the system users and can be inherited by others application eventually deployed on the same WL instance and I want to avoid this.
weblogic-application.xml is correctly contained in META-INF dir of the EAR that contain the WAR and this is the content:
<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-application
xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-application"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/javaee_6.xsd http://xmlns.oracle.com/weblogic/weblogic-application http://xmlns.oracle.com/weblogic/weblogic-application/1.8/weblogic-application.xsd">
<wls:security>
<wls:realm-name>myrealm</wls:realm-name>
</wls:security>
</wls:weblogic-application>
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.
Version: GlassFish Server 3.1.2.2 (build 5)
I have an EAR project which contains a WAR and a single EAR.
In the META-INF folder of the EAR, I have a sun-application.xml file which maps a selection of roles to groups.
In the default file realm for Glassfish, I have configured users which map to these groups.
I am not using Default Role to Mapping and I have not actived the Security Manager.
Access works perfectly. This is further proven by removing the deployment descriptor, which causes an Authorization exception when trying to log in without it.
However when trying to access a seemingly random (but consistent) selection of my EJBs, I am greated with the infamous Glassfish "javax.ejb.AccessLocalException: Client not authorized for this invocation" exception.
I have tried to delete my generated Policy files and redeploy the server, but this does not work.
When I look into the Policy file for my EJB, straight away I notice that the afflicted EJB grants are missing.
It would appear that one or two roles per group as defined in the sun-application.xml file are being missed.
Why would Glassfish fail to generate a complete policy file from a (proven) working sun-application.xml and (proven) set of #RolesAllowed definitions?
Here's the deployment descriptor:
<!DOCTYPE sun-application PUBLIC "-//Sun Microsystems, Inc.//DTD
GlassFish Application Server 3.0 Java EE Application 6.0//EN"
"http://www.sun.com/software/appserver/dtds/sun-application_6_0-0.dtd">
<sun-application>
<security-role-mapping>
<role-name>ViewAllData</role-name>
<role-name>BasicUser</role-name>
<group-name>BasicGroup</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>DataSupervisor</role-name>
<group-name>DatasetSupervisors</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>FindData</role-name>
<role-name>FindSubData</role-name>
<group-name>DatasetUsers</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>ManageData</role-name>
<role-name>ManageSubData</role-name>
<role-name>InvokeDataload</role-name>
<group-name>DatasetManagers</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>ResolveGroup1</role-name>
<role-name>ResolveGroup2</role-name>
<role-name>ResolveGroup3</role-name>
<group-name>Decoders</group-name>
</security-role-mapping>
</sun-application>
For some reason, the roles ResolveGroup1 and ViewAllData are missing from the EJB granted.policy file, despite appearing in a couple of EJBs:
#RolesAllowed({"ResolveGroup1"})
#Stateless(mappedName = "ejb/FindGroupOneController")
#Local(FindRegistrationFragmentController.class)
#Interceptors(SpringBeanAutowiringInterceptor.class)
public class FindGroupOneControllerImpl implements FindGroupOneController{
#RolesAllowed({"ViewAllData"})
#Stateless(mappedName = "ejb/ViewDataController")
#Local(FindRegistrationFragmentController.class)
#Interceptors(SpringBeanAutowiringInterceptor.class)
public class ViewDataControllerImpl implements ViewDataController{
Unless someone can tell me otherwise, it looks like the reason I was having problems is because you may use only one <role-name> per <security-role-mapping>.
can somebody please help me how to make a war of a simple mule application.
My mule application consists of a single mule-config.xml file.
I have made this mule project in ecplise and can run it as a mule server.
My requirement is to make a war and deploy it in a tomcat or tcat server.
Thanks and Regards,
Arijit
As explained in the user guide:
To embed Mule inside a webapp, you provide one or more configuration file locations as context params and include a context listener to initialize the Mule Server.
So just add this in your web.xml, with mule-config.xml at the root of your classpath (for ex. in src/main/resources):
<context-param>
<param-name>org.mule.config</param-name>
<param-value>mule-config.xml</param-value>
</context-param>
<listener>
<listener-class>org.mule.config.builders.MuleXmlBuilderContextListener</listener-class>
</listener>
EDIT I've open-sourced a running demo: https://github.com/ddossot/mule-webapp-example
I'm currently trying to 'port' my Java EE 5 Application from Jboss 6 M2 to Glassfish 3.0.1
Jboss used to create my JMS Destination Queues a deployment-time thanks to the -service.xml files. I really liked this feature and I would like to find a way to do the same thing on Glassfish. Is this even possible ?
I'm not sure of the exact status with GlassFish 3.0.1 but according to these threads:
http://markmail.org/thread/cqj56ehulg7qdenp
http://markmail.org/thread/zs4naxy534ijbpic
creating JMS destinations at deploy time was not supported. But these threads are pretty old and things might have changed (see below).
You can however declare them in a sun-resources.xml file and pass it to the asadmin add-resources command.
That being said, several documents (like this one or this one) mention the deployment of application-scoped-resources defined in a sun-resources.xml bundled in the application (that will become glassfish-resources.xml in GlassFish 3.1) as part of the deploy/undeploy of the app but:
I don't know if this is relevant for 3.0.1.
I don't know the exact status, especially for JMS resources.
This would require testing.
With glassfish v4x, Connection factory and destinations(ie queue and topics) can be configured in domain.xml file under glassfish/domains/your-domain-name
Eg :
<resources>
<connector-connection-pool resource-adapter-name="jmsra" max-pool-size="250" steady-pool-size="1" name="jms/DurableConnectionFactory-Connection-Pool" description="connection factory for durable subscriptions" connection-definition-name="javax.jms.ConnectionFactory">
<property name="ClientId" description="MyID" value="MyID"></property>
</connector-connection-pool>
<connector-resource pool-name="jms/DurableConnectionFactory-Connection-Pool" description="connection factory for durable subscriptions" jndi-name="jms/DurableConnectionFactory"></connector-resource>
<admin-object-resource res-adapter="jmsra" description="PhysicalQueue" res-type="javax.jms.Queue" jndi-name="jms/MyQueue">
<property name="Name" value="PhysicalQueue">
</property>
</admin-object-resource>
</resources>