Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hibernate.class.getPackage().getImplementationVersion() returning null in PhoneHomeInfo class #286

Open
Guisi opened this issue Nov 23, 2021 · 1 comment
Assignees
Labels

Comments

@Guisi
Copy link

Guisi commented Nov 23, 2021

I am using hazelcast-hibernate53:2.2.1, with HazelcastLocalCacheRegionFactory as the Hibernate cache region factory.

When running my application inside an embedded Tomcat (tomcat-embed-jasper:8.5.63), I'm getting this NullPointerException:

Caused by: java.lang.NullPointerException: null
	at java.base/java.net.URLEncoder.encode(URLEncoder.java:224)
	at java.base/java.net.URLEncoder.encode(URLEncoder.java:196)
	at com.hazelcast.hibernate.PhoneHomeInfo$QueryStringBuilder.tryEncode(PhoneHomeInfo.java:99)
	at com.hazelcast.hibernate.PhoneHomeInfo$QueryStringBuilder.addParam(PhoneHomeInfo.java:93)
	at com.hazelcast.hibernate.PhoneHomeInfo.buildQueryString(PhoneHomeInfo.java:76)
	at com.hazelcast.hibernate.PhoneHomeInfo.<init>(PhoneHomeInfo.java:50)
	at com.hazelcast.hibernate.HazelcastLocalCacheRegionFactory.<clinit>(HazelcastLocalCacheRegionFactory.java:31)

That happens because for some reason the hibernate implementation version in the classloader is null when building the PhoneHomeInfo query string:

private String buildQueryString(boolean isLocalRegion) {
        return new QueryStringBuilder()
                .addParam("version", version)
                .addParam("hibernate-version", Hibernate.class.getPackage().getImplementationVersion())
                .addParam("region-type", isLocalRegion ? "local" : "distributed")
                .build();
    }

Could this be changed to do something like read it from a system property or env variable when the value is null, or even use a default value?

@pivovarit
Copy link
Contributor

pivovarit commented Nov 23, 2021

Yes, it's a trivial classloading bug. We'll take care of that and release a bugfix

@pivovarit pivovarit added the bug label Nov 23, 2021
@pivovarit pivovarit self-assigned this Nov 23, 2021
ldziedziul added a commit to ldziedziul/hazelcast-hibernate that referenced this issue May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants