I'm trying to use Lift 2.1-SNAPSHOT on Google App Engine but the lift snippets in the HTML are not being processed. It simply returns the HTML file.
This is the lift.html file (just a simple test):
<lift:surround with="default" at="content">
Welcome to your Lift application
</lift:surround>
The web.xml has:
<filter>
<filter-name>LiftFilter</filter-name>
<display-name>Lift Filter</display-name>
<description>The Filter that intercepts lift calls</description>
<filter-class>net.liftweb.http.LiftFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>LiftFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
The appengine-web.xml contains:
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>kivanotify</application>
<version>6</version>
<static-files/>
<resource-files/>
<system-properties>
<property name="java.util.logging.config.file" value="WEB-INF/classes/logging.properties"/>
<property name="in.gae.j" value="true" />
</system-properties>
<sessions-enabled>true</sessions-enabled>
<static-files>
<exclude path="/static/**" />
</static-files>
</appengine-web-app>
When running the project using " /opt/appengine-java-sdk-1.3.6/bin/dev_appserver.sh target/kivanotify" and accessing the url http://localhost:8080/lift.html is simple returns the lift.html as is without processing the tags.
Any idea why the tags are not being processed? There is no logging that hints at a problem.
Regards,
Gero
I remember you need the following setting in appengine-web-app.xml.
<static-files>
<exclude path="/**" />
</static-files>
BTW, I found stax.net is much Lift-friendly then GAE.
Related
I have an angular application which uses ui-router, and is served by a SpringMvc (4.2.4) java app. I decided to map any requests to a single Controller/method which loads the single JSP page of my project.
But, When I try to add static resources mappings, to load js and css files, those static resources are ignored... Every requests, inside the [mayapp]/resources/* path leads to my single jsp page.
Here is my config :
web.xml
<servlet>
<servlet-name>mvc-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/servlet.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
servlet.xml
<context:component-scan base-package="com.adveasys.omrh.front.web" />
<mvc:annotation-driven></mvc:annotation-driven>
<mvc:resources mapping="/resources/**" location="/resources/">
<mvc:resource-chain resource-cache="false" auto-registration="false">
<mvc:resolvers>
<bean class="org.springframework.web.servlet.resource.GzipResourceResolver"/>
<bean class="org.springframework.web.servlet.resource.PathResourceResolver"/>
</mvc:resolvers>
</mvc:resource-chain>
</mvc:resources>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/pages/" />
<property name="suffix" value=".jsp" />
</bean>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/pages/" />
<property name="suffix" value=".jsp" />
</bean>
MainController.java
#RequestMapping("/**")
public ModelAndView mainPage(HttpServletRequest request) throws JsonProcessingException {
Before having this problem, I used the default servlet in web.xml for every /resources/*, But I am generating a .gz version of my scripts/css with maven
and I want this kind of configuration to be able to user the GzipResourceResolver.
Things I already tried, and did not work
declare 2 distincts DispatcherServlets in web.xml, one for JSP only, the other one only for resources. (I splitted the mvc configuration into 2 different files for each servlets)
#RequestMapping("/") in the controller, the user must enter the website at the root address, not acceptable.
I tried to set an order on and as a property for InternalResourceViewResolver
Thanks in advance.
Alright,
after digging in debug mode. HandlerMappings where in this order :
RequestMappingHandlerMapping (the #Controller one, inner property "order" = 0)
SimpleUrlHandlerMapping (the resources one, inner property "order" = 0)
BeanNameUrlHandlerMapping (don't know what it is ... ^^)
When calling a /resource/* file the RequestMappingHandlerMapping was the first to respond as a valid candidate.
after adding such an order in Spring configuration :
<mvc:resources mapping="/resources/**" location="/resources/" order = "-1">
It worked.
I'm learning Struts 2 for a project requirement and I've met some issues.
Following this tutorial at:
http://www.mkyong.com/google-app-engine/google-app-engine-struts-2-example/
And what I've done extra:
Added an index.jsp into the war folder
Changed web.xml to
<?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_2_5.xsd"
version="2.5">
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>com.mkyong.listener.Struts2ListenerOnGAE</listener-class>
</listener>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
Now, when I rebuild and loads
http://localhost:8888
Rather then seeing the content I should have in my index.jsp, I'm getting a
Error 404 There is no Action mapped for namespace [/] and action name [] associated with context path [].
Can someone point me to the right direction? I've seen some other similar questions in SO but their solutions do not work for this specific example of Struts 2 + GAE.
My struts.xml
<struts>
<package name="user" namespace="/User" extends="struts-default">
<action name="Login">
<result>pages/login.jsp</result>
</action>
<action name="Welcome" class="com.mkyong.user.action.WelcomeUserAction">
<result name="SUCCESS">pages/welcome_user.jsp</result>
</action>
</package>
</struts>
Folder structure
I cant post images so, http://i.imgur.com/KSPmaMr.png
Exact same libraries used for download
http://www[dot]mediafire[dot]com/?utliwvcmo63o8l7
ok ,i got your problem,
change your struts.xml to this
<struts>
<package name="default" extends="struts-default" namespace="/">
<action name="Login">
<result>pages/login.jsp</result>
</action>
<action name="Welcome" class="com.mkyong.user.action.WelcomeUserAction">
<result name="SUCCESS">pages/welcome_user.jsp</result>
</action>
</package>
</struts>
I guess this will work, because filterDispatcher search for struts.xml file in root folder if you put your struts.xml file in root directory.
#Eleazar I followed the mykong tutorial link that you mentioned in your question. There is no use of index.html as far as I see that tutorial. <welcome-list> file is used when the is no action mentioned on application startup.
On step:8 in that tutorial they has provided the url which is http://localhost:8888/User/Login.action you need to run the test. Its got nothing to do with file in welcome list...
UPDATE:
You are getting that error because you have added struts2 filter as /*, and your action namespace is for /User. There is not action namespace for /. Adding package with name="default" with namespace="/" i.e <package name="default" extends="struts-default" namespace="/"></package> will resolve you issue. It will hit <welcome-file>
I am a google app engine newbie.
I have an encoding issue with a wicket application in GAE.
(see http://ristorante-lastoria.appspot.com/wicket/home )
My IDE is configured to save the HTML template files in UTF-8.
I ve printed out the default file.encoding used by GAE JVM and it's ASCII.
I 've tried to set the following parameters in the appengine-web.xml.
<system-properties>
<property name="file.encoding" value="UTF-8" />
</system-properties>
<env-variables>
<env-var name="DEFAULT_ENCODING" value="UTF-8" />
<env-var name="APP_ENCODING" value="UTF-8" />
</env-variables>
I ve tried to set the flag --compile-encoding=UTF-8 when uploading the war content to the server.
At the build level(using maven), I tried to escape the unicode characters in the build using the native2ascii tool.
No luck so far :-(
Wicket version: 1.4.17
TIA
Add a xml declaration wirh encoding to all your templates:
<?xml version="1.0" encoding="UTF-8" ?>
I try to set up a camel (Ver. 2.4.0) route in a FUSE (Ver. 4.3.0) ESB/OSGi container.
It should be a simple cxf-proxy to route a WebService call from a 'proxy' address to a real service.
I read several documentation:
CXF Proxy Example
camel cxf component
and set up the following spring configuration:
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camel="http://camel.apache.org/schema/spring"
xmlns:osgi="http://www.springframework.org/schema/osgi"
xmlns:cxf="http://camel.apache.org/schema/cxf"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/osgi
http://www.springframework.org/schema/osgi/spring-osgi.xsd
http://camel.apache.org/schema/osgi
http://camel.apache.org/schema/osgi/camel-osgi.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
http://camel.apache.org/schema/cxf
http://camel.apache.org/schema/cxf/camel-cxf.xsd">
<import
resource="classpath:META-INF/cxf/cxf.xml" />
<import
resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import
resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
<import
resource="classpath:META-INF/cxf/osgi/cxf-extension-osgi.xml" />
<!-- the proxy service -->
<cxf:cxfEndpoint
id="myServiceProxy"
address="http://localhost:9003/cxf/myService"
serviceClass="foo.bar.iface.MyServiceInterface" />
<!-- my real existing cxf soap service -->
<cxf:cxfEndpoint
id="myService"
address="http://foo.bar/services/myService"
wsdlURL="http://foo.bar/services/myService?wsdl"
serviceClass="foo.bar.iface.MyServiceInterface"
serviceName="s:MyService"
endpointName="s:MyServiceEndpoint"
xmlns:s="http://foo.bar/iface/" />
<!-- route -->
<camel:camelContext>
<camel:route>
<camel:from
uri="cxf:bean:myServiceProxy" />
<camel:to
uri="cxf:bean:myService" />
</camel:route>
</camel:camelContext>
</beans>
Trying to start the bundle in FUSE leads to this exception
karaf#root> Exception in thread "SpringOsgiExtenderThread-22" org.apache.camel.RuntimeCamelException: java.lang.IllegalStateException: Endpoint address should be a relative URI wrt to the servlet address (use '/xxx' for example)
at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1126)
at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:103)
at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:231)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:97)
I do not know what's wrong. I doubt that my Endpoint address is wrong and I do not know what my servlet address is (there is no cxf:cxfEndoint servelt address attribute).
Any help to lead me in the right direction to solve this problem would be appreciated.
Thanks
Klaus
I finally found out what's wrong.
Instead
<!-- the proxy service -->
<cxf:cxfEndpoint
id="myServiceProxy"
address="http://localhost:9003/cxf/myService"
serviceClass="foo.bar.iface.MyServiceInterface" />
it has to be
<!-- the proxy service -->
<cxf:cxfEndpoint
id="myServiceProxy"
address="/myService"
serviceClass="foo.bar.iface.MyServiceInterface" />
As the first approach worked well running the camel project outside FUSE (in this case a the http server will be started to provide the service) it has to be a relative address inside FUSE.
Inside FUSE the embedded HTTP server which runs on (localhost:8181) will be used and the service url will be extended to http://localhost:8181/cxf/myService.
I developed a Java web application in Netbeans 6.5 using a MySQL database and Hibernate. Both the development database server and development application server (Tomcat 6) reside on my development machine. Everything works; the application pulls data from the database correctly.
Now, I'm ready to move it to the production server. Again, the DB server and app server are on the same machine. I deploy the WAR file and try to access the application; I can access the static pages but the Servlets that use the database error out with the exception:
org.hibernate.exception.JDBCConnectionException: Cannot open connection
I'm pretty sure the problem relates to Tomcat not knowing about the data source. It seems as if Netbeans handles this for me. I've read that I might need to add a RESOURCE entry so I took some advice from this site which gave me a context.xml of:
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/EmployeeDirectory">
<Resource
name="jdbc/employeedirectory" auth="Container"
type="javax.sql.DataSource" username="EmployeeDir"
password="EmployeeDirectory" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://127.0.0.1:3306/EmployeeDirectory?autoReconnect=true"
maxActive="15" maxIdle="7"
validationQuery="Select 1" />
</Context>
a web.xml of:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 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">
<!-- Omit Servlet Info -->
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/employeedirectory</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
and a hibernate.cfg.xml of:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.datasource">java:comp/env/jdbc/employeedirectory</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- Omit other Mappings -->
<mapping class="EmployeeDirectory.data.PhoneNumber" resource="EmployeeDirectory/data/PhoneNumber.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Now, I get a org.hibernate.HibernateException: Could not find datasource error.
Am I on the right path for moving from development to production? What am I missing?
I think you are on the right track. I would first set up the datasource and verify it out side of hibernate. Here is a good article on that: http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.htm and some examples here: http://www.mbaworld.com/docs/jndi-datasource-examples-howto.html
Then, I would configure hibernate to use the datsource. From looking at your hibernate.cfg.xml file I think you should try changing hibernate.connection.datasource to jdbc/employeedirectory
the jndi datasource should be defined in /tomcat/server.xml see Tomcat JNDI Datasource how-to and not in webapp/context.xml
Tomcat 6 requires that you add the resource tag to the context.xml, not the server.xml. You could in Tomcat 5.x. I have it working fine in a separate install of Tomcat, but I'm still trying to use connection pooling inside NB 6.5.
That same Apache site has a link to the Tomcat 6 version of JNDI and it tells you to add the resource tag to the context.xml.