You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "Thiago H. de Paula Figueiredo" <th...@gmail.com> on 2021/08/16 12:45:28 UTC
[RELEASE] Apache Tapestry 5.7.3 released
Hello, community!
Tapestry 5.7.3 has just been released. It's a new release focused on some
improvements and new features. Main ones are:
- Upgrading Hibernate's version from 5.1.1.Final to 5.4.32.Final. This
required some changes in tapestry-hibernate due to some
non-backward-compatible changes between these 2 Hibernate versions. If your
project doesn't work with this new Hibernate version, you should be able to
use version 5.7.2 of tapestry-hibernate and tapestry-hibernate with 5.7.3
of everything else without issues.
- Introducing tapestry-spock, an integration of Tapestry with the Spock
testing framework, which used to be part of the Spock project.
Unfortunately, the Tapestry site isn't updating at the moment due to an
internal process being broken.
Your feedback is always welcome!
Cheers!
--
Thiago
Re: [RELEASE] Apache Tapestry 5.7.3 released
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
I forgot to mention you can see the 5.7.3 release notes at
https://cwiki.apache.org/confluence/display/TAPESTRY/Release+Notes+5.7.3
until the main site is updated.
On Mon, Aug 16, 2021 at 9:45 AM Thiago H. de Paula Figueiredo <
thiagohp@gmail.com> wrote:
> Hello, community!
>
> Tapestry 5.7.3 has just been released. It's a new release focused on some
> improvements and new features. Main ones are:
>
>
> - Upgrading Hibernate's version from 5.1.1.Final to 5.4.32.Final. This
> required some changes in tapestry-hibernate due to some
> non-backward-compatible changes between these 2 Hibernate versions. If your
> project doesn't work with this new Hibernate version, you should be able to
> use version 5.7.2 of tapestry-hibernate and tapestry-hibernate with 5.7.3
> of everything else without issues.
> - Introducing tapestry-spock, an integration of Tapestry with the
> Spock testing framework, which used to be part of the Spock project.
>
> Unfortunately, the Tapestry site isn't updating at the moment due to an
> internal process being broken.
>
> Your feedback is always welcome!
>
> Cheers!
>
> --
> Thiago
>
--
Thiago
Re: [RELEASE] Apache Tapestry 5.7.3 released
Posted by Massimo Lusetti <ml...@gmail.com>.
Thanks Thiago! Great job!
On Mon, Aug 16, 2021 at 2:45 PM Thiago H. de Paula Figueiredo <
thiagohp@gmail.com> wrote:
> Hello, community!
>
> Tapestry 5.7.3 has just been released. It's a new release focused on some
> improvements and new features. Main ones are:
>
>
> - Upgrading Hibernate's version from 5.1.1.Final to 5.4.32.Final. This
> required some changes in tapestry-hibernate due to some
> non-backward-compatible changes between these 2 Hibernate versions. If
> your
> project doesn't work with this new Hibernate version, you should be
> able to
> use version 5.7.2 of tapestry-hibernate and tapestry-hibernate with
> 5.7.3
> of everything else without issues.
> - Introducing tapestry-spock, an integration of Tapestry with the Spock
> testing framework, which used to be part of the Spock project.
>
> Unfortunately, the Tapestry site isn't updating at the moment due to an
> internal process being broken.
>
> Your feedback is always welcome!
>
> Cheers!
>
> --
> Thiago
>
--
Massimo Lusetti
hibernate session.createQuery is null when using Tapestry 5.7.3, but
only in some cases
Posted by "Vangel V. Ajanovski" <aj...@gmail.com>.
As I mentioned previously, in a contributed applicationStateManager, I
am not able to do a session.createQuery as it returns null - the Query
object is null.
@Contribute(ApplicationStateManager.class)
public void contributeApplicationStateManager(
MappedConfiguration<Class, ApplicationStateContribution>
configuration, final Session session, final Logger logger) {
ApplicationStateCreator<UserInfo> userInfoCreator = new
ApplicationStateCreator<UserInfo>() {
public UserInfo create() {
Person p = (Person) session
.createQuery("from Person p where
p.userName='student1'")
.uniqueResult();
I have done some more experiments and made it work somehow, but in an
unexpected way.
I found out that:
- session.createQuery() - returns null, whatever the query
- session.get(Person.class, id) - works OK, which means the session and
the connection to the database is OK
After many trials, I managed to find a way to run a query
- either like this:
session.getSession().createQuery()
- or like this:
session.getSessionFactory().openSession()
Somehow I don't think that I am supposed to do that. Any ideas?
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: [RELEASE] Apache Tapestry 5.7.3 released
Posted by "Vangel V. Ajanovski" <aj...@gmail.com>.
On 30.8.21 22:56, Thiago H. de Paula Figueiredo wrote:
> If you want to tell Tapestry how to build and initialize your @SessionState
> objects, you can implement ApplicationStateCreator and contribute an
> ApplicationStateContribution instance with it for a given class to the
> distributed configuration of the ApplicationStateManager services. Your
> ApplicationStateCreator implementation will be called by
> ApplicationStateManagerImpl to get the object instead of using
> ObjectLocator.autobuild(). This is probably the best way of implementing
> the logic you want here.
Hi Thiago (or anyone else that can help).
I tried to follow the suggestion with ApplicationStateContribution.
Either I am doing it the wrong way, or something is wrong with the
Hibernate session at the moment of ASO creation, as I have the same
problem again - session.createQuery returns null.
Here is the Application State Contribution code, it is a really simple
test code:
@Contribute(ApplicationStateManager.class)
public void contributeApplicationStateManager(
MappedConfiguration<Class, ApplicationStateContribution>
configuration, final Session session, final Logger logger) {
ApplicationStateCreator<UserInfo> userInfoCreator = new
ApplicationStateCreator<UserInfo>() {
public UserInfo create() {
Person p = (Person) session
.createQuery("from Person p where
p.userName='student1'")
.uniqueResult();
...
It fails right at this point.
This is the page, it is really a basic page:
public class Index {
@Property @SessionState private UserInfo userInfo;
}
And the .TML:
<html title="message:index-page"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_4.xsd"
xmlns:p="tapestry:parameter">
<p>${userInfo.userName}</p>
</html>
And this is UserInfo, not much here:
package info.ajanovski.muldequa.model;
public class UserInfo {
public static enum UserRole {
NONE, STUDENT, INSTRUCTOR, ADMINISTRATOR
};
private String userName;
private Long personId;
private List<UserRole> userRoles;
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public Long getPersonId() {
return personId;
}
public void setPersonId(Long personId) {
this.personId = personId;
}
public List<UserRole> getUserRoles() {
return userRoles;
}
public void setUserRoles(List<UserRole> userRoles) {
this.userRoles = userRoles;
}
public boolean isNone() {
return userRoles.contains(UserRole.NONE);
}
public boolean isStudent() {
return userRoles.contains(UserRole.STUDENT);
}
public boolean isInstructor() {
return userRoles.contains(UserRole.INSTRUCTOR);
}
public boolean isAdministrator() {
return userRoles.contains(UserRole.ADMINISTRATOR);
}
}
The error log:
2021-09-03 19:27:32,396 [http-nio-8081-exec-3 ] INFO
org.apache.tapestry5.modules.InternalModule.PageLoader Loaded page
'Index' (mk) in 152.200 ms
2021-09-03 19:27:32,464 [http-nio-8081-exec-3 ] INFO
che.tapestry5.modules.TapestryModule.ApplicationStateManager
userInfoCreator.create entered
2021-09-03 19:27:32,475 [http-nio-8081-exec-3 ] ERROR
tapestry.render.info.ajanovski.muldequa.pages.Index Render queue error
in Expansion[PropBinding[expansion Index(userInfo.userName)]]: Cannot
invoke "org.hibernate.query.Query.uniqueResult()" because the return
value of "org.hibernate.Session.createQuery(String)" is null
org.apache.tapestry5.commons.internal.util.TapestryException: Cannot
invoke "org.hibernate.query.Query.uniqueResult()" because the return
value of "org.hibernate.Session.createQuery(String)" is null
at
org.apache.tapestry5.internal.bindings.PropBinding.get(PropBinding.java:67)
~[tapestry-core-5.7.3.jar:?]
...
...
Caused by: java.lang.NullPointerException: Cannot invoke
"org.hibernate.query.Query.uniqueResult()" because the return value of
"org.hibernate.Session.createQuery(String)" is null
at
info.ajanovski.muldequa.services.AppModule$3.create(AppModule.java:150)
~[classes/:?]
...
Exactly the location noted above.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: [RELEASE] Apache Tapestry 5.7.3 released
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Hello! I'm sorry for the very late answer.
On Mon, Aug 16, 2021 at 11:29 AM Vangel V. Ajanovski <aj...@gmail.com>
wrote:
> I'm experiencing some issue where session.createQuery always returns a
> null in the constructor of a SessionState object, after moving to 5.7.3.
> Otherwise everything works and is a welcome upgrade.
> Are there any differences in how and when Tapestry creates the hibernate
> session and how this behaves after this upgrade?
>
No. The only difference is how tapestry-hibernate gets the list of entity
classes from Hibernate. No changes were done to Tapestry-IoC of
tapestry-core that could have affected dependency injection. Maybe some
change in Hibernate itself? You should be able to use tapestry-hibernate
and tapestry-hibernate-core 5.7.2 with Tapestry 5.7.3 without issues.
To be honest, I've never had anything injected into a @SessionState object
and that's something I'd avoid doing anyway. I consider @SessionState
object to be a data storage and prefer to keep any kind of logic, specially
querying, in services.
If you want to tell Tapestry how to build and initialize your @SessionState
objects, you can implement ApplicationStateCreator and contribute an
ApplicationStateContribution instance with it for a given class to the
distributed configuration of the ApplicationStateManager services. Your
ApplicationStateCreator implementation will be called by
ApplicationStateManagerImpl to get the object instead of using
ObjectLocator.autobuild(). This is probably the best way of implementing
the logic you want here.
Please let me know if you have further questions.
>
>
> More details:
>
> I have a @SessionState UserInfo in each page where the authenticated
> user details are needed.
>
> The UserInfo class constructor calls a PersonManager service to find the
> logged-in user details.
>
> Authentication is external so it is not part of the problem. Apereo CAS,
> over all paths of the server, so that request.remoteUser contains the
> loggedin user name.
>
> In this personManager i have @Inject Session session and i have
> session.createQuery.
>
> Now the strange change in behaviour is that after upgrade to 5.7.3, all
> calls to session.CreateQuery always return null when personManager is
> called in the UserInfo constructor. Whatever query I use, it returns a
> null. As if the session is not working. But the session is not null, the
> session object status is OK and session object connection status is ok.
>
> If I call the personManager directly from a page (setupRender or
> property getter) everything works fine.
>
> Probably something is not written as it supposed to be and I need to
> refactor. Maybe we are not supposed to fill-in the UserInfo session
> state object details during its construction, but later. But this piece
> of code is more than 10 years old and has survived over all the Tapestry
> 5.x.x upgrades in the meanwhile and worked fine until now.
>
> UserInfo example:
>
> https://github.com/ajanovski/eprms/blob/main/eprms-tap/src/main/java/info/ajanovski/eprms/tap/util/UserInfo.java
>
> PersonImpl example (nothing special here):
>
> public class PersonDaoImpl implements PersonDao {
> @Inject private Logger logger;
> @Inject private Session session;
>
> @Override
> public List<Person> getAllPersons() {
> try {
> return session.createQuery("from Person order by
> lastName").list();
> } catch (Exception e) {
> return null;
> }
> }
>
> @Override
> public Person getPersonByUsername(String username) {
> try {
> return (Person) (session
> .createQuery("from Person where userName=:param")
> .setParameter("param", username).setReadOnly(true)
> .setCacheable(true).uniqueResult());
> } catch (Exception e) {
> return null;
> }
> }
>
> In case it matters, there is a ComponentRequestFilter to protect access
> to pages depending on the user role, implemented like this:
>
> https://github.com/ajanovski/eprms/blob/main/eprms-tap/src/main/java/info/ajanovski/eprms/tap/services/AccessController.java
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
--
Thiago
Re: [RELEASE] Apache Tapestry 5.7.3 released
Posted by "Vangel V. Ajanovski" <aj...@gmail.com>.
On 16.8.21 14:45, Thiago H. de Paula Figueiredo wrote:
> - Upgrading Hibernate's version from 5.1.1.Final to 5.4.32.Final. This
> required some changes in tapestry-hibernate due to some
> non-backward-compatible changes between these 2 Hibernate versions.
I'm experiencing some issue where session.createQuery always returns a
null in the constructor of a SessionState object, after moving to 5.7.3.
Otherwise everything works and is a welcome upgrade.
Are there any differences in how and when Tapestry creates the hibernate
session and how this behaves after this upgrade?
More details:
I have a @SessionState UserInfo in each page where the authenticated
user details are needed.
The UserInfo class constructor calls a PersonManager service to find the
logged-in user details.
Authentication is external so it is not part of the problem. Apereo CAS,
over all paths of the server, so that request.remoteUser contains the
loggedin user name.
In this personManager i have @Inject Session session and i have
session.createQuery.
Now the strange change in behaviour is that after upgrade to 5.7.3, all
calls to session.CreateQuery always return null when personManager is
called in the UserInfo constructor. Whatever query I use, it returns a
null. As if the session is not working. But the session is not null, the
session object status is OK and session object connection status is ok.
If I call the personManager directly from a page (setupRender or
property getter) everything works fine.
Probably something is not written as it supposed to be and I need to
refactor. Maybe we are not supposed to fill-in the UserInfo session
state object details during its construction, but later. But this piece
of code is more than 10 years old and has survived over all the Tapestry
5.x.x upgrades in the meanwhile and worked fine until now.
UserInfo example:
https://github.com/ajanovski/eprms/blob/main/eprms-tap/src/main/java/info/ajanovski/eprms/tap/util/UserInfo.java
PersonImpl example (nothing special here):
public class PersonDaoImpl implements PersonDao {
@Inject private Logger logger;
@Inject private Session session;
@Override
public List<Person> getAllPersons() {
try {
return session.createQuery("from Person order by
lastName").list();
} catch (Exception e) {
return null;
}
}
@Override
public Person getPersonByUsername(String username) {
try {
return (Person) (session
.createQuery("from Person where userName=:param")
.setParameter("param", username).setReadOnly(true)
.setCacheable(true).uniqueResult());
} catch (Exception e) {
return null;
}
}
In case it matters, there is a ComponentRequestFilter to protect access
to pages depending on the user role, implemented like this:
https://github.com/ajanovski/eprms/blob/main/eprms-tap/src/main/java/info/ajanovski/eprms/tap/services/AccessController.java
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org