Re: Issue while running Tapestry tutorial with JPA instead of Hibernate

2011-08-11 Thread mat --
 Are you sure you added tapestry-jpa dependency?

I knew I was missing something obvious :-)
Thanks Igor, for the reminder!

So now I added tapestry-jpa and the CommitAfter annotation resolves without
Hibernate dependency and the EntityManagerSource service is now visible!

I can now run app with mvn jetty:run, but am getting this when
http://localhost:8080/jpaapp/
org.apache.tapestry5.internal.services.RenderQueueException
Render queue error in SetupRender[Index:grid]: Failure reading parameter
'source' of component Index:grid: Failed to create EntityManagerFactory for
persistence unit 'DemoUnit'

This occurs when using @PersistenceContext (unitName = DemoUnit) and the
with-XML configuration file with persistence-unit name=DemoUnit. So
presumably the two should match... Does this mean that the persistence.xml
file is not found by the application?

When using the without-XML code as per the JPA doc, I am getting a different
error:

Caused by: java.lang.RuntimeException: Exception constructing service
'EntityManagerSource': Error invoking service builder method
org.apache.tapestry5.jpa.JpaModule.buildEntityManagerSource(Logger,
Resource, PersistenceUnitConfigurer, Map, RegistryShutdownHub) (at
JpaModule.java:94) (for service 'EntityManagerSource'):
javax.naming.NameNotFoundException; remaining name 'jdbc/JPATest'

Let me know if you want the full error stack

Thanks

Mat

 On Thu, Aug 11, 2011 at 9:42 AM, Igor Drobiazko
igor.drobia...@gmail.comwrote:

 Are you sure you added tapestry-jpa dependency?

 On Thu, Aug 11, 2011 at 12:39 AM, mat -- mat...@gmail.com wrote:

 Two other questions, regarding the JPA integration doc:
 
  Q: Should one keep the tapestry-hibernate dependency when integrating
 with
  JPA: import org.apache.tapestry5.hibernate.annotations.CommitAfter? if
 not,
  how to resolve the @CommitAfter annotation?
 

 No, tapestry-hibernate is not needed.


  Q: should this service be seen in the Tapestry IoC Services Status?
 

  EntityManagerSource service should be visible as any other service.

 
  Mat
 
  On Wed, Aug 10, 2011 at 10:50 PM, Lenny Primak lpri...@hope.nyc.ny.us
  wrote:
 
   If you are not getting the eclipse link login messages it's not going
 to
   work.
   The file is supposed to be in classpath/META-INF directory. Not
 web-inf.
   Whatever your source package is just add META-INF To that.
  
   Also what's your content of the WEB-INF/lib directory?  The lack or
   incorrect libraries may also hurt you.
  
   On Aug 10, 2011, at 2:03 PM, mat -- mat...@gmail.com wrote:
  
Hi
   
What's your persistence.xml look like? -- Here it it:
(as per the JPA integration instruction)?
   
?xml version=1.0 encoding=UTF-8?
persistence xmlns=http://java.sun.com/xml/ns/persistence;
version=2.0
  persistence-unit name=DemoUnit
 transaction-type=RESOURCE_LOCAL
  properties
 property name=javax.persistence.jdbc.driver
   value=org.h2.Driver /
 property name=javax.persistence.jdbc.url
   value=jdbc:h2:mem:test /
 property name=javax.persistence.jdbc.username
   value=sa /
 property name=eclipselink.ddl-generation
   value=create-tables/
 property name=eclipselink.logging.level
   value=fine/
 /properties
  /persistence-unit
/persistence
   
Where exactly should the persistence.xml file be located?
In the doc it says: and is expected to be located on the classpath
 in
   the *
META-INF* directory. Is that under the WEB-INF directory?
   
Do you get login messages int he logs for EclipseLink? -- No.
   
What are the contents of your WEB-INF/lib? -- There is no lib older
   under
WEB-INF in my sample app?
   
