Could someone explain the main differences (or provide a link to) between glassfish-web.xml, sun-web.xml and web.xml?
Can I use just glassfish-web.xml in my webapp and skip the others?
web.xml: Standard deployment descriptor defined by Java EE (Servlet JSR in particular, but used by many JSRs). It is used to specify the metadata used by the web container to deploy the application in a portable manner across application servers (such as the URL endpoint of a servlet). In Java EE 6 and beyond, it is optional (depending on technologies that you use) when metadata is provided by annotations in your Java code, like #WebServlet.
glassfish-web.xml: Each application server offers implementation-specific features. To configure these features for GlassFish, use glassfish-web.xml. This is documented in the GlassFish Documentation.
sun-web.xml: Legacy application-server specific deployment descriptor, and has been replaced by glassfish-web.xml. It no longer made sense to have this name after Sun was acquired by Oracle. This file name is still supported for backwards compatibility, but you should migrate to glassfish-web.xml.
You may or may not need a web.xml file. It depends on the Java EE features you use. By default, don't use any of these files and simply use Java EE annotations like #WebServlet. As you build out your app and perhaps begin using some features that require the web.xml file (like to define the JavaServer Faces FacesServlet), then use a web.xml file. As for the glassfish-web.xml, you only use one if you have GlassFish-specific features to configure for your application.
The Java EE tutorial is also a good way to learn Java EE, and is bundled with the Java EE 7 SDK along with GlassFish 4.
Web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>BusProject</display-name>
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-servlet.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</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'm trying to deploy this example to Google Cloud. I'm following the exact instructions,
When I go to Cloud Console -> App Engine -> versions, I did see a new version deployed, but the size of the version is 0, and going to the module url returns 503 server error even after I waited 30 minutes.
Error: Server Error The service you requested is not available yet.
Please try again in 30 seconds.
Since I didn't modify anything in the example except the PROJECT_ID, CLUSTER_UNIQUE_ID, etc. What could be the problem here?
I was facing similar issue. I resolved it by doing the following changes:
Within web.xml:
<servlet>
<servlet-name>test</servlet-name>
<servlet-class>com.example.cloud.bigtable.helloworld.HelloServlet </servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>test</servlet-name>
<url-pattern>/test/*</url-pattern>
</servlet-mapping>
Added an index.html file within WebApp folder.
Within pom.xml, added the following:
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-client</artifactId>
<version>1.1.1</version>
</dependency>
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 porting a legacy application from JBoss 4.2.3 to JBoss 7 (the web profile version). They used a custom login module and used a valve to capture the login failure reason into j_exception. They did this by putting context.xml into the web-inf directory of the war, with the following contents:
<!-- Add the ExtendedFormAuthenticator to get access to the username/password/exception ->
<Context cookies="true" crossContext="true">
<Valve className="org.jboss.web.tomcat.security.ExtendedFormAuthenticator"
includePassword="true" ></Valve>
</Context>
The login is working for me, but not that valve. When there's a login exception, the j_exception is still empty and the logic that depends on analyzing why the login was rejected fails. According to this link: http://community.jboss.org/wiki/ExtendedFormAuthenticator, everything looks right. However that link is very old, and it's possible things have changed since then. What's the new way?
It seems that security valves are now defined directly in jboss-web.xml, like this:
<jboss-web>
<security-domain>mydomain</security-domain>
<valve>
<class-name>org.jboss.web.tomcat.security.ExtendedFormAuthenticator</class-name>
<param>
<param-name>includePassword</param-name>
<param-value>true</param-value>
</param>
</valve>
</jboss-web>
However, the ExtendedFormAuthenticator class wasn't ported to JBoss 7.0.1. A ticket has been opened for me, so it should be present in JBoss 7.1.0:
https://issues.jboss.org/browse/AS7-1963
I am trying to get a RESTful web service (JAX-RS) going with Tomcat7. I have tried 3 different implementations (Jersey, RESTeasy and Restlet) with no success. This should be easy but somehow it is not. I am looking for an up to date tutorial/documentation for annotations, web.xml and sample code.
I know it has been a while since you posted this question. Most likely you figured it out by now but I would like to answer in case anyone else might benefit.
Here are some tutorials that could get you started:
http://www.javacodegeeks.com/2011/01/restful-web-services-with-resteasy-jax.html
http://www.vogella.de/articles/REST/article.html
http://www.mastertheboss.com/web-interfaces/273-resteasy-tutorial-.html
If you want to create a Servlet container deployable Jersey web application use
mvn archetype:generate -DarchetypeGroupId=org.glassfish.jersey.archetypes \
-DarchetypeArtifactId=jersey-quickstart-webapp -DarchetypeVersion=2.26
I'm using both Apache Wink and Jersey with Tomcat 7 and have no problems.
In web.xml I have:
<servlet>
<servlet-name>restSdkService</servlet-name>
<!-- When running with Jersey use the following class: com.sun.jersey.spi.container.servlet.ServletContainer -->
<!-- When running with Wink use the following class: org.apache.wink.server.internal.servlet.RestServlet -->
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>mypackage.MyApplication</param-value>
</init-param>
</servlet>
May be you should elaborate what problems/exceptions you get.
tomcat 7.0.29
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-extension-providers</artifactId>
<version>2.7.7</version>
</dependency>
Tomcat 7 should not require RESTEasy, Jersey or any other proprietary implementation if JAX-RS is an integral part of Java EE 6 web-profile, which it is.