You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Patrick Refondini <pa...@pobox.com> on 2006/11/29 01:31:49 UTC

How to run block built with cocoon-22-archetype-block

Following doc:

http://cocoon.zones.apache.org/daisy/documentation/g1/1159.html


I created a fresh block with:

mvn archetype:create -DarchetypeGroupId=org.apache.cocoon 
-DarchetypeArtifactId=cocoon-22-archetype-webapp 
-DarchetypeVersion=1.0.0-M4-SNAPSHOT -DgroupId=my.domain 
-DartifactId=testwebapp


Using installed local cocoon trunk at revision 480141 build with:

-Dmaven.war.shieldingclassloader=false

java version "1.5.0_06" on MacOSX 10.4.6
Maven version: 2.0.4

While trying either mvn package, mvn jetty:run, mvn jetty6:run
I always get the following error:

[INFO] Scanning for projects...
[INFO] 
----------------------------------------------------------------------------
[INFO] Building testblock
[INFO]    task-segment: [package]
[INFO] 
----------------------------------------------------------------------------
[INFO] 
------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] 
------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).


Project ID: org.apache.cocoon:cocoon-deployer-plugin

Reason: Error getting POM for 'org.apache.cocoon:cocoon-deployer-plugin' 
from the repository: Unable to read local copy of metadata: Cannot read 
metadata from 
'/Users/patrick/.m2/repository/org/apache/cocoon/cocoon-deployer-plugin/1.0.0-M2-SNAPSHOT/maven-metadata-central.xml': 
end tag name </head> must be the same as start tag <link> from line 17 
(position: TEXT seen .../planetmirror.com/themes/standard/pm.css\' 
type=\'text/css\'>\n</head>... @18:8)
   org.apache.cocoon:cocoon-deployer-plugin:pom:1.0.0-M2-SNAPSHOT


Any hint to work with block created from archetype ?

Patrick



Re: How to run block built with cocoon-22-archetype-block

Posted by Patrick Refondini <pa...@pobox.com>.
Reinhard Poetz wrote:
> Patrick Refondini wrote:
>> Reinhard Poetz wrote:
>>> Patrick Refondini wrote:
>>>
>>>> Is there a cocoon-22-archetype-block working with the current trunk ?
>>>
>>>
>>> no, yesterday evening I've started to work on it.
>>>
>> Great ! I'll be please to give feedback when it is available.
> 
> please try (IIRC, the only thing you forgot was the blocks-fw-impl 
> dependency)
I'll invest in that direction this week-end.

> 
>> What else can a user do to help ? Updating related documentation ? 
>> I'll have a look to the FAQ.
> 
> Documentation is always welcome! It would be great to have a second 
> getting started document ("Getting started in 5 minutes") that explains 
> how to connect to another block and how to use inheritance.
As far as my understanding permits, I'll be glad to update what's 
existing and propose something as you mention above as soon as I am able 
to make it work for myself :)

And by the way thanks for the great work.
Once a 2.2 release will be available, I think the Mavenization and 
Spring integration will ease Cocoon adoption a lot.

Patrick

> 


Re: How to run block built with cocoon-22-archetype-block

Posted by Patrick Refondini <pa...@pobox.com>.
Patrick Refondini wrote:
> Daniel Fagerstrom wrote:
> 
>> Patrick Refondini skrev:
>> ...
>>
>>> It seems that block protocol is not available from root webapp 
>>> according to:
>>> http://www.nabble.com/Configuring-BlockServlets-via-properties-and-sitemap-reloading-for-blocks-t2450880.html 
>>>
>>> Or do I miss something ?
>>
>> That is correct. The block servlets are Spring components that are 
>> wired together in a Spring configuration. The block connections are 
>> put into a property map where a key and a component reference are a 
>> associated. The key is used as block name in the block protocol within 
>> the block.
>>
>> As the root webapp not is a Spring component, it is not obvious how to 
>> use the mechanism for the block protocol within it. I started to 
>> implement another protocol that would make it possible to call blocks 
>> from the root sitemap using the block servlets component identifier, 
>> but I have not found the time to finish it.
>>
>> It is also possible to access static resources from a block using the 
>> blockcontext protocol. It is however not the recommended way as a 
>> block is intended to be an isolated unit that only should be accessed 
>> through its "public" API in form of the block protocol. The 
>> blockcontext protocol is more intended for internal use in Cocoon and 
>> for setting up the blockcontext property i the block servlet 
>> configuration.
> 
> Ok, I already read "bad practise" for the above (certainly from you) in 
> some thread, but now it is much clearer why.
> 
>>
>> One can also use a block for the "root" sitemap in this scenario 
>> everything is a block. For the moment I would say that this is the 
>> recommended way for those testing the blocks fw.
Ok, did it like:

mvn archetype:create \
     -DarchetypeGroupId=org.apache.cocoon \
     -DarchetypeArtifactId=cocoon-22-archetype-block \
     -DarchetypeVersion=1.0.0-M5-SNAPSHOT \
     -DgroupId=ch.extentis \
     -DartifactId=testroot


Modify:

src/main/resources/META-INF/cocoon/spring/block.xml

From:
     <property name="mountPath" value="/testroot" />

To:
     <property name="mountPath" value="/" />

Do not forget:
cd testroot
mvn install
cd ..

Then this block is accessible as "root" sitemap while included in a 
webapp such as:

mvn archetype:create \
     -DarchetypeGroupId=org.apache.cocoon \
     -DarchetypeArtifactId=cocoon-22-archetype-webapp \
     -DarchetypeVersion=1.0.0-M2-SNAPSHOT \
     -DgroupId=ch.extentis \
     -DartifactId=testwebapp

Modify pom.xml to add dependencies on testroot

cd testwebapp
mvn package jetty:run

testroot block is then accessible via http://localhost:8888/

Patrick

> 
> I will try this together with starting testing inter-block protocol 
> communications. I will certainly start a Block Protocol thread at that 
> time :)
> 
> Thanks for your valuable input,
> 
> Patrick
> 
>>
>> ======
>>
>> I don't know enough about the block archetype to answer the rest of 
>> your questions.
>>
>> /Daniel
>>
> 


Re: How to run block built with cocoon-22-archetype-block

Posted by Patrick Refondini <pa...@pobox.com>.
Daniel Fagerstrom wrote:
> Patrick Refondini skrev:
> ...
>> It seems that block protocol is not available from root webapp 
>> according to:
>> http://www.nabble.com/Configuring-BlockServlets-via-properties-and-sitemap-reloading-for-blocks-t2450880.html 
>>
>> Or do I miss something ?
> That is correct. The block servlets are Spring components that are wired 
> together in a Spring configuration. The block connections are put into a 
> property map where a key and a component reference are a associated. The 
> key is used as block name in the block protocol within the block.
> 
> As the root webapp not is a Spring component, it is not obvious how to 
> use the mechanism for the block protocol within it. I started to 
> implement another protocol that would make it possible to call blocks 
> from the root sitemap using the block servlets component identifier, but 
> I have not found the time to finish it.
> 
> It is also possible to access static resources from a block using the 
> blockcontext protocol. It is however not the recommended way as a block 
> is intended to be an isolated unit that only should be accessed through 
> its "public" API in form of the block protocol. The blockcontext 
> protocol is more intended for internal use in Cocoon and for setting up 
> the blockcontext property i the block servlet configuration.
Ok, I already read "bad practise" for the above (certainly from you) in 
some thread, but now it is much clearer why.

> 
> One can also use a block for the "root" sitemap in this scenario 
> everything is a block. For the moment I would say that this is the 
> recommended way for those testing the blocks fw.
I will try this together with starting testing inter-block protocol 
communications. I will certainly start a Block Protocol thread at that 
time :)

Thanks for your valuable input,

Patrick

> 
> ======
> 
> I don't know enough about the block archetype to answer the rest of your 
> questions.
> 
> /Daniel
> 


Re: How to run block built with cocoon-22-archetype-block

Posted by Daniel Fagerstrom <da...@nada.kth.se>.
Patrick Refondini skrev:
...
> It seems that block protocol is not available from root webapp 
> according to:
> http://www.nabble.com/Configuring-BlockServlets-via-properties-and-sitemap-reloading-for-blocks-t2450880.html 
>
> Or do I miss something ?
That is correct. The block servlets are Spring components that are wired 
together in a Spring configuration. The block connections are put into a 
property map where a key and a component reference are a associated. The 
key is used as block name in the block protocol within the block.

As the root webapp not is a Spring component, it is not obvious how to 
use the mechanism for the block protocol within it. I started to 
implement another protocol that would make it possible to call blocks 
from the root sitemap using the block servlets component identifier, but 
I have not found the time to finish it.

It is also possible to access static resources from a block using the 
blockcontext protocol. It is however not the recommended way as a block 
is intended to be an isolated unit that only should be accessed through 
its "public" API in form of the block protocol. The blockcontext 
protocol is more intended for internal use in Cocoon and for setting up 
the blockcontext property i the block servlet configuration.

One can also use a block for the "root" sitemap in this scenario 
everything is a block. For the moment I would say that this is the 
recommended way for those testing the blocks fw.

======

I don't know enough about the block archetype to answer the rest of your 
questions.

/Daniel


Re: How to run block built with cocoon-22-archetype-block

Posted by Patrick Refondini <pa...@pobox.com>.
Reinhard Poetz wrote:
> Patrick Refondini wrote:
>> Reinhard Poetz wrote:
>>> Patrick Refondini wrote:
>>>
>>>> Reinhard Poetz wrote:
>>>>
>>>>> Patrick Refondini wrote:
>>>>>
>>>>>> Is there a cocoon-22-archetype-block working with the current trunk ?
>>>>>
>>>>>
>>>>>
>>>>> no, yesterday evening I've started to work on it.
>>>>>
>>>> Great ! I'll be please to give feedback when it is available.
>>>
>>>
>>> please try (IIRC, the only thing you forgot was the blocks-fw-impl 
>>> dependency)
>> Indeed blocks-fw-impl was missing !
>>
>>
>> I have tested referencing the a testblock from a testwebapp as follow:
>>
>> Created testblock:
>>
>> mvn archetype:create -DarchetypeGroupId=org.apache.cocoon 
>> -DarchetypeArtifactId=cocoon-22-archetype-block 
>> -DarchetypeVersion=1.0.0-M4-SNAPSHOT -DgroupId=ch.extentis 
>> -DartifactId=testblock
>>
>> Installed testblock
>>
>> Created testwebapp
>>
>> mvn archetype:create -DarchetypeGroupId=org.apache.cocoon 
>> -DarchetypeArtifactId=cocoon-22-archetype-webapp 
>> -DarchetypeVersion=1.0.0-SNAPSHOT -DgroupId=ch.extentis 
>> -DartifactId=testwebapp
>>
>> Added testblock dependency to testwebapp POM:
>>
>> <dependency>
>>   <groupId>ch.extentis</groupId>
>>   <artifactId>testblock</artifactId>
>>   <version>1.0-SNAPSHOT</version>
>> </dependency>
>>
>> Added the following to testwebapp sitemap:
>>
>> <!--  Reference any block by its blockContextURL / mount path ?  -->
>> <map:match pattern="*/**">
>>   <map:mount uri-prefix="{1}" src="blockcontext:/{1}/"/>
>> </map:match>
> 
> This shouldn't be necessary to get some result from your testblock as it 
> is automaticially mounted.

1. Webapp

Sorry if I have introduced some confusion by talking of webapp 
"testwebapp" in a thread titled "How to run block...". I did that test 
while lacking to run block directly...

In the context of the web application root "testwebapp" I created with 
cocoon-22-archetype-webapp I did not manage to get result from the 
testblock in any other way. Given what I read at:

It seems that block protocol is not available from root webapp according to:
http://www.nabble.com/Configuring-BlockServlets-via-properties-and-sitemap-reloading-for-blocks-t2450880.html
Or do I miss something ?


2. Block

Now I finally got block running directly using:
mvn package cocoon:deploy jetty:run

After that the block name "testblock" is available at:
http://localhost:8888/testblock/

Is this the right way to proceed ?

Then in my testblock pom.xml I modified the cocoon-deployer-plugin from 
its initial state provided by the archetype:

   <plugin>
     <groupId>org.apache.cocoon</groupId>
     <artifactId>cocoon-deployer-plugin</artifactId>
     <version>1.0.0-M2-SNAPSHOT</version>
   </plugin>

to:

   <plugin>
     <groupId>org.apache.cocoon</groupId>
     <artifactId>cocoon-deployer-plugin</artifactId>
     <version>1.0.0-M2-SNAPSHOT</version>
     <executions>
       <execution>
         <phase>package</phase>
           <goals>
             <goal>deploy</goal>
           </goals>
       </execution>
     </executions>
   </plugin>

then the block can simply be run as:
mvn package jetty:run

I am not particularly knowledgeable with that kind of Maven 
configurations, its just that its was like this a couple of weeks ago :)

Feedback are welcome as I plan write some "Getting started" 
documentation and would avoid writing wrong tips.

TIA,

Patrick

> 
>> Then after
>> mvn package jetty:run
>>
>> I could get testblock answer from localhost:8888/testblock/
>>
>>
>> Is this the right way to proceed for referencing blocks from a webapp 
>> ? I just discovered blockcontext: syntax lately.
> 
> see above
> 


Re: How to run block built with cocoon-22-archetype-block

Posted by Reinhard Poetz <re...@apache.org>.
Patrick Refondini wrote:
> Reinhard Poetz wrote:
>> Patrick Refondini wrote:
>>
>>> Reinhard Poetz wrote:
>>>
>>>> Patrick Refondini wrote:
>>>>
>>>>> Is there a cocoon-22-archetype-block working with the current trunk ?
>>>>
>>>>
>>>>
>>>> no, yesterday evening I've started to work on it.
>>>>
>>> Great ! I'll be please to give feedback when it is available.
>>
>>
>> please try (IIRC, the only thing you forgot was the blocks-fw-impl 
>> dependency)
> Indeed blocks-fw-impl was missing !
> 
> 
> I have tested referencing the a testblock from a testwebapp as follow:
> 
> Created testblock:
> 
> mvn archetype:create -DarchetypeGroupId=org.apache.cocoon 
> -DarchetypeArtifactId=cocoon-22-archetype-block 
> -DarchetypeVersion=1.0.0-M4-SNAPSHOT -DgroupId=ch.extentis 
> -DartifactId=testblock
> 
> Installed testblock
> 
> Created testwebapp
> 
> mvn archetype:create -DarchetypeGroupId=org.apache.cocoon 
> -DarchetypeArtifactId=cocoon-22-archetype-webapp 
> -DarchetypeVersion=1.0.0-SNAPSHOT -DgroupId=ch.extentis 
> -DartifactId=testwebapp
> 
> Added testblock dependency to testwebapp POM:
> 
> <dependency>
>   <groupId>ch.extentis</groupId>
>   <artifactId>testblock</artifactId>
>   <version>1.0-SNAPSHOT</version>
> </dependency>
> 
> Added the following to testwebapp sitemap:
> 
> <!--  Reference any block by its blockContextURL / mount path ?  -->
> <map:match pattern="*/**">
>   <map:mount uri-prefix="{1}" src="blockcontext:/{1}/"/>
> </map:match>

This shouldn't be necessary to get some result from your testblock as it is 
automaticially mounted.

> Then after
> mvn package jetty:run
> 
> I could get testblock answer from localhost:8888/testblock/
> 
> 
> Is this the right way to proceed for referencing blocks from a webapp ? 
> I just discovered blockcontext: syntax lately.

see above

-- 
Reinhard Pötz           Independent Consultant, Trainer & (IT)-Coach 

{Software Engineering, Open Source, Web Applications, Apache Cocoon}

                                        web(log): http://www.poetz.cc
--------------------------------------------------------------------



	
		
___________________________________________________________ 
Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de

Re: How to run block built with cocoon-22-archetype-block

Posted by Patrick Refondini <pa...@pobox.com>.
Reinhard Poetz wrote:
> Patrick Refondini wrote:
> 
>> Reinhard Poetz wrote:
>>
>>> Patrick Refondini wrote:
>>>
>>>> Is there a cocoon-22-archetype-block working with the current trunk ?
>>>
>>>
>>>
>>> no, yesterday evening I've started to work on it.
>>>
>> Great ! I'll be please to give feedback when it is available.
> 
> 
> please try (IIRC, the only thing you forgot was the blocks-fw-impl 
> dependency)
Indeed blocks-fw-impl was missing !


I have tested referencing the a testblock from a testwebapp as follow:

Created testblock:

mvn archetype:create -DarchetypeGroupId=org.apache.cocoon 
-DarchetypeArtifactId=cocoon-22-archetype-block 
-DarchetypeVersion=1.0.0-M4-SNAPSHOT -DgroupId=ch.extentis 
-DartifactId=testblock

Installed testblock

Created testwebapp

mvn archetype:create -DarchetypeGroupId=org.apache.cocoon 
-DarchetypeArtifactId=cocoon-22-archetype-webapp 
-DarchetypeVersion=1.0.0-SNAPSHOT -DgroupId=ch.extentis 
-DartifactId=testwebapp

Added testblock dependency to testwebapp POM:

<dependency>
   <groupId>ch.extentis</groupId>
   <artifactId>testblock</artifactId>
   <version>1.0-SNAPSHOT</version>
</dependency>

Added the following to testwebapp sitemap:

<!--  Reference any block by its blockContextURL / mount path ?  --> 

<map:match pattern="*/**">
   <map:mount uri-prefix="{1}" src="blockcontext:/{1}/"/>
</map:match>


Then after
mvn package jetty:run

I could get testblock answer from localhost:8888/testblock/


Is this the right way to proceed for referencing blocks from a webapp ? 
I just discovered blockcontext: syntax lately.

TIA,

Patrick




> 
>> What else can a user do to help ? Updating related documentation ? 
>> I'll have a look to the FAQ.
> 
> 
> Documentation is always welcome! It would be great to have a second 
> getting started document ("Getting started in 5 minutes") that explains 
> how to connect to another block and how to use inheritance.
> 


Re: How to run block built with cocoon-22-archetype-block

Posted by Reinhard Poetz <re...@apache.org>.
Patrick Refondini wrote:
> Reinhard Poetz wrote:
>> Patrick Refondini wrote:
>>
>>> Is there a cocoon-22-archetype-block working with the current trunk ?
>>
>>
>> no, yesterday evening I've started to work on it.
>>
> Great ! I'll be please to give feedback when it is available.

please try (IIRC, the only thing you forgot was the blocks-fw-impl dependency)

> What else can a user do to help ? Updating related documentation ? I'll 
> have a look to the FAQ.

Documentation is always welcome! It would be great to have a second getting 
started document ("Getting started in 5 minutes") that explains how to connect 
to another block and how to use inheritance.

-- 
Reinhard Pötz           Independent Consultant, Trainer & (IT)-Coach 

{Software Engineering, Open Source, Web Applications, Apache Cocoon}

                                        web(log): http://www.poetz.cc
--------------------------------------------------------------------

		
___________________________________________________________ 
Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de

Re: How to run block built with cocoon-22-archetype-block

Posted by Patrick Refondini <pa...@pobox.com>.
Reinhard Poetz wrote:
> Patrick Refondini wrote:
> 
>> Is there a cocoon-22-archetype-block working with the current trunk ?
> 
> 
> no, yesterday evening I've started to work on it.
> 
Great ! I'll be please to give feedback when it is available.
What else can a user do to help ? Updating related documentation ? I'll 
have a look to the FAQ.

Patrick


Re: How to run block built with cocoon-22-archetype-block

Posted by Reinhard Poetz <re...@apache.org>.
Patrick Refondini wrote:

> Is there a cocoon-22-archetype-block working with the current trunk ?

no, yesterday evening I've started to work on it.