AppModule.java? -- Here is it (much the same as in the Hibernate /
   Tutorial
sample app).
(I didn't add any of the configuration code mentioned in the JPA
instructions as I understood this was needed only in XML-less JPA
configuration
   
package com.example.jpa.services;
   
import java.io.IOException;
   
import org.apache.tapestry5.*;
import org.apache.tapestry5.ioc.Configuration;
import org.apache.tapestry5.ioc.MappedConfiguration;
import org.apache.tapestry5.ioc.OrderedConfiguration;
import org.apache.tapestry5.ioc.ServiceBinder;
import org.apache.tapestry5.ioc.annotations.Contribute;
import org.apache.tapestry5.ioc.annotations.Local;
import org.apache.tapestry5.services.Request;
import org.apache.tapestry5.services.RequestFilter;
import org.apache.tapestry5.services.RequestHandler;
import org.apache.tapestry5.services.Response;
import org.slf4j.Logger;
   
/**
* This module is automatically included as part of the Tapestry IoC
Registry, it's a good place to
* configure and extend Tapestry, or to place your own service
   definitions.
*/
public

Issue while running Tapestry tutorial with JPA instead of Hibernate

2011-08-10 Thread mat --
Hi there,

I have run the Hibernate version of the Tapestry tutorial:
http://tapestry.apache.org/using-tapestry-with-hibernate.html and it works
fine for me.

I am now trying to integrate it with the new 5,3 Tapestry version, running
JPA instead of Hibernate.

I have read instructions at
http://tapestry.apache.org/integrating-with-jpa.html, but I am not sure I
understand how to put the different parts together.

Since I no longer use Hibernate session, I have replaced in Index.java page:

... this code:

   /* @Inject
private Session session;
public ListAddress getAddresses()
{
return session.createCriteria(Address.class).list();
}*/

... with this one:

   @PersistenceContext
private EntityManager em;
public ListAddress getAddresses()
{
Query query = em.createQuery(SELECT a FROM Address a);
return query.getResultList();
}

But I am getting this error in t:grid source=addresses/ of Index.tml:

Render queue error in SetupRender[Index:grid]: Failure reading parameter
 'source' of component Index:grid:
 org.apache.tapestry5.ioc.internal.util.TapestryException


Could someone explain what is the issue in the above code?

Also, could someone briefly list/describe the tasks which are needed to
switch the Tapestry tutorial from Hibernate to JPA support.

Regards

Mat


Re: Issue while running Tapestry tutorial with JPA instead of Hibernate

2011-08-10 Thread mat --
.services.TapestryModule$3.service(TapestryModule.java:1055)
  -
  
org.apache.tapestry5.services.TapestryModule$2.service(TapestryModule.java:1045)
  -
  
org.apache.tapestry5.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:90)
  -
  
org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:105)
  -
  
org.apache.tapestry5.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:95)
  -
  
org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:85)
  -
  
org.apache.tapestry5.internal.services.CheckForUpdatesFilter.service(CheckForUpdatesFilter.java:119)
  -
  
org.apache.tapestry5.services.TapestryModule$HttpServletRequestHandlerTerminator.service(TapestryModule.java:385)
  -
  org.apache.tapestry5.internal.gzip.GZipFilter.service(GZipFilter.java:53)
  -
  
org.apache.tapestry5.internal.services.IgnoredPathsFilter.service(IgnoredPathsFilter.java:62)
  -
  
org.apache.tapestry5.services.TapestryModule$1.service(TapestryModule.java:1005)
  -
  org.apache.tapestry5.TapestryFilter.doFilter(TapestryFilter.java:147)

Tapestry FrameworkTapestry Version5.3.0Application Version1.0-SNAPSHOT

On Wed, Aug 10, 2011 at 6:18 PM, Lenny Primak lpri...@hope.nyc.ny.uswrote:

 Can you give a full exception listing?  Also make sure your entities are in
 he correct entities package.



 On Aug 10, 2011, at 11:02 AM, mat -- mat...@gmail.com wrote:

  Hi there,
 
  I have run the Hibernate version of the Tapestry tutorial:
  http://tapestry.apache.org/using-tapestry-with-hibernate.html and it
 works
  fine for me.
 
  I am now trying to integrate it with the new 5,3 Tapestry version,
 running
  JPA instead of Hibernate.
 
  I have read instructions at
  http://tapestry.apache.org/integrating-with-jpa.html, but I am not sure
 I
  understand how to put the different parts together.
 
  Since I no longer use Hibernate session, I have replaced in Index.java
 page:
 
  ... this code:
 
/* @Inject
 private Session session;
 public ListAddress getAddresses()
 {
 return session.createCriteria(Address.class).list();
 }*/
 
  ... with this one:
 
@PersistenceContext
  private EntityManager em;
  public ListAddress getAddresses()
  {
  Query query = em.createQuery(SELECT a FROM Address a);
  return query.getResultList();
  }
 
  But I am getting this error in t:grid source=addresses/ of Index.tml:
 
  Render queue error in SetupRender[Index:grid]: Failure reading parameter
  'source' of component Index:grid:
  org.apache.tapestry5.ioc.internal.util.TapestryException
 
 
  Could someone explain what is the issue in the above code?
 
  Also, could someone briefly list/describe the tasks which are needed to
  switch the Tapestry tutorial from Hibernate to JPA support.
 
  Regards
 
  Mat

 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org




Re: Issue while running Tapestry tutorial with JPA instead of Hibernate

2011-08-10 Thread mat --
.
 */
public RequestFilter buildTimingFilter(final Logger log)
{
return new RequestFilter()
{
public boolean service(Request request, Response response,
RequestHandler handler)
throws IOException
{
long startTime = System.currentTimeMillis();

try
{
// The responsibility of a filter is to invoke the
corresponding method
// in the handler. When you chain multiple filters
together, each filter
// received a handler that is a bridge to the next
filter.

return handler.service(request, response);
}
finally
{
long elapsed = System.currentTimeMillis() - startTime;

log.info(String.format(Request time: %d ms, elapsed));
}
}
};
}

/**
 * This is a contribution to the RequestHandler service configuration.
This is how we extend
 * Tapestry using the timing filter. A common use for this kind of
filter is transaction
 * management or security. The @Local annotation selects the desired
service by type, but only
 * from the same module.  Without @Local, there would be an error due to
the other service(s)
 * that implement RequestFilter (defined in other modules).
 */
public void contributeRequestHandler(OrderedConfigurationRequestFilter
configuration,
@Local
RequestFilter filter)
{
// Each contribution to an ordered configuration has a name, When
necessary, you may
// set constraints to precisely control the invocation order of the
contributed filter
// within the pipeline.

configuration.add(Timing, filter);
}

}


On Wed, Aug 10, 2011 at 7:34 PM, Lenny Primak lpri...@hope.nyc.ny.uswrote:

 I think your issue is environmental.  What's your persistence.xml look
 like?
 AppModule.java?  Do you get login messages int he logs for EclipseLink?
 What are the contents of your WEB-INF/lib?


 On Aug 10, 2011, at 12:27 PM, Igor Drobiazko wrote:

  Looks like your PersistenceManager is null. You need to share some of
 your
  code with us in order to get help.
 
  On Wed, Aug 10, 2011 at 5:35 PM, mat -- mat...@gmail.com wrote:
 
  Hi
 
  Also make sure your entities are in he correct entities package -- I
 think
  I have same files structure as in the Tapestry tutorial:
 
  - Address.java in entities package
  - Index.java in pages package
  - CreateAddress.java in pages.address package
  - AppModule.java in services package
 
  Can you give a full exception listing --- Here is it:
 
 
   - locationclasspath:com/example/jpa/pages/Index.tml, line 29
   - java.lang.NullPointerExceptionHide uninteresting stack framesStack
   trace
  - com.example.jpa.pages.Index.getAddresses(Index.java:33)
  -
 
 
 org.apache.tapestry5.internal.bindings.PropBinding.get(PropBinding.java:59)
  -
 
 
 org.apache.tapestry5.internal.transform.ParameterWorker$2$1.readFromBinding(ParameterWorker.java:328)
  -
 
 
 org.apache.tapestry5.internal.transform.ParameterWorker$2$1.get(ParameterWorker.java:427)
  -
 
 
 org.apache.tapestry5.internal.transform.BridgeClassTransformation$BridgeTransformField$WrapFieldHandleForFieldValueConduitAsFieldConduit.get(BridgeClassTransformation.java:210)
  -
 
 
 org.apache.tapestry5.corelib.components.Grid.getfieldvalue_source(Grid.java)
  -
 
 
 org.apache.tapestry5.corelib.components.Grid.setupDataSource(Grid.java:459)
  -
 
  org.apache.tapestry5.corelib.components.Grid.setupRender(Grid.java:445)
  -
 
 org.apache.tapestry5.corelib.components.Grid$Shim_2ba81c88b285.invoke(Unknown
  Source)
  -
 
 
 org.apache.tapestry5.internal.plastic.MethodHandleImpl.invoke(MethodHandleImpl.java:48)
  -
 
 
 org.apache.tapestry5.internal.transform.BridgeClassTransformation$WrapMethodHandleAsMethodAccess.invoke(BridgeClassTransformation.java:84)
  -
 
 
 org.apache.tapestry5.internal.transform.RenderPhaseMethodWorker$Invoker.invoke(RenderPhaseMethodWorker.java:117)
  -
 
 
 org.apache.tapestry5.internal.transform.RenderPhaseMethodWorker$RenderPhaseMethodAdvice.advise(RenderPhaseMethodWorker.java:86)
  -
 
 
 org.apache.tapestry5.internal.transform.BridgeClassTransformation$WrapMethodAdviceAsComponentMethodAdvice.advise(BridgeClassTransformation.java:348)
  -
 
 
 org.apache.tapestry5.internal.plastic.AbstractMethodInvocation.proceed(AbstractMethodInvocation.java:86)
  -
 org.apache.tapestry5.corelib.components.Grid.setupRender(Grid.java)
  -
 
 
 org.apache.tapestry5.internal.structure.ComponentPageElementImpl$SetupRenderPhase.invokeComponent(ComponentPageElementImpl.java:230)
  -
 
 
 org.apache.tapestry5.internal.structure.ComponentPageElementImpl$AbstractPhase.invoke(ComponentPageElementImpl.java:191)
  -
 
 
 org.apache.tapestry5

