I have a dev machine running Lucee with Tomcat on Mac OS X El Capitan. Lucee is running fine, but when I bring up my dev site, mapped to admin.local, I have to type in "admin.local:8080/index.cfm". For some reason entering the URL as "admin.local:8080" just brings up a 404. Is there something I need to do to get Lucee/Tomcat to serve index.cfm by default?
UPDATE:
The web.xml for Tomcat does include the following:
<servlet-mapping>
<servlet-name>CFMLServlet</servlet-name>
<url-pattern>*.cfc</url-pattern>
<url-pattern>*.cfm</url-pattern>
<url-pattern>*.cfml</url-pattern>
<url-pattern>/index.cfc/*</url-pattern>
<url-pattern>/index.cfm/*</url-pattern>
<url-pattern>/index.cfml/*</url-pattern>
<!-- url-pattern>*.cfm/*</url-pattern !-->
<!-- url-pattern>*.cfml/*</url-pattern !-->
<!-- url-pattern>*.cfc/*</url-pattern !-->
<!-- url-pattern>*.htm</url-pattern !-->
<!-- url-pattern>*.jsp</url-pattern !-->
</servlet-mapping>
In order for your web server to handle the index.cfm files without specifying it in the URL you will need to add that as a default document for your web server. You mentioned you are using Apache, one approach for that web server is to add index.cfm to the DirectoryIndex within the httpd.conf file.
Here is an example of how to do that - https://stackoverflow.com/a/7977774/1636917
I just added index.cfm to welcome file list in web.xml, it helps
<web-app ...
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.cfm</welcome-file>
</welcome-file-list>
</web-app>
Related
I created an hello-world RAP application following the eclipse tutorial. I have no problems starting it in eclipse.
Now i want to package it as a .war file with maven and deploy it inside a jetty server. That's the point where i'm already unsure if it is the right approach.
My .war file includes all RAP, equinox and maven plugins, a web.xml and a config.ini. I'm building it with Tycho but i'm open to other solutions.
config.ini:
#Product Runtime Configuration File
osgi.bundles=RapHello/BasicEntryPoint#start,\
org.eclipse.core.commands#start,\
org.eclipse.core.jobs#start,\
org.eclipse.equinox.common#start,\
org.eclipse.equinox.console#start,\
org.eclipse.equinox.ds#start,\
org.eclipse.equinox.http.registry#start,\
org.eclipse.equinox.servletbridge.extensionbundle,\
org.eclipse.equinox.http.servlet#start,\
org.eclipse.equinox.http.servletbridge#start,\
org.eclipse.equinox.registry#start,\
org.eclipse.equinox.servletbridge#start,\
org.eclipse.equinox.util#start,\
org.eclipse.osgi.services#start,\
org.eclipse.rap.jface#start,\
org.eclipse.rap.rwt#start,\
org.eclipse.rap.rwt.osgi#start,\
raphello.BasicEntryPoint#start
osgi.bundles.defaultStartLevel=4
web.xml (copied from another sample .war):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app id="WebApp">
<servlet id="bridge">
<servlet-name>equinoxbridgeservlet</servlet-name>
<display-name>Equinox Bridge Servlet</display-name>
<description>Equinox Bridge Servlet</description>
<servlet-class>org.eclipse.equinox.servletbridge.BridgeServlet</servlet-class>
<!-- Framework Controls could be useful for testing purpose, but
we disable it per default -->
<init-param>
<param-name>enableFrameworkControls</param-name>
<param-value>false</param-value>
</init-param>
<!-- Enable multi-language support for the extension registry -->
<!-- the OSGi console is useful for trouble shooting but will fill up your
appserver log quickly, so deactivate on production use. Uncomment
the -console parameter to enabled OSGi console access. -->
<init-param>
<param-name>commandline</param-name>
<param-value>-registryMultiLanguage <!-- -console --></param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>equinoxbridgeservlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
When i deploy the file in my jetty server, i get no errors and it seems like the file gets picked up, but all i get are
HTTP ERROR 404
Problem accessing /hellorap. Reason:
ProxyServlet: /hellorap
i think i tried all possible paths. What i read so far is, that the path should be the file name of my .war but that doesn't work.
jetty start log:
INFO::main: Logging initialized #276ms to org.eclipse.jetty.util.log.StdErrLog
INFO:oejs.Server:main: jetty-9.4.10.v20180503; built: 2018-05-03T15:56:21.710Z; git: daa59876e6f384329b122929e70a80934569428c; jvm 1.8.0_181-b13
INFO:oejw.StandardDescriptorProcessor:main: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
INFO:oejs.session:main: DefaultSessionIdManager workerName=node0
INFO:oejs.session:main: No SessionScavenger set, using defaults
INFO:oejs.session:main: node0 Scavenging every 600000ms
INFO:oejsh.ContextHandler:main: Started o.e.j.w.WebAppContext#561b6512{/,file:///C:/Users/USR/AppData/Local/Temp/jetty-0.0.0.0-8081-raphello.war-_-any-511053963228532950.dir/webapp/,AVAILABLE}{webapps/raphello.war}
INFO:oejs.AbstractConnector:main: Started ServerConnector#2898ac89{HTTP/1.1,[http/1.1]}{0.0.0.0:8081}
INFO:oejs.Server:main: Started #4477ms
So the question is: What am i doing wrong? Is it even the right approach?
This answer doesn't seem to work so my error is propably at an earlier stage.
iam using a Tomcat 7 server and copied my angular 5 project into the ROOT directory. Deep links does not work at the moment. I have tried to use tucky URL rewrite.
I created a WEB-INF folder in the ROOT directory. Therein i created a folder named lib and saved the file "urlrewritefilter-4.0.3 .jar" there.
The WEB-INF folder also contain a urlrewrite.xml file and a web.xml.
I hope that someone may help me to solve this issue.
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 4.0//EN"
"http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd">
<!--
Configuration file for UrlRewriteFilter
http://www.tuckey.org/urlrewrite/
-->
<urlrewrite>
<rule match-type="regex">
<note>
Redirect all http requests to angulars index. html except /tcc/* cause its needed for backend operations
</note>
<condition name="request-uri" operator="notequal">^/tcc/*</condition>
<from>^.*$</from>
<to type="permanent-redirect" last="true">http://localhost:8080</to>
</rule>
</urlrewrite>
web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<filter>
<filter-name>UrlRewriteFilter</filter-name>
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
</web-app>
I was not able to get Tucky to run. I changed the routing method of Angular to the # routing to fit my needs. Another working aproach to get this running is to update to tomcat 8 and use the inbuild mechanisms.
I am a Spring newbie and am putting together a Spring web-app (not Spring-boot - how much difference does this make?). Deployment is on a Tomcat 7 server.
The app is up and running. My problem is that is only accessible via the standard URL:
http://mycompany.com:8081/cwing-0.0.3-SNAPSHOT/index.html
The following do not work:
http://mycompany.com:8081/cwing-0.0.3-SNAPSHOT
http://mycompany.com:8081/cwing-0.0.3-SNAPSHOT/
even though my web.xml lists index.html as the welcome page.
An additional symptom of the problem is that all sorts of links within the application need to be specified as relative, rather than with a prepended '/'.
But even these urls are not what I really want.
I would rather specify
http://mycompany.com:8081/cwing
and have it bring up the index.html.
Following the lead of Add context path to Spring Boot application
I created an application.xml file in src/main/resources with the following content:
server.contextPath=/cwing
server.port=8081
This doesn't work. http://mycompany.com:8081/cwing brings up a blank page, with a 404 error on the server, as does http://mycompany.com:8081/cwing/index.html.
I must be missing something. What else is needed to get this to work as I want it to work?
UPDATE: as asked, here is the web.xml (irrelevant details removed).
<?xml version="1.0"?>
<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_3_0.xsd"
version="3.0">
<display-name>cwing</display-name>
<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- The definition of the Root Spring Container shared by all Servlets
and Filters -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring/context.xml
/WEB-INF/spring/datasource.xml
/WEB-INF/spring/security.xml
</param-value>
</context-param>
<servlet>
<servlet-name>d</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring/context.xml
/WEB-INF/spring/datasource.xml
/WEB-INF/spring/security.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>d</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<!-- Disables Servlet Container welcome file handling. Needed for compatibility
with Servlet 3.0 and Tomcat 7.0 -->
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
...
</web-app>
This is not related to Spring MVC but to specific server, by default Tomcat gets your WAR name as context root. If you want to change this, you can always rename your WAR file or I recommends to change your pom.xml to build your WAR file with final name, here is how to do this:
<build>
<finalName>finalName</finalName>
. . .
</build>
I want to speed up development cycle: read/write code, build, deploy, test by eliminating build and deploy stage for such file types:
CSS (.css)
JavaScript (.js)
images (.png, .jpg, .gif)
as CSS/JS/img are static files (does not require build stage) and I hope that JBoss can scan for file timestamp changes to update static file cache.
I have such code in web.xml:
<servlet>
<servlet-name>resources</servlet-name>
<servlet-class>org.springframework.web.servlet.ResourceServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>resources</servlet-name>
<url-pattern>/js/**</url-pattern>
<url-pattern>/css/**</url-pattern>
<url-pattern>/images/**</url-pattern>
</servlet-mapping>
So I need change it to something that also give full path to CSS/JS/imgs, like ~/devel/$proj/src/main/webapp. Also I think that static content may be served by JBoss itself instead of Spring.
As summary: how to configure Java EE project with JBoss AS 7 to serve static files from selected (in my case development) directory, while other files deployed as usual through .war file (I deploy by mvn -DskipTests=true package jboss-as:deploy)?
After spending 4 hours I make it work! But not in general case because solution based on new Spring 3.x series.
For general case solution you must implement own servlet, like this done n famous blog article: http://balusc.blogspot.com/2009/02/fileservlet-supporting-resume-and.html
I don't like to write code but like to configure already prebuild components!
So first I change request handler for all URL to org.springframework.web.servlet.DispatcherServlet:
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
Before I have:
<url-pattern>*.htm</url-pattern>
<url-pattern>*.xml</url-pattern>
so *.js, *.css, *.png files managed by default container (JBoss) servlet and any options further have no effect...
Next I use Spring 3.0 features <mvc:resources> (xmlns:mvc="http://www.springframework.org/schema/mvc") and file: resource type:
<mvc:resources mapping="/css/**" location="file:/home/user/devel/proj/src/main/webapp/css/"/>
<mvc:resources mapping="/images/**" location="file:/home/user/devel/proj/src/main/webapp/images/"/>
<mvc:resources mapping="/js/**" location="file:/home/user/devel/proj/src/main/webapp/js/"/>
Any time I save .js or .css file and refresh web-page in browser I get new content!
So reduce static content deploy time from 2 minute to 1 second!!!
UPDATE After switching to Tomcat 7 I configure context /opt/apache-tomcat-7.0.40/conf/Catalina/localhost/CTXNAME.xml:
<Context docBase="/home/user/devel/proj-dev/src/main/webapp"
reloadable="true">
<Resources className="org.apache.naming.resources.VirtualDirContext"
extraResourcePaths="/WEB-INF/classes=/home/user/devel/proj-dev/target/classes,/WEB-INF/lib=/home/user/devel/proj-dev/target/proj/WEB-INF/lib"/>
<Loader className="org.apache.catalina.loader.VirtualWebappLoader"
virtualClasspath="/home/user/devel/proj-dev/target/classes;/home/user/devel/proj-dev/target/proj/WEB-INF/lib"/>
<JarScanner scanAllDirectories="true"/>
</Context>
according to:
http://tomcat.apache.org/tomcat-7.0-doc/config/context.html
http://tomcat.apache.org/tomcat-7.0-doc/config/resources.html
http://tomcat.apache.org/tomcat-7.0-doc/config/loader.html
Now JS/CSS/JSP files update by F5 in browser. In order to use new .class invoke mvn compile. To bootstrap invoke mvn package
I need to expose some static content (xsd files that are required by the wsdl). I cannot use the mvn:resources since it is not available in Spring 3.0.0
I don't have an idea as to where the static content should go. Hope someone can help me.
In my web.xml i have
<servlet>
<servlet-name>Resources</servlet-name>
<servlet-class>org.springframework.web.servlet.ResourceServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Resources</servlet-name>
<url-pattern>/resources/*</url-pattern>
</servlet-mapping>
then in the webapp dir I added a resources dir with the static files.
% ls webapp
index.jsp META-INF resources WEB-INF
can someone tell me where the static content should go.
thanks much.
Dont forget this one aswell:
<!-- Allows for mapping the DispatcherServlet to "/" by forwarding static resource
requests to the container's default Servlet -->
<mvc:default-servlet-handler/>
You wrote
I cannot use the mvn:resources since it is not available in Spring 3.0.0
This is complete wrong!
mvn:resources is avaiable in Spring mvc namespace for version 3.0.0 3.0.4
See the xsd: http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd