PDA

View Full Version : Resin 4 - deploying .ear files with / context root


koge_pan
01-12-2011, 06:04 AM
Hi

I am trying to deploy an .ear file on latest resin 4.0.14, and found a problem with the webapp binded to the "/" context root.

Everything works fine when the webapp is binded to another context root, but I get a 404 error as soon as i changed the context root to "/" in the application.xml.

I noticed in resin 3.1.9, the context path of the WebAppController is set to "" when the context root is "/", but from 4.x onwards, the context path is set to "/".

reza
01-13-2011, 04:48 PM
koge_pan,

Can you kindly post your resin.xml, web.xml, resin-web.xml and application.xml? Note, normally, the webapps/ROOT application is mapped to the "/" context root.

Thanks,
Reza

koge_pan
01-13-2011, 09:00 PM
Hi reza,

Here are the resin.xml, application.xml and web.xml.
Attached is the sample .ear file I've used.

Thanks.

resin.xml

<!--
- Resin 4.0 configuration file.
-
- See conf/full.xml for more sample configuration, including load
- balancing and database configuration.
-->
<resin xmlns="http://caucho.com/ns/resin"
xmlns:resin="urn:java:com.caucho.resin">

<!--
- Logging configuration for the JDK logging API.
-->
<log-handler name="" level="all" path="stdout:"
timestamp="[%y-%m-%d %H:%M:%S.%s] {%{thread}} "/>

<!--
- level='info' for production
- 'fine' or 'finer' for development and troubleshooting
-->
<logger name="com.caucho" level="info"/>

<logger name="com.caucho.java" level="config"/>
<logger name="com.caucho.loader" level="config"/>

<!--
- driver .jar files can be placed in ${resin.root}/ext-lib
-->
<class-loader>
<tree-loader path="${resin.root}/ext-lib"/>
</class-loader>

<!--
- Remote management requires at least one enabled admin user.
-->
<resin:AdminAuthenticator>
<resin:import path="${__DIR__}/admin-users.xml" optional="true"/>
</resin:AdminAuthenticator>

<!--
- <resin-system-auth-key>changeme</resin-system-auth-key>
-->

<!--
- For production sites, change dependency-check-interval to something
- like 600s, so it only checks for updates every 10 minutes.
-->
<dependency-check-interval>2s</dependency-check-interval>

<!-- Java system-properties -->
<system-property mail.smtp.host="127.0.0.1"/>
<system-property mail.smtp.port="25"/>

<!--
- default configuration applied to all clusters
-->
<cluster-default>
<!-- standard servlet behavior, including .jsp, .php, and WEB-INF -->
<resin:import path="${__DIR__}/app-default.xml"/>

<!-- enables development error pages -->
<development-mode-error-page/>

<!--
- Enables the proxy cache (available in Resin Professional)
-->
<resin:if test="${resin.professional}">
<cache memory-size="64M">
<!-- Vary header rewriting for IE -->
<rewrite-vary-as-private/>
</cache>
</resin:if>

<!--
- Admin services
-->
<resin:DeployService/>

<resin:if test="${resin.professional}">
<resin:AdminServices/>
</resin:if>

<!--
- Default host configuration applied to all virtual hosts.
-->
<host-default>
<access-log path="log/access.log"
format='%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"'
rollover-period="1W"/>

<!-- creates the webapps directory for .war expansion -->
<web-app-deploy path="webapps" versioning="true"/>

<!-- creates a directory for .ear expansion -->
<ear-deploy path="deploy">
<ear-default>
</ear-default>
</ear-deploy>

<!--
- Defaults applied to each web-app.
-->
<web-app-default>
<prologue>
<allow-servlet-el/>
</prologue>

<!-- enable persistent sessions -->
<session-config>
<use-persistent-store/>
<enable-url-rewriting>false</enable-url-rewriting>
</session-config>

<!--
- Sets max-age for cacheable pages, e.g. static pages.
-->
<resin:if test="${resin.professional}">
<cache-mapping url-pattern="/" max-age="5s"/>
<cache-mapping url-pattern="*.gif" max-age="60s"/>
<cache-mapping url-pattern="*.jpg" max-age="60s"/>
<cache-mapping url-pattern="*.png" max-age="60s"/>
<cache-mapping url-pattern="*.css" max-age="60s"/>
<cache-mapping url-pattern="*.js" max-age="60s"/>
</resin:if>
</web-app-default>
</host-default>
</cluster-default>

<!--
- Configures the main appliction cluster. Load-balancing configurations
- will also have a load-balance-tier cluster.
-->
<cluster id="app-tier">
<!-- sets the content root for the cluster, relative to resin.root -->
<root-directory>.</root-directory>

<!-- defaults for each server, i.e. JVM -->
<server-default>
<!-- The http port -->
<http address="*" port="8080"/>

<!-- SSL port configuration: -->
<http address="*" port="8443">
<jsse-ssl self-signed-certificate-name="resin@localhost"/>
</http>

<!--
- <jvm-arg>-Xmx512m</jvm-arg>
- <jvm-arg>-agentlib:resin</jvm-arg>
-->

<!--
- If starting Resin as root on Unix, specify the user name
- and group name for the web server user.
<user-name>www-data</user-name>
<group-name>www-data</group-name>
-->
</server-default>

<!-- define the servers in the cluster -->
<server id="" address="127.0.0.1" port="6800">
</server>

<!-- the default host, matching any host name -->
<host id="" root-directory=".">
<!--
- configures an explicit root web-app matching the
- webapp's ROOT
-->
<!--web-app id="/" root-directory="webapps/ROOT"/-->

<!--
- Administration application /resin-admin
-->
<web-app id="/resin-admin" root-directory="${resin.home}/doc/admin">
<prologue>
<resin:set var="resin_admin_external" value="false"/>
<resin:set var="resin_admin_insecure" value="true"/>
</prologue>
</web-app>

<!--
- Resin documentation - remove for a live site
-->
<web-app id="/resin-doc" root-directory="${resin.root}/doc/resin-doc"/>

<!--
- <resin:LoadBalance regexp="^/load" cluster="backend-tier"/>
- <resin:HttpProxy regexp="^/http" address="localhost:9000"/>
- <resin:FastCgiProxy regexp="^/fcgi" address="localhost:9001"/>
-->
</host>
</cluster>
</resin>


application.xml

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="5"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd">

<module>
<web>
<web-uri>test.war</web-uri>
<context-root>/</context-root>
</web>
</module>

<module>
<web>
<web-uri>test2.war</web-uri>
<context-root>/test</context-root>
</web>
</module>

</application>


web.xml

<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
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/web-app_2_5.xsd"
version="2.5">

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

</web-app>

reza
01-18-2011, 06:22 PM
koge_pan,

This definitely looks like a bug. I entered a bug report for it here: http://bugs.caucho.com/view.php?id=4348. Feel free to track it.

Thanks,
Reza

koge_pan
01-18-2011, 09:56 PM
Thank you!