Re: Issue while running Tapestry tutorial with JPA instead of Hibernate

2011-08-10 Thread mat --
Thanks!

I added ejb3-persistence and eclipselink dependencies to my pom.xml file. So
presumably I now have all required dependencies, although I still don't see
any Eclipse Link login messages in console...
Q: Are there other required dependencies which are not already mentioned in
the Hibernate version of the Tapestry Tutorial?

Two other questions, regarding the JPA integration doc:

1) In the doc it is mentinoned that the JPA integration library defines the
@CommitAfter annotation, which acts as the correspondent annotation from the
Hibernate integration library.
Q: Should one keep the tapestry-hibernate dependency when integrating with
JPA: import org.apache.tapestry5.hibernate.annotations.CommitAfter? if not,
how to resolve the @CommitAfter annotation?

2) The *without* XML configuration code refers to a contribution to the *
EntityManagerSource* service, which is responsible for creating the
EntityManagerFactoryhttp://download.oracle.com/javaee/6/api/javax/persistence/EntityManagerFactory.html
to
be used to create
EntityManagerhttp://download.oracle.com/javaee/6/api/javax/persistence/EntityManager.html
.
Q: should this service be seen in the Tapestry IoC Services Status?

Mat

On Wed, Aug 10, 2011 at 10:50 PM, Lenny Primak lpri...@hope.nyc.ny.uswrote:

 If you are not getting the eclipse link login messages it's not going to
 work.
 The file is supposed to be in classpath/META-INF directory. Not web-inf.
 Whatever your source package is just add META-INF To that.

 Also what's your content of the WEB-INF/lib directory?  The lack or
 incorrect libraries may also hurt you.

 On Aug 10, 2011, at 2:03 PM, mat -- mat...@gmail.com wrote:

  Hi
 
  What's your persistence.xml look like? -- Here it it:
  (as per the JPA integration instruction)?
 
  ?xml version=1.0 encoding=UTF-8?
  persistence xmlns=http://java.sun.com/xml/ns/persistence;
  version=2.0
persistence-unit name=DemoUnit transaction-type=RESOURCE_LOCAL
properties
   property name=javax.persistence.jdbc.driver
 value=org.h2.Driver /
   property name=javax.persistence.jdbc.url
 value=jdbc:h2:mem:test /
   property name=javax.persistence.jdbc.username
 value=sa /
   property name=eclipselink.ddl-generation
 value=create-tables/
   property name=eclipselink.logging.level
 value=fine/
   /properties
