branaway / Japid

A Java-based statically-typed fast template engine that can be used in any Java code. It has special adapter for use with the Play! Framework.
113 stars 18 forks source link

Doc needed on where the compiled class files be stored for new japidroot approach #55

Open rrjanbiah opened 11 years ago

rrjanbiah commented 11 years ago

With the new japidroot approach, the compiled template class files are not created within app path when we create WAR. And so, it doesn't work in Tomcat. Any documentation on this might be helpful.

branaway commented 11 years ago

Its a neglect on my part . Haven't considered the use with tomcat. What's your way of generating the war file?

bing ran, en route

ÔÚ 2013-7-31£¬23:47£¬"R. Rajesh Jeba Anbiah" notifications@github.com дµÀ£º

With the new japidroot approach, the compiled template class files are not created within app path when we create WAR. And so, it doesn't work in Tomcat. Any documentation on this might be helpful.

¡ª Reply to this email directly or view it on GitHub.

rrjanbiah commented 11 years ago

If I understand your question right, we create WAR in the following approach in Windows:

play war appfolder -o appname
jar -cvf ROOT.war

Not sure, if the below stack trace will give you any idea:

created: japidroot/japidviews/_javatags
created: japidroot/japidviews/_layouts
created: japidroot/japidviews/_tags
created: japidroot/japidviews/_notifiers
created: japidroot/japidviews/Users_Controller
[snipped]
created: japidroot/japidviews/_notifiers/Mailer
created: japidroot/japidviews/_javatags
11:24:32,576 ERROR play -

@6f64ig84j
Internal Server Error (500)

Execution exception (/app/controllers/AppController.java:580)
RuntimeException occured : java.lang.NullPointerException

play.exceptions.JavaExecutionException: java.lang.NullPointerException
        at play.mvc.ActionInvoker.invoke(ActionInvoker.java:236)
        at play.server.ServletWrapper$ServletInvocation.execute(ServletWrapper.java:562)
        at play.Invoker$Invocation.run(Invoker.java:282)
        at play.server.ServletWrapper$ServletInvocation.run(ServletWrapper.java:553)
        at play.Invoker.invokeInThread(Invoker.java:72)
        at play.server.ServletWrapper.service(ServletWrapper.java:141)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
        at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.RuntimeException: java.lang.NullPointerException
        at cn.bran.play.JapidPlayRenderer.refreshClasses(JapidPlayRenderer.java:231)
        at cn.bran.play.JapidPlayRenderer.getTemplateClass(JapidPlayRenderer.java:61)
        at cn.bran.play.JapidController2.getRenderClass(JapidController2.java:284)
        at cn.bran.play.JapidController2.getRenderResultWith(JapidController2.java:307)
        at cn.bran.play.JapidController2.renderJapidWith(JapidController2.java:185)
        at controllers.AppController.renderPresentation(AppController.java:580)
        at controllers.Users_Controller.home(Users_Controller.java:1026)
        at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:556)
        at play.mvc.ActionInvoker.invoke(ActionInvoker.java:507)
        at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:483)
        at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:478)
        at play.mvc.ActionInvoker.invoke(ActionInvoker.java:160)
        ... 18 more
Caused by: java.lang.NullPointerException
        at cn.bran.japid.util.DirUtil.scanJavaTags(DirUtil.java:351)
        at cn.bran.play.JapidPlayRenderer.reloadChanged(JapidPlayRenderer.java:532)
        at cn.bran.play.JapidPlayRenderer.gen(JapidPlayRenderer.java:478)
        at cn.bran.play.JapidPlayRenderer.refreshClasses(JapidPlayRenderer.java:156)
        ... 29 more

Any quick suggestions may be helpful. TIA.

branaway commented 11 years ago

The class files are never output to file system in the post-controller integration mode. The "separated" mode assumes a folder named "japidroot" in the working directory. The "current working directory" in a jee server is not defined and may be located in a place you never would imaging.

The Japid42 project contains a short description of using it in a servlet environment. Search "Use Japid in any Java applications" in https://github.com/branaway/japid42.

The standalone mode of Japid42 should work for any Java apps including Play1. See if would fit your need before I enhance Japid for servlet containers.

rrjanbiah commented 11 years ago

Thanks a lot for a quick reply. Will check "Use Japid in any Java applications" now.

branaway commented 11 years ago

I have found out the layout used by the "play war" command. What you can try is create a serlet to bootstrap Japid and configure the root path, something like:

public class S2 extends HttpServlet {

public void init(ServletConfig config) throws ServletException {
        String p = config.getServletContext().getRealPath("WEB-INF/application/japidroot");
        JapidPlayRenderer.setTemplateRoot(p)
}

}

branaway commented 11 years ago

BTW, I have made some changes in Japid hopefully that would work out of box when running in Tomcat. Can you grad the latest jars from: https://github.com/branaway/Japid/tree/master/lib ?

rrjanbiah commented 11 years ago

Thanks, very kind of you. We thought of degrading the version, but will check this version and let you know. Thanks again.

rrjanbiah commented 11 years ago

We tried the new jar, but getting below error.

System error 500: play.exceptions.JavaExecutionException: Japid template class not found: japidviews.Users_Controller.home

Since, there's some urgency, we have decided to downgrade our japid version now (Though standalone version may work, we thought it may demand more time/changes.). After that we'll closely try this with other options and update.

Many thanks for your great support.

branaway commented 11 years ago

Sorry to hear that. When you have time, can you make a minimal application that demos the problem?

2013/8/2 R. Rajesh Jeba Anbiah notifications@github.com

We tried the new jar, but getting below error.

System error 500: play.exceptions.JavaExecutionException: Japid template class not found: japidviews.Users_Controller.home

Since, there's some urgency, we have decided to downgrade our japid version now (Though standalone version may work, we thought it may demand more time/changes.). After that we'll closely try this with other options and update.

Many thanks for your great support.

— Reply to this email directly or view it on GitHubhttps://github.com/branaway/Japid/issues/55#issuecomment-22002650 .

rrjanbiah commented 11 years ago

Sure, will do. This could be a problem at our end too. Anyway, we'll check this little later. Thanks again for your help.

branaway commented 11 years ago

I have identified one bug with Japid and one defect with Play that prevents standalone Japid mode with Tomcat. Can you try 0.9.23 and see if it has dealt with them.

branaway commented 11 years ago

this is a sample dependencies.yml file to reference them:

require:
    - cn.bran -> japid 0.9.23
    - cn.bran -> japidplay 0.9.23
    - org.eclipse.tycho -> org.eclipse.jdt.core 3.8.2.v20120814-155456
    - com.google.code.javaparser -> javaparser 1.0.8

# My custom repositories
repositories:
    - bran:
        type:       http
        artifact:   "https://raw.github.com/branaway/Japid/master/lib/[module]-[revision].[ext]"
        contains:
            - cn.bran -> *
rrjanbiah commented 11 years ago

Bing, thanks a lot for your great efforts. Currently, we're working to launch one website. So, please allow me to provide with more updates in few days time. Thanks again.

rrjanbiah commented 11 years ago

For a quick check, we tested with JapidContact2 application. We get same error as shown below. Note that we haven't yet checked the standalone version, as we're more inclined towards japid play version due to its invoke and content negotiation features.

System error 500: play.exceptions.JavaExecutionException: Japid template class not found: japidviews.Application.index
Execution exception (/app/controllers/Application.java:14)
RuntimeException occured : Japid template class not found: japidviews.Application.index

play.exceptions.JavaExecutionException: Japid template class not found: japidviews.Application.index
    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:236)
    at play.server.ServletWrapper$ServletInvocation.execute(ServletWrapper.java:562)
    at play.Invoker$Invocation.run(Invoker.java:282)
    at play.server.ServletWrapper$ServletInvocation.run(ServletWrapper.java:553)
    at play.Invoker.invokeInThread(Invoker.java:72)
    at play.server.ServletWrapper.service(ServletWrapper.java:141)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: Japid template class not found: japidviews.Application.index
    at cn.bran.play.JapidPlayRenderer.getTemplateClass(JapidPlayRenderer.java:65)
    at cn.bran.play.JapidController2.getRenderClass(JapidController2.java:284)
    at cn.bran.play.JapidController2.getRenderResultWith(JapidController2.java:307)
    at cn.bran.play.JapidController2.renderJapidWith(JapidController2.java:185)
    at cn.bran.play.JapidController2.renderJapid(JapidController2.java:171)
    at controllers.Application.index(Application.java:14)
    at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:556)
    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:507)
    at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:483)
    at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:478)
    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:160)
    ... 22 more
branaway commented 11 years ago

I got the same error with an older version of Japid because of the way it dealt with path containing dot. I have fixed that. And I have my sample app deployed on tomcat and its working. Can you try the latest jars in the Japid project, in the lib dir?