-- 
Reinhard Pötz           Independent Consultant, Trainer & (IT)-Coach 

{Software Engineering, Open Source, Web Applications, Apache Cocoon}

                                        web(log): http://www.poetz.cc
--------------------------------------------------------------------

		
___________________________________________________________ 
Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de

Re: How to run block built with cocoon-22-archetype-block

Posted by Patrick Refondini <pa...@pobox.com>.
Patrick Refondini wrote:
> 
> Following doc:
> 
> http://cocoon.zones.apache.org/daisy/documentation/g1/1159.html
> 
> 
> I created a fresh block with:
> 
> mvn archetype:create -DarchetypeGroupId=org.apache.cocoon 
> -DarchetypeArtifactId=cocoon-22-archetype-webapp 
> -DarchetypeVersion=1.0.0-M4-SNAPSHOT -DgroupId=my.domain 
> -DartifactId=testwebapp
> 
> 
> Using installed local cocoon trunk at revision 480141 build with:
> 
> -Dmaven.war.shieldingclassloader=false
> 
> java version "1.5.0_06" on MacOSX 10.4.6
> Maven version: 2.0.4
> 
> While trying either mvn package, mvn jetty:run, mvn jetty6:run
> I always get the following error:
> 
> [INFO] Scanning for projects...
> [INFO] 
> ---------------------------------------------------------------------------- 
> 
> [INFO] Building testblock
> [INFO]    task-segment: [package]
> [INFO] 
> ---------------------------------------------------------------------------- 
> 
> [INFO] 
> ------------------------------------------------------------------------
> [ERROR] BUILD ERROR
> [INFO] 
> ------------------------------------------------------------------------
> [INFO] Error building POM (may not be this project's POM).
> 
> 
> Project ID: org.apache.cocoon:cocoon-deployer-plugin
> 
> Reason: Error getting POM for 'org.apache.cocoon:cocoon-deployer-plugin' 
> from the repository: Unable to read local copy of metadata: Cannot read 
> metadata from 
> '/Users/patrick/.m2/repository/org/apache/cocoon/cocoon-deployer-plugin/1.0.0-M2-SNAPSHOT/maven-metadata-central.xml': 
> end tag name </head> must be the same as start tag <link> from line 17 
> (position: TEXT seen .../planetmirror.com/themes/standard/pm.css\' 
> type=\'text/css\'>\n</head>... @18:8)
>   org.apache.cocoon:cocoon-deployer-plugin:pom:1.0.0-M2-SNAPSHOT
> 
> 
> Any hint to work with block created from archetype ?
> 
> Patrick
> 
> 
I have read more docs:

Tutorial: Creating, extending and running a block
http://cocoon.zones.apache.org/daisy/documentation/796.html

BD: Tutorial: Using the block deployer to create a Cocoon web application
http://cocoon.zones.apache.org/daisy/documentation/797.html

But it does not help me running blocks created with 
cocoon-22-archetype-block 1.0.0-M4-SNAPSHOT

I have added:

       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-jar-plugin</artifactId>
         <version>2.1</version>
         <configuration>
           <archive>
             <manifestEntries>
               <Cocoon-Block-Name>${pom.artifactId}</Cocoon-Block-Name>
             </manifestEntries>
           </archive>
         </configuration>
       </plugin>		

Removed / Re-added cocoon-deployer-plugin

Updated maven-jetty-plugin from 6.0.0beta10 to 6.0.0rc4

Added a BlockServlet to my 
META-INF/cocoon/spring/myblock-application-context.xml file:

<bean
   id="com.mydomain.block" class="org.apache.cocoon.blocks.BlockServlet">
   <property name="mountPath" value="/myblock"/>
   <property name="servletClass"
             value="org.apache.cocoon.sitemap.SitemapServlet"/>
   <property name="blockContextURL"
             value="blockcontext:/myblock/"/>
</bean>


and finally obtains a:

java.lang.ClassNotFoundException: org.apache.cocoon.blocks.BlockServlet


Is there a cocoon-22-archetype-block working with the current trunk ?

TIA,

Patrick