branaway / japid42

A full feaured Java-based template engine for Play2
57 stars 11 forks source link

Play2.1-RC - Fails to compile with "package scala.actors.threadpool does not exist" #9

Open brainwatch opened 12 years ago

brainwatch commented 12 years ago

Hi

I tried publishing the latest japid with latest play2.1rc build and the compilation process fails with the following error.

[error] D:\japid42\app\cn\bran\japid\template\JapidRenderer.java:35: error: package scala.actors.threadpool does not exist [error] import scala.actors.threadpool.Arrays; [error] ^ [error] D:\japid42\app\cn\bran\japid\template\JapidRenderer.java:1101: error: cannot find symbol [error] List list = Arrays.asList(header); [error] ^ [error] symbol: variable Arrays [error] location: class JapidRenderer [error] D:\japid42\app\cn\bran\japid\template\JapidRenderer.java:1109: error: cannot find symbol [error] List list = Arrays.asList(header); [error] ^ [error] symbol: variable Arrays [error] location: class JapidRenderer [error] Note: D:\japid42\app\cn\bran\play\CacheablePlayActionRunnerImpl1.java

NOTE: I have changed the build.properties entry to "sbt.version=0.12.1" and plugins.sbt entry to "2.1-SNAPSHOT"

branaway commented 12 years ago

Thanks for reporting. I'll take a look. I've not tested with 2.1 yet.

branaway commented 12 years ago

created a new brach for2.1 and it should compile. Please update and checkout that branch and see if it works.

branaway commented 12 years ago

Due to a bug with2.1, to make it compile, I have to add a dummy routes file, which might interfere with your app's route. it's an issue to be investigated.

brainwatch commented 12 years ago

I managed to compile and publish. I have changed the Global.java in my modules as per computer-japid example you have provided.

I have not tried for the scenario you have mentioned where the modules are considered as the sub-modules and the source base is available within the project scope. I tried for my requirements, as mentioned earlier, I'm trying to publish each module which wraps all its resources into jar and trying to extend the external module from main module. This scenario is not working. It gives the same error that the views are not available.

[RuntimeException: renderer class not found: japidviews.RouterA.a1. Consider creating the Japid script file @: [japidroot,japidroot]\japidviews\RouterA\a1.html]

For example :

If I'm trying to create a SecureSocial module in japid version and then publish it, it cannot be used as is used currently. Currently its scala template based and we can just publish the module without adding the source base in our main module and can access the secureSocial pages from the published module.

This will restrict me partially from creating reusable modules and publish it .

branaway commented 12 years ago

You're right, I have not done anything yet to support this. It requires some work. I'm still trying to figure out the best way to do it.

2012/11/22 brainwatch notifications@github.com

I managed to compile and publish. I have changed the Global.java in my modules as per computer-japid example you have provided.

I have not tried for the scenario you have mentioned where the modules are considered as the sub-modules and the source base is available within the project scope. I tried for my requirements, as mentioned earlier, I'm trying to publish each module which wraps all its resources into jar and trying to extend the external module from main module. This scenario is not working. It gives the same error that the views are not available.

[RuntimeException: renderer class not found: japidviews.RouterA.a1. Consider creating the Japid script file @: [japidroot,japidroot]\japidviews\RouterA\a1.html]

— Reply to this email directly or view it on GitHubhttps://github.com/branaway/japid42/issues/9#issuecomment-10625241.

brainwatch commented 11 years ago

Hi

Just to add to the thought process some issues which I could see are

  1. Template sharing ( Access common templates from other modules which is published and added to the dependency )
  2. Template precedence : In the above case the individual module requires a template to work independently while development and hence a template loading mechanism which on need basis can be switched on or off whether to use local or centralized template.
  3. Extension ( Override ) : Similar to the previous point but applies to all the html, If I need to change a particular html's behaviour which lies in another module which I have extended. How can this be achieved. eg: If Secure social module is implemented with Japid and When I use the module in many projects, I should have the ability to override the login page to give the same look and feel of the application in which I'm extending SecureSocial.
  4. Cross Template Language Functional : This is pretty tricky, but is my actual problem too. I have developed the application using Japid Template and I'm using SecureSocial in my application which is developed using Scala Templates. I want to override the login page of SecureSocial ( Which I can do by implementing another Scala template ) but using Japid Template. Is there a way to give a hook that can be provided to mock the Japid template as a scala template.