/persistence-unit
  /persistence
 
  Where exactly should the persistence.xml file be located?
  In the doc it says: and is expected to be located on the classpath in
 the *
  META-INF* directory. Is that under the WEB-INF directory?
 
  Do you get login messages int he logs for EclipseLink? -- No.
 
  What are the contents of your WEB-INF/lib? -- There is no lib older
 under
  WEB-INF in my sample app?
 
  AppModule.java? -- Here is it (much the same as in the Hibernate /
 Tutorial
  sample app).
  (I didn't add any of the configuration code mentioned in the JPA
  instructions as I understood this was needed only in XML-less JPA
  configuration
 
  package com.example.jpa.services;
 
  import java.io.IOException;
 
  import org.apache.tapestry5.*;
  import org.apache.tapestry5.ioc.Configuration;
  import org.apache.tapestry5.ioc.MappedConfiguration;
  import org.apache.tapestry5.ioc.OrderedConfiguration;
  import org.apache.tapestry5.ioc.ServiceBinder;
  import org.apache.tapestry5.ioc.annotations.Contribute;
  import org.apache.tapestry5.ioc.annotations.Local;
  import org.apache.tapestry5.services.Request;
  import org.apache.tapestry5.services.RequestFilter;
  import org.apache.tapestry5.services.RequestHandler;
  import org.apache.tapestry5.services.Response;
  import org.slf4j.Logger;
 
  /**
  * This module is automatically included as part of the Tapestry IoC
  Registry, it's a good place to
  * configure and extend Tapestry, or to place your own service
 definitions.
  */
  public class AppModule
  {
 public static void bind(ServiceBinder binder)
 {
 // binder.bind(MyServiceInterface.class, MyServiceImpl.class);
 
 // Make bind() calls on the binder object to define most IoC
  services.
 // Use service builder methods (example below) when the
  implementation
 // is provided inline, or requires more initialization than simply
 // invoking the constructor.
 }
 public static void contributeApplicationDefaults(
 MappedConfigurationString, String configuration)
 {
 // Contributions to ApplicationDefaults will override any
  contributions to
 // FactoryDefaults (with the same key). Here we're restricting the
  supported
 // locales to just en (English). As you add localised message
  catalogs and other assets,
 // you can extend this list of locales (it's a comma separated
  series of locale names;
 // the first locale name is the default when there's no reasonable

running Tapestry on Google App Engine

2011-07-25 Thread mat --
Hello,

Can recent versions of Tapestry be deployed on Google App Engine?

This page http://code.google.com/p/googleappengine/wiki/WillItPlayInJava
 lists 5.0.18 version as compatible and 5.1 version as incompatible with
GAE.

I was told that Tapestry has a few configuration options that need to
be switched
off for GAE compatibility. Are code example or tutorial of how to achieve
this?

Regards

Mat


Re: running Tapestry on Google App Engine

2011-07-25 Thread mat --
Hi there,
That was a quick answer :-)
For some reasons, I was able to build, but not run
tynamo-example-federatedaccounts
I was more lucky with tynamo-example-conversations --indeed runs well on
GAE.
Thanks a lot, Kalle!
Mat

On Mon, Jul 25, 2011 at 8:45 PM, Kalle Korhonen
kalle.o.korho...@gmail.comwrote:

 5.2.x runs on GAE without issues, a few Tynamo (http://tynamo.org)
 examples are deployed there. Use the maven-gae-plugin to deploy
 (assuming you are using Maven), for example see

 http://svn.codehaus.org/tynamo/trunk/tynamo-example-federatedaccounts/pom.xml
 .

 Kalle


 On Mon, Jul 25, 2011 at 10:37 AM, mat -- mat...@gmail.com wrote:
  Hello,
 
  Can recent versions of Tapestry be deployed on Google App Engine?
 
  This page http://code.google.com/p/googleappengine/wiki/WillItPlayInJava
   lists 5.0.18 version as compatible and 5.1 version as incompatible with
  GAE.
 
  I was told that Tapestry has a few configuration options that need to
  be switched
  off for GAE compatibility. Are code example or tutorial of how to achieve
  this?
 
  Regards
 
  Mat
 

 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org