OSGi-fied JSR 223 JRuby engine

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

OSGi-fied JSR 223 JRuby engine

Yoko Harada
Hi,

I've released JSR 223 JRuby engine independenly at
https://scripting.dev.java.net/servlets/ProjectDocumentList?folderID=8848&expandFolder=8848&folderID=8848
expecially for JDK 1.5 users.

I just released JRuby engine 1.1.5, which is JRuby 1.1.4 compliant
version and should be OSGi-fied one. However, I'm not sure this
release really fixes issue
37(https://scripting.dev.java.net/issues/show_bug.cgi?id=37) filed in
the scripting project's issue tracker. How can I test released
archives work with Apache Sling?

-Yoko

Reply | Threaded
Open this post in threaded view
|

Re: OSGi-fied JSR 223 JRuby engine

Felix Meschberger-2
Hi Yoko,

Yoko Harada schrieb:

> Hi,
>
> I've released JSR 223 JRuby engine independenly at
> https://scripting.dev.java.net/servlets/ProjectDocumentList?folderID=8848&expandFolder=8848&folderID=8848
> expecially for JDK 1.5 users.
>
> I just released JRuby engine 1.1.5, which is JRuby 1.1.4 compliant
> version and should be OSGi-fied one. However, I'm not sure this
> release really fixes issue
> 37(https://scripting.dev.java.net/issues/show_bug.cgi?id=37) filed in
> the scripting project's issue tracker. How can I test released
> archives work with Apache Sling?

It should be fairly easy: just install the required bundle(s) into sling
  (I generally use the Apache Felix Web Console). The Sling scripting
infrastructure should recognize the JRuby bundle, which contains the
ScriptEngineFactory provided the factory is listed in the
META-INF/services folders as described by JSR-223.

When the ScriptEngineFactory has been picked up, you should be able to
write scripts with the extension supported by the ScriptEngine.

Unfortunately there is no other way yet, to find out whether the script
engine has been "accepted".


For example, you could do the following:

   - start Sling
   - install the JRuby bundles
   - look in the Sling log (logs/error.log) for any
        errors during the installation
   - open a web dav connect to Sling (e.g. if Sling is
        started on por 8888, open to http://host:8888/)
   - create a script at /apps/sling/nonexisting/GET.erb
        (given erb would be the JRuby extension)
   - with your browser access http://host:8888/missing/page.html

The last part causes a non existing resource of type sling:nonexisting
to be used for processing and the /apps/sling/nonexisting/GET.erb would
be called to process the request.

Hope this helps.

Regards
Felix

Reply | Threaded
Open this post in threaded view
|

Re: OSGi-fied JSR 223 JRuby engine

Bertrand Delacretaz
On Sun, Aug 31, 2008 at 9:02 PM, Felix Meschberger <[hidden email]> wrote:

> ...When the ScriptEngineFactory has been picked up, you should be able to write
> scripts with the extension supported by the ScriptEngine.
>
> Unfortunately there is no other way yet, to find out whether the script
> engine has been "accepted"....

I have improved this a tiny bit by logging the complete mapping of
extensions to ScriptEngines whenever the ScriptEngineManager is
(re)initialized. See SLING-636.

-Bertrand

Reply | Threaded
Open this post in threaded view
|

Re: OSGi-fied JSR 223 JRuby engine

Yoko Harada
In reply to this post by Felix Meschberger-2
Hi Felix,

Thanks for giving me an idea. Let me ask a couple questions since I'm
sill struggling to get things work.
I followed the instruction described at
http://incubator.apache.org/sling/site/discover-sling-in-15-minutes.html
to install and start sling. I could probably intall JRuby engine
successfully by using the form in
http://localhost:8888/system/console/list. When I looked at
http://localhost:8888/system/console/list after restarting jetty
server, I could see the entry "40 JRuby JSR223 Engine" showed up in
the list. However, the status was "Installed" and not "Active." When I
clicked on a start button on the left, an error.log said as follows:

03.09.2008 09:39:00.287 *ERROR* [btpool0-1] org.apache.felix.webconsole Cannot s
tart (org.osgi.framework.BundleException: Unresolved package in bundle 40: packa
ge; (package=org.jruby.runtime.builtin)) org.osgi.framework.BundleException: Unr
esolved package in bundle 40: package; (package=org.jruby.runtime.builtin)
        at org.apache.felix.framework.Felix._resolveBundle(Felix.java:1728)
        at org.apache.felix.framework.Felix._startBundle(Felix.java:1591)
        at org.apache.felix.framework.Felix.startBundle(Felix.java:1544)
        at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:371)
        at org.apache.felix.webconsole.internal.core.StartAction.performAction(S
tartAction.java:58)
        at org.apache.felix.webconsole.internal.servlet.OsgiManager.handleAction
(OsgiManager.java:306)
(skip)

JSR 223 JRuby engine needes JRuby archives to get it start. How can I
install jruby.jar into Sling or where to put ruby.jar in a directory
tree?

My another question is where /apps/sling/nonexisting/GET.erb should be
in the sling directory tree? I tried curl command as in "Create some
content" section of
http://incubator.apache.org/sling/site/discover-sling-in-15-minutes.html.
However, I don't have /apps/foo/bar directory anywhere under the sling
directory tree. Am I missing something?

My last question is what document should I read to know how to get JSR
223 scripting engines work? I googled but could not find any document
available.

Thanks

-Yoko

On Sun, Aug 31, 2008 at 3:02 PM, Felix Meschberger <[hidden email]> wrote:

> Hi Yoko,
>
> Yoko Harada schrieb:
>>
>> Hi,
>>
>> I've released JSR 223 JRuby engine independenly at
>>
>> https://scripting.dev.java.net/servlets/ProjectDocumentList?folderID=8848&expandFolder=8848&folderID=8848
>> expecially for JDK 1.5 users.
>>
>> I just released JRuby engine 1.1.5, which is JRuby 1.1.4 compliant
>> version and should be OSGi-fied one. However, I'm not sure this
>> release really fixes issue
>> 37(https://scripting.dev.java.net/issues/show_bug.cgi?id=37) filed in
>> the scripting project's issue tracker. How can I test released
>> archives work with Apache Sling?
>
> It should be fairly easy: just install the required bundle(s) into sling  (I
> generally use the Apache Felix Web Console). The Sling scripting
> infrastructure should recognize the JRuby bundle, which contains the
> ScriptEngineFactory provided the factory is listed in the META-INF/services
> folders as described by JSR-223.
>
> When the ScriptEngineFactory has been picked up, you should be able to write
> scripts with the extension supported by the ScriptEngine.
>
> Unfortunately there is no other way yet, to find out whether the script
> engine has been "accepted".
>
>
> For example, you could do the following:
>
>  - start Sling
>  - install the JRuby bundles
>  - look in the Sling log (logs/error.log) for any
>       errors during the installation
>  - open a web dav connect to Sling (e.g. if Sling is
>       started on por 8888, open to http://host:8888/)
>  - create a script at /apps/sling/nonexisting/GET.erb
>       (given erb would be the JRuby extension)
>  - with your browser access http://host:8888/missing/page.html
>
> The last part causes a non existing resource of type sling:nonexisting to be
> used for processing and the /apps/sling/nonexisting/GET.erb would be called
> to process the request.
>
> Hope this helps.
>
> Regards
> Felix
>

Reply | Threaded
Open this post in threaded view
|

Re: OSGi-fied JSR 223 JRuby engine

Felix Meschberger-2
Hi Yoko,

Sorry for the late answer ....

Yoko Harada schrieb:

> Hi Felix,
>
> Thanks for giving me an idea. Let me ask a couple questions since I'm
> sill struggling to get things work.
> I followed the instruction described at
> http://incubator.apache.org/sling/site/discover-sling-in-15-minutes.html
> to install and start sling. I could probably intall JRuby engine
> successfully by using the form in
> http://localhost:8888/system/console/list. When I looked at
> http://localhost:8888/system/console/list after restarting jetty
> server, I could see the entry "40 JRuby JSR223 Engine" showed up in
> the list. However, the status was "Installed" and not "Active." When I
> clicked on a start button on the left, an error.log said as follows:
>
> 03.09.2008 09:39:00.287 *ERROR* [btpool0-1] org.apache.felix.webconsole Cannot s
> tart (org.osgi.framework.BundleException: Unresolved package in bundle 40: packa
> ge; (package=org.jruby.runtime.builtin)) org.osgi.framework.BundleException: Unr
> esolved package in bundle 40: package; (package=org.jruby.runtime.builtin)
>         at org.apache.felix.framework.Felix._resolveBundle(Felix.java:1728)
>         at org.apache.felix.framework.Felix._startBundle(Felix.java:1591)
>         at org.apache.felix.framework.Felix.startBundle(Felix.java:1544)
>         at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:371)
>         at org.apache.felix.webconsole.internal.core.StartAction.performAction(S
> tartAction.java:58)
>         at org.apache.felix.webconsole.internal.servlet.OsgiManager.handleAction
> (OsgiManager.java:306)
> (skip)
>
> JSR 223 JRuby engine needes JRuby archives to get it start. How can I
> install jruby.jar into Sling or where to put ruby.jar in a directory
> tree?

The easiest thing to do probably is to include the jruby.jar file in
your ruby bundle together with the JRuby engine. This way you can hide
the complety JRuby internals from the outside world and just provide the
ScriptEngine[Factory] for use.

>
> My another question is where /apps/sling/nonexisting/GET.erb should be
> in the sling directory tree? I tried curl command as in "Create some
> content" section of
> http://incubator.apache.org/sling/site/discover-sling-in-15-minutes.html.
> However, I don't have /apps/foo/bar directory anywhere under the sling
> directory tree. Am I missing something?

Easiest thing for creating a file is using WebDAV: Just connect to
<a href="http://host:port/dav/default">http://host:port/dav/default and create the /apps/sling/nonexisting
folder and therein the GET.erb file.

The /apps/foo/bar node (aka resource) should not exist. If you access it
using Sling, internally a NonExistingResource instance with the path
/apps/foo/bar is used which has the resource type sling:nonexisting.
This causes the /apps/sling/nonexisting/GET.erb to be called.

>
> My last question is what document should I read to know how to get JSR
> 223 scripting engines work? I googled but could not find any document
> available.

Good question ... The first stop gap is certainly the JSR-223
specification itself, which tells you about what a ScriptEngineFactory
and ScriptEngine have to do. Then I suggest you might look at the
jsr233.dev.java.net project and see how others implement the interfaces.

Third is integrating this stuff such, that it may be used in an OSGi
framework such as Sling. Unfortunately there is no documentation for
that yet (at least documentation I would know of). But I will be holding
a session on this issue at ApacheConUS08 in New Orleans. You are welcome
to join ;-) As part of preparing that talk, I will certainly create some
documentation and also the talk slides will be available after the
conference, of course.

Anyway here's how I would do it:

   * Create the ScriptEngine[Factory] implementations
   * Create a bundle comprising the above implementations as
        well as the script language implementation.
   * Create the META-INF/services/javax.script.ScriptEngineFactory
        file listing the fully qualified name of your
        ScriptEngineFactory implementaiton

This short text should display shortly below the Development [1] page of
the Sling site.

Hope this helps.

Regards
Felix

[1] http://incubator.apache.org/sling/site/development.html

>
> Thanks
>
> -Yoko
>
> On Sun, Aug 31, 2008 at 3:02 PM, Felix Meschberger <[hidden email]> wrote:
>> Hi Yoko,
>>
>> Yoko Harada schrieb:
>>> Hi,
>>>
>>> I've released JSR 223 JRuby engine independenly at
>>>
>>> https://scripting.dev.java.net/servlets/ProjectDocumentList?folderID=8848&expandFolder=8848&folderID=8848
>>> expecially for JDK 1.5 users.
>>>
>>> I just released JRuby engine 1.1.5, which is JRuby 1.1.4 compliant
>>> version and should be OSGi-fied one. However, I'm not sure this
>>> release really fixes issue
>>> 37(https://scripting.dev.java.net/issues/show_bug.cgi?id=37) filed in
>>> the scripting project's issue tracker. How can I test released
>>> archives work with Apache Sling?
>> It should be fairly easy: just install the required bundle(s) into sling  (I
>> generally use the Apache Felix Web Console). The Sling scripting
>> infrastructure should recognize the JRuby bundle, which contains the
>> ScriptEngineFactory provided the factory is listed in the META-INF/services
>> folders as described by JSR-223.
>>
>> When the ScriptEngineFactory has been picked up, you should be able to write
>> scripts with the extension supported by the ScriptEngine.
>>
>> Unfortunately there is no other way yet, to find out whether the script
>> engine has been "accepted".
>>
>>
>> For example, you could do the following:
>>
>>  - start Sling
>>  - install the JRuby bundles
>>  - look in the Sling log (logs/error.log) for any
>>       errors during the installation
>>  - open a web dav connect to Sling (e.g. if Sling is
>>       started on por 8888, open to http://host:8888/)
>>  - create a script at /apps/sling/nonexisting/GET.erb
>>       (given erb would be the JRuby extension)
>>  - with your browser access http://host:8888/missing/page.html
>>
>> The last part causes a non existing resource of type sling:nonexisting to be
>> used for processing and the /apps/sling/nonexisting/GET.erb would be called
>> to process the request.
>>
>> Hope this helps.
>>
>> Regards
>> Felix
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: OSGi-fied JSR 223 JRuby engine

Yoko Harada
Hi Felix,

On Fri, Sep 12, 2008 at 3:30 AM, Felix Meschberger <[hidden email]> wrote:
> Sorry for the late answer ....

Thank for remebering this, but this is not what I wanted to know. Let
me explain why I asked these questions to this list.

I release JSR 223 JRuby engine out there, and released the latest
version, 1.1.5, in the end of August. It  should have been fixed the
issue filed at https://scripting.dev.java.net/issues/show_bug.cgi?id=37,
but I was not sure that the latest release of JRuby engine was
OSGified. I wanted to know the way of checking it. This is for thoese
who want to use JSR 223 JRuby engin on Apache Sling and me, too, since
I'm interested in Apache Sling.

>
> Yoko Harada schrieb:
>> Hi Felix,
>>
>> Thanks for giving me an idea. Let me ask a couple questions since I'm
>> sill struggling to get things work.
>> I followed the instruction described at
>> http://incubator.apache.org/sling/site/discover-sling-in-15-minutes.html
>> to install and start sling. I could probably intall JRuby engine
>> successfully by using the form in
>> http://localhost:8888/system/console/list. When I looked at
>> http://localhost:8888/system/console/list after restarting jetty
>> server, I could see the entry "40 JRuby JSR223 Engine" showed up in
>> the list. However, the status was "Installed" and not "Active." When I
>> clicked on a start button on the left, an error.log said as follows:
>>
>> 03.09.2008 09:39:00.287 *ERROR* [btpool0-1] org.apache.felix.webconsole Cannot s
>> tart (org.osgi.framework.BundleException: Unresolved package in bundle 40: packa
>> ge; (package=org.jruby.runtime.builtin)) org.osgi.framework.BundleException: Unr
>> esolved package in bundle 40: package; (package=org.jruby.runtime.builtin)
>>         at org.apache.felix.framework.Felix._resolveBundle(Felix.java:1728)
>>         at org.apache.felix.framework.Felix._startBundle(Felix.java:1591)
>>         at org.apache.felix.framework.Felix.startBundle(Felix.java:1544)
>>         at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:371)
>>         at org.apache.felix.webconsole.internal.core.StartAction.performAction(S
>> tartAction.java:58)
>>         at org.apache.felix.webconsole.internal.servlet.OsgiManager.handleAction
>> (OsgiManager.java:306)
>> (skip)
>>
>> JSR 223 JRuby engine needes JRuby archives to get it start. How can I
>> install jruby.jar into Sling or where to put ruby.jar in a directory
>> tree?
>
> The easiest thing to do probably is to include the jruby.jar file in
> your ruby bundle together with the JRuby engine. This way you can hide
> the complety JRuby internals from the outside world and just provide the
> ScriptEngine[Factory] for use.

Including jruby.jar into jruby-engine.jar is unable because JSR 223
JRuby engine adopts differenct type of software license from JRuby. I
can put those archives into a bundle for personal use but cannot for
release archives. I want to know how to deploy JRuby which is
necessary for JRuby engine to run.

If the issue, https://scripting.dev.java.net/issues/show_bug.cgi?id=31,
is resolved, will this problem be fixed?

>
>>
>> My another question is where /apps/sling/nonexisting/GET.erb should be
>> in the sling directory tree? I tried curl command as in "Create some
>> content" section of
>> http://incubator.apache.org/sling/site/discover-sling-in-15-minutes.html.
>> However, I don't have /apps/foo/bar directory anywhere under the sling
>> directory tree. Am I missing something?
>
> Easiest thing for creating a file is using WebDAV: Just connect to
> <a href="http://host:port/dav/default">http://host:port/dav/default and create the /apps/sling/nonexisting
> folder and therein the GET.erb file.
>
> The /apps/foo/bar node (aka resource) should not exist. If you access it
> using Sling, internally a NonExistingResource instance with the path
> /apps/foo/bar is used which has the resource type sling:nonexisting.
> This causes the /apps/sling/nonexisting/GET.erb to be called.

I'll try this though .erb, Ruby template, is another Ruby extension
than JRuby engine.

-Yoko

>>
>> My last question is what document should I read to know how to get JSR
>> 223 scripting engines work? I googled but could not find any document
>> available.
>
> Good question ... The first stop gap is certainly the JSR-223
> specification itself, which tells you about what a ScriptEngineFactory
> and ScriptEngine have to do. Then I suggest you might look at the
> jsr233.dev.java.net project and see how others implement the interfaces.
>
> Third is integrating this stuff such, that it may be used in an OSGi
> framework such as Sling. Unfortunately there is no documentation for
> that yet (at least documentation I would know of). But I will be holding
> a session on this issue at ApacheConUS08 in New Orleans. You are welcome
> to join ;-) As part of preparing that talk, I will certainly create some
> documentation and also the talk slides will be available after the
> conference, of course.
>
> Anyway here's how I would do it:
>
>   * Create the ScriptEngine[Factory] implementations
>   * Create a bundle comprising the above implementations as
>        well as the script language implementation.
>   * Create the META-INF/services/javax.script.ScriptEngineFactory
>        file listing the fully qualified name of your
>        ScriptEngineFactory implementaiton
>
> This short text should display shortly below the Development [1] page of
> the Sling site.
>
> Hope this helps.
>
> Regards
> Felix
>
> [1] http://incubator.apache.org/sling/site/development.html
>
>>
>> Thanks
>>
>> -Yoko
>>
>> On Sun, Aug 31, 2008 at 3:02 PM, Felix Meschberger <[hidden email]> wrote:
>>> Hi Yoko,
>>>
>>> Yoko Harada schrieb:
>>>> Hi,
>>>>
>>>> I've released JSR 223 JRuby engine independenly at
>>>>
>>>> https://scripting.dev.java.net/servlets/ProjectDocumentList?folderID=8848&expandFolder=8848&folderID=8848
>>>> expecially for JDK 1.5 users.
>>>>
>>>> I just released JRuby engine 1.1.5, which is JRuby 1.1.4 compliant
>>>> version and should be OSGi-fied one. However, I'm not sure this
>>>> release really fixes issue
>>>> 37(https://scripting.dev.java.net/issues/show_bug.cgi?id=37) filed in
>>>> the scripting project's issue tracker. How can I test released
>>>> archives work with Apache Sling?
>>> It should be fairly easy: just install the required bundle(s) into sling  (I
>>> generally use the Apache Felix Web Console). The Sling scripting
>>> infrastructure should recognize the JRuby bundle, which contains the
>>> ScriptEngineFactory provided the factory is listed in the META-INF/services
>>> folders as described by JSR-223.
>>>
>>> When the ScriptEngineFactory has been picked up, you should be able to write
>>> scripts with the extension supported by the ScriptEngine.
>>>
>>> Unfortunately there is no other way yet, to find out whether the script
>>> engine has been "accepted".
>>>
>>>
>>> For example, you could do the following:
>>>
>>>  - start Sling
>>>  - install the JRuby bundles
>>>  - look in the Sling log (logs/error.log) for any
>>>       errors during the installation
>>>  - open a web dav connect to Sling (e.g. if Sling is
>>>       started on por 8888, open to http://host:8888/)
>>>  - create a script at /apps/sling/nonexisting/GET.erb
>>>       (given erb would be the JRuby extension)
>>>  - with your browser access http://host:8888/missing/page.html
>>>
>>> The last part causes a non existing resource of type sling:nonexisting to be
>>> used for processing and the /apps/sling/nonexisting/GET.erb would be called
>>> to process the request.
>>>
>>> Hope this helps.
>>>
>>> Regards
>>> Felix
>>>
>>
>