branaway commented 11 years ago

Assuming that a later Japid version will implemented using Japid in such a way,

  1. Japid scripts will probably be treated as resource on the classpath. So sharing is natural.
  2. Not sure if this can be properly implemented. 3 & 4. I'll need to find out how the secure social couple the templates it requires. It would be silly for Secure Social to require that the error presentation content be code in a specific templating mechanism.

I hope I can deal with your original request in my next iteration if Japid2.

Thanks!

2012/12/24 brainwatch notifications@github.com

Hi

Just to add to the thought process some issues which I could see are

1.

Template sharing ( Access common templates from other modules which is published and added to the dependency ) 2.

Template precedence : In the above case the individual module requires a template to work independently while development and hence a template loading mechanism which on need basis can be switched on or off whether to use local or centralized template. 3.

Extension ( Override ) : Similar to the previous point but applies to all the html, If I need to change a particular html's behaviour which lies in another module which I have extended. How can this be achieved. eg: If Secure social module is implemented with Japid and When I use the module in many projects, I should have the ability to override the login page to give the same look and feel of the application in which I'm extending SecureSocial. 4.

Cross Template Language Functional : This is pretty tricky, but is my actual problem too. I have developed the application using Japid Template and I'm using SecureSocial in my application which is developed using Scala Templates. I want to override the login page of SecureSocial ( Which I can do by implementing another Scala template ) but using Japid Template. Is there a way to give a hook that can be provided to mock the Japid template as a scala template.

— Reply to this email directly or view it on GitHubhttps://github.com/branaway/japid42/issues/9#issuecomment-11654940.

brainwatch commented 11 years ago

Hi

Any update on the issues I had raised ?

Just a quick update

I was able to achieve point 1 by calling the japidviews class file using render(Class, Object args...).

But this will not work if I switch off the config of keepJavaFiles(false); Then the system could not find the class specified and throws null pointer at runtime.

