I have a rest easy url. When i type the url in browser java class get called returns the output. when i call the index.html file it is not loading. i am using tomcat7
This is my 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_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>projectname</display-name>
<resource-ref>
<description>MySQL Datasource example</description>
<res-ref-name>jdbc/projectnamedb</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>${catalina.home}\conf\log4j.properties</param-value>
</context-param>
<context-param>
<param-name>inputPropertiesLocation</param-name>
<param-value>${catalina.home}\conf\projectDetails.properties</param-value>
</context-param>
<context-param>
<param-name>resteasy.scan</param-name>
<param-value>true</param-value>
</context-param>
<listener>
<listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
</listener-class>
</listener>
<servlet>
<servlet-name>Resteasy</servlet-name>
<servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Resteasy</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/index.html</welcome-file>
</welcome-file-list>
</web-app>
Well 2 things to know here
1) You cannot type simply http://index.html you have to give path to the index page like http://projectname/path/to/index.html
2) The other simple way is to add index.html as welcome page. So when-ever server is started it opens index.html page at first. like
<welcome-file-list>
<welcome-file>path/to/index.html</welcome-file>
</welcome-file-list>
Related
I'm quite new at PrimeFaces as I am migrating from IceFaces.
My IceFaces application shows with a single url, page content changes and when hitting F5, current view get refreshed, without reloading the page referred by the url.
I expect this behaviour in my Primefaces app too, but this doesn't happen, as I go back to the page referred by the url, the login page in my case.
Is this an expected behaviour?
Below the web.xml:
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" version="4.0">
<display-name>oweb20-mainweb</display-name>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>none</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.validateXml</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.verifyObjects</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.enableRestoreView11Compatibility</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<context-param>
<param-name>facelets.DEVELOPMENT</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>facelets.SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>javax.faces.FACELETS_LIBRARIES</param-name>
<param-value>/WEB-INF/extras/extras.xml</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>StickyCaptcha</servlet-name>
<servlet-class>nl.captcha.servlet.StickyCaptchaServlet</servlet-class>
<init-param>
<param-name>width</param-name>
<param-value>250</param-value>
</init-param>
<init-param>
<param-name>height</param-name>
<param-value>75</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>StickyCaptcha</servlet-name>
<url-pattern>/stickyImg</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
The faces-config.xml contains beans and navigation cases and rules, here's an example:
<?xml version="1.0" encoding="UTF-8"?>
<faces-config version="2.0" 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-facesconfig_2_0.xsd">
<managed-bean>
<managed-bean-name>SessionBean</managed-bean-name>
<managed-bean-class>com.sia.mainweb.web.SessionBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>updateManager</property-name>
<value>#{UIUpdateManager}</value>
</managed-property>
</managed-bean>
<navigation-rule>
<from-view-id>/*</from-view-id>
<navigation-case>
<from-outcome>caseHome</from-outcome>
<to-view-id>/Home.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
To navigate between pages, in actions, I use to return the case of the page I want to go, without redirecting to that page:
public String home_action() {
logger.info(BaseLogging.methodName() + getTraceEnteringUser());
String caseName;
if (userAuthenticated()) {
boolean canContinue = checkUserFingerprint();
if (canContinue) {
caseName = "caseHome";
}
} else {
caseName = "caseNotLoggedOn";
}
logger.info(BaseLogging.methodName() + getTraceExitingUser());
return this.getNavigationManager().navigateTo(caseName); //returns caseName
}
I got the following error while deploying war file in weblogic
Message icon - Error VALIDATION PROBLEMS WERE FOUND <5:4> problem: cvc->complex-type.2.3: Element 'web-app#http://java.sun.com/xml/ns/javaee' with element-only content type cannot have text content. <14:5> problem: cvc-complex-type.2.4a: Expected element 'url-pattern#http://java.sun.com/xml/ns/javaee' instead of 'load-on-startup#http://java.sun.com/xml/ns/javaee' here in element servlet-mapping#http://java.sun.com/xml/ns/javaee <18:5> problem: cvc-complex-type.2.4b: Element not allowed: listener-class#http://java.sun.com/xml/ns/javaee in element listener#http://java.sun.com/xml/ns/javaee
Below is my web.xml
<web-app id="WebApp_ID" version="2.4"
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 ">
>
<display-name>Archetype Created Web Application</display-name>
<servlet>
<servlet-name>mvc-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
<load-on-startup>1</load-on-startup>
</servlet-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
<listener-class>
org.springframework.security.web.session.HttpSessionEventPublisher
</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/mvc-dispatcher-servlet.xml
</param-value>
</context-param>
and here's my weblogic.xml
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app"
xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-web-app ht
tp://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd">
<context-root>/</context-root>
<container-descriptor>
<show-archived-real-path-enabled>true</show-archived-real-path-enabled>
<prefer-application-packages>
<package-name>javax.faces.*</package-name>
<package-name>com.sun.faces.*</package-name>
<package-name>com.bea.faces.*</package-name>
<package-name>org.slf4j.*</package-name>
<package-name>com.google.common.*</package-name>
</prefer-application-packages>
<prefer-application-resources>
<resource-name>javax.faces.*</resource-name>
<resource-name>com.sun.faces.*</resource-name>
<resource-name>com.bea.faces.*</resource-name>
<resource-name>com.google.common.*</resource-name>
<resource-name>org/slf4j/impl/StaticLoggerBinder.class</resource-name>
<resource-name>META-INF/services/javax.servlet.ServletContainerInitializer</resource-name>
</prefer-application-resources>
</container-descriptor>
<session-descriptor>
<cookie-secure>true</cookie-secure>
<url-rewriting-enabled>false</url-rewriting-enabled>
<!-- <cookie-http-only>true</cookie-http-only> -->
</session-descriptor>
<virtual-directory-mapping>
<local-path>/usr/local/WebLogic/wlApps/miDocs</local-path>
<url-pattern>/docs/*</url-pattern>
</virtual-directory-mapping>
The folder structure matches as per the description in the oracle website
Any help is appreciated
Thinky ou have two Problems here:
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee ">
>
First a blank at the end of the schemaLocation.
Second > is too much
<web-app id="WebApp_ID" version="2.4"
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 ">
>
<display-name>Archetype Created Web Application</display-name>
<servlet>
<servlet-name>mvc-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.security.web.session.HttpSessionEventPublisher
</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/mvc-dispatcher-servlet.xml
</param-value>
</context-param>
</web-app>
After adding the context file i get this error : Statut 404 ..
my web file :
<?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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>CRUDWebAppMavenized</display-name>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:log4j.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<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>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
structure
I don't know where is exactly the problem ! the 'student.jsp' page there is inside the wepapp folder.
Add this to your web.xml:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
You are probably missing the ContextLoadListener, which picks up your Spring configuration files. If this doesn't solve your issue, edit your question to include the contents of your web.xml file.
I have index.html in my WEB-INF folder. I want it to be loaded when I go to localhost:8080/myapp. But unfortunately I am getting 404.
Could you please let me know what do I need to modify in order achieve that?
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<display-name>${project.name} (${project.version})</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<servlet>
<servlet-name>jersey-servlet</servlet-name>
<servlet-class>
com.sun.jersey.spi.spring.container.servlet.SpringServlet
</servlet-class>
<init-param>
<param-name>
com.sun.jersey.config.property.packages
</param-name>
<param-value>com.skygraph.facade</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jersey-servlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
I am having a weird problem. I have a my-spring.xml file i would like to add to application but for some reason i can only get it to be detected if it is in the root context.
The following does not detect the my-spring.xml declared in the root context.
<?xml version="1.0" encoding="ISO-8859-1"?>
<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">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/my-datasources.xml
/WEB-INF/my-spring.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>myservice</servlet-name>
<servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/webservice-config.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>myservice</servlet-name>
<url-pattern>/webservice/*</url-pattern>
</servlet-mapping>
<mime-mapping>
<extension>wsdl</extension>
<mime-type>text/xml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xsd</extension>
<mime-type>text/xml</mime-type>
</mime-mapping>
</web-app>
If i change it to this then it works (Note the difference in the location of my-spring.xml).
<?xml version="1.0" encoding="ISO-8859-1"?>
<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">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/my-datasources.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>myservice</servlet-name>
<servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/webservice-config.xml</param-value>
<param-value>/WEB-INF/my-spring.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>myservice</servlet-name>
<url-pattern>/webservice/*</url-pattern>
</servlet-mapping>
<mime-mapping>
<extension>wsdl</extension>
<mime-type>text/xml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xsd</extension>
<mime-type>text/xml</mime-type>
</mime-mapping>
</web-app>
I cant really see what i am doing wrong. If i understood the way this works, when declared on the root context (as in the first example) it should be accessed by any resource throught the application. This does not seem to be the case in this example as i cant access the properties defined in the my-spring.xml file from the Controller/Endpoint class.
I think you need commas to separate multiple contextConfigLocation files. Based on this answer: https://stackoverflow.com/a/2725413/116509
Edit: Try removing the preceding / e.g. WEB-INF/my-datasources.xml rather than /WEB-INF/my-datasources.xml
Try something like this
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:/my-datasources.xml
classpath:/my-spring.xml
</param-value>
</context-param>
But you must have these 2 files in classpath