2013/8/5 R. Rajesh Jeba Anbiah notifications@github.com

For a quick check, we tested with JapidContact2 application. We get same error as shown below. Note that we haven't yet checked the standalone version, as we're more inclined towards japid play version due to its invoke and content negotiation features.

System error 500: play.exceptions.JavaExecutionException: Japid template class not found: japidviews.Application.index

Execution exception (/app/controllers/Application.java:14) RuntimeException occured : Japid template class not found: japidviews.Application.index

play.exceptions.JavaExecutionException: Japid template class not found: japidviews.Application.index at play.mvc.ActionInvoker.invoke(ActionInvoker.java:236) at play.server.ServletWrapper$ServletInvocation.execute(ServletWrapper.java:562) at play.Invoker$Invocation.run(Invoker.java:282) at play.server.ServletWrapper$ServletInvocation.run(ServletWrapper.java:553) at play.Invoker.invokeInThread(Invoker.java:72) at play.server.ServletWrapper.service(ServletWrapper.java:141) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.RuntimeException: Japid template class not found: japidviews.Application.index at cn.bran.play.JapidPlayRenderer.getTemplateClass(JapidPlayRenderer.java:65) at cn.bran.play.JapidController2.getRenderClass(JapidController2.java:284) at cn.bran.play.JapidController2.getRenderResultWith(JapidController2.java:307) at cn.bran.play.JapidController2.renderJapidWith(JapidController2.java:185) at cn.bran.play.JapidController2.renderJapid(JapidController2.java:171) at controllers.Application.index(Application.java:14) at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:556) at play.mvc.ActionInvoker.invoke(ActionInvoker.java:507) at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:483) at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:478) at play.mvc.ActionInvoker.invoke(ActionInvoker.java:160) ... 22 more

— Reply to this email directly or view it on GitHubhttps://github.com/branaway/Japid/issues/55#issuecomment-22114916 .

branaway commented 11 years ago

I have updated the JapidContact2 sample app to refer to Japid 0.9.25. It worked OK with my local Tomcat 7.

I wonder it would work in your environment.

1 Clone the latest Japid from github. 2 cd JapidContact2 3 play deps --sync 4 play run

To deploy to Tomcat:

  1. play war JapidContact2 -o jc2
  2. copy the jc2 folder to tomcat webapps
  3. start tomcat
  4. browse to http://localhost:8080/jc2
rrjanbiah commented 11 years ago

Sorry, I hope, we tried with the latest. Anyway, will try again. Thanks again for your great support.

rrjanbiah commented 11 years ago

Bing, I can confirm that we didn't use the latest jar. But, we're yet to check the latest jar. Since, we're working for the release, it's taking time. Sorry for that. I hope latest jar should work as you have already checked. We'll check as soon as we're set. Thanks again.

branaway commented 11 years ago

I have changed the location where the jars are located in the github:

this is a sample dependencies.yml file to reference them:

require:
    - cn.bran -> japid 0.9.27
    - cn.bran -> japidplay 0.9.27
    - com.google.code.javaparser -> javaparser 1.0.8

# My custom repositories
repositories:
    - bran:
        type:       http
        artifact:   "https://raw.github.com/branaway/Japid/master/dist-lib/[module]-[revision].[ext]"
        contains:
            - cn.bran -> *
rrjanbiah commented 11 years ago

Thanks, will check and update by Monday. We're in holiday mood now:-)

rrjanbiah commented 11 years ago

Thanks, the latest version is working fine. Thanks for the great work.

branaway commented 11 years ago

cool...

2013/8/12 R. Rajesh Jeba Anbiah notifications@github.com

Thanks, the latest version is working fine. Thanks for the great work.

— Reply to this email directly or view it on GitHubhttps://github.com/branaway/Japid/issues/55#issuecomment-22503604 .

rrjanbiah commented 11 years ago

Sorry to notice this now. Not critical, but... this version requires that HTML template files be present. In previous version, we can remove template files after precompiling.

branaway commented 11 years ago

I'll take car of that...

2013/8/16 R. Rajesh Jeba Anbiah notifications@github.com

Sorry to notice this now. Not critical, but... this version requires that HTML template files be present. In previous version, we can remove template files after precompiling.

— Reply to this email directly or view it on GitHubhttps://github.com/branaway/Japid/issues/55#issuecomment-22750809 .

rrjanbiah commented 11 years ago

Thanks Bing:-)