Is there a way to get hold of the Classes generated in memory through the class loader ?

    public static Result index() {
        return render(viewOf("japidviews.Application.index"), "Brainwatch");
    }

    public static Result test() {
        return render(viewOf("japidviews.Application.test"), "Test");
    }

    private static Class viewOf(String fileNameWithPath) {
        Class clazz = null;
        try {
            clazz = Class.forName(fileNameWithPath).asSubclass(JapidTemplateBase.class);

        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return clazz;
    }
branaway commented 11 years ago

Hi,

Your use case comes to my mind from time to time but I don't think I have figured it out yet.

I'll revisit it some time later. In the meantime, do you think using Japid without heavily depending on Play would help in any way?.

It's extremely simple to use Japid generically:

Basically you call:

JapidRenderer.setXXX(); JapidRenderer.init(...)

once somewhere in your code and invoke Japid renderer anywhere in any Java application:

JapidRenderer.render(...) or renderWith(...) or renderDynamic(...)

It's in the readme in the github project.

Not sure it will help but I guess does not hurt to know this option.

Bing

2013/6/21 brainwatch notifications@github.com

Hi

Any update on the issues I had raised ?

Just a quick update

I was able to achieve point 1 by calling the japidviews class file using render(Class, Object args...).

But this will not work if I switch off the config of keepJavaFiles(false); Then the system could not find the class specified and throws null pointer at runtime.

public static Result index() {
    return render(viewOf("japidviews.Application.index"), "Brainwatch");
}

public static Result test() {
    return render(viewOf("japidviews.Application.test"), "Test");
}

private static Class viewOf(String fileNameWithPath) {
    Class clazz = null;
    try {
        clazz = Class.forName(fileNameWithPath).asSubclass(JapidTemplateBase.class);

    } catch (ClassNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return clazz;
}

— Reply to this email directly or view it on GitHubhttps://github.com/branaway/japid42/issues/9#issuecomment-19815931 .

branaway commented 11 years ago

Do you have a sample project with the sub-project structure and the SecureSocial module configured to demo the issue?

I almost started to code something about publishing Japid scripts in jars but could not figure out how to include the japid root tree in a distribution. I'm still stumbled on that since I know very little about sbt and Scala for that matter.

2013/6/22 Bing Ran bing.ran@gmail.com

Hi,

Your use case comes to my mind from time to time but I don't think I have figured it out yet.

I'll revisit it some time later. In the meantime, do you think using Japid without heavily depending on Play would help in any way?.

It's extremely simple to use Japid generically:

Basically you call:

JapidRenderer.setXXX(); JapidRenderer.init(...)

once somewhere in your code and invoke Japid renderer anywhere in any Java application:

JapidRenderer.render(...) or renderWith(...) or renderDynamic(...)

It's in the readme in the github project.

Not sure it will help but I guess does not hurt to know this option.

Bing

2013/6/21 brainwatch notifications@github.com

Hi

Any update on the issues I had raised ?

Just a quick update

I was able to achieve point 1 by calling the japidviews class file using render(Class, Object args...).

But this will not work if I switch off the config of keepJavaFiles(false); Then the system could not find the class specified and throws null pointer at runtime.

public static Result index() {
    return render(viewOf("japidviews.Application.index"), "Brainwatch");
}

public static Result test() {
    return render(viewOf("japidviews.Application.test"), "Test");
}

private static Class viewOf(String fileNameWithPath) {
    Class clazz = null;
    try {
        clazz = Class.forName(fileNameWithPath).asSubclass(JapidTemplateBase.class);

    } catch (ClassNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return clazz;
}

— Reply to this email directly or view it on GitHubhttps://github.com/branaway/japid42/issues/9#issuecomment-19815931 .

brainwatch commented 11 years ago

Hi

Thanks for the revert.

  1. I'm not sure I would want to use Japid without play, 'cos I would want to use play for some reasons and its features with simple and faster template mechanism. Hence recommended Play with Japid.
  2. I do not have securesocial as sub project but as a published component included in dependency for another component.
branaway commented 11 years ago

Sorry I did not mean to recommend using Japid without Play. Japid can be used with Play either in deeply-tied mode (using the JapidController) or in a none-dependent mode, similar to using Velocity or Freemarker, with the difference being the availability of the implicit objects, such as the request, response, etc.

I have been working on a mechanism of using Japid scripts packaged in jars in the last few days. The intention is to allow developers to package Japid scripts as resources in jars to be used else where. It's largely working and almost ready to be released, although I'm not sure how much it would help with your original problem.

2013/6/26 brainwatch notifications@github.com

Hi

Thanks for the revert.

1.

I'm not sure I would want to use Japid without play, 'cos I would want to use play for some reasons and its features with simple and faster template mechanism. Hence recommended Play with Japid. 2.

I do not have securesocial as sub project but as a published component included in dependency for another component.

— Reply to this email directly or view it on GitHubhttps://github.com/branaway/japid42/issues/9#issuecomment-20036054 .

brainwatch commented 11 years ago

That would be great and I would be happy to do the pilot implementation

brainwatch commented 11 years ago

Hi

Is there a release of the "Japid scripts packaged in jars" version anytime soon ?

branaway commented 11 years ago

Hi, Sorry for the delay until now that I have released 0.9.5 and 0.9.6, which support using japid script resources in jar files. The delay had been due to the fact the route file in sub-project seemed to interfere with the main project. Since the new version of Japid support a routing mechanism based on annotations and some conventions and do away with the route files, I believe it should help you to achieve your original goal. See the readme file in the root package for more detail.

brainwatch commented 11 years ago

Hi

Thanks for the update. Will try and let you know.

brainwatch commented 11 years ago

Hi

Thanks Bran. Works perfectly fine.

branaway commented 11 years ago

glad to hear that!

2013/7/24 brainwatch notifications@github.com

Hi

Thanks Bran. Works perfectly fine.

— Reply to this email directly or view it on GitHubhttps://github.com/branaway/japid42/issues/9#issuecomment-21473716 .

branaway commented 11 years ago

image