Skip to main content

Hibernate working in EJB OSGI bundle?

5 replies [Last post]
cameronr
Offline
Joined: 2006-07-27

Hi all,

According to the OSGI Dashboard (http://wiki.glassfish.java.net/Wiki.jsp?page=OsgiDashboard) JPA is working with eclipselink in OSGI web/ejb applications.

I would like to use Hibernate, primarily for the envers component, and I would like to know the status of Hibernate in OSGI WABs. Any idea if it works?

Cheers
Cameron

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Sanjeeb Sahoo

I have not tried it, so I don't know if it works or not. You may like to
try by bundling hibernate as part of your web or ejb bundle and let me
know how it goes.

Thanks,
Sahoo

On Wednesday 09 June 2010 12:19 PM, glassfish@javadesktop.org wrote:
> Hi all,
>
> According to the OSGI Dashboard (http://wiki.glassfish.java.net/Wiki.jsp?page=OsgiDashboard) JPA is working with eclipselink in OSGI web/ejb applications.
>
> I would like to use Hibernate, primarily for the envers component, and I would like to know the status of Hibernate in OSGI WABs. Any idea if it works?
>
> Cheers
> Cameron
> [Message sent by forum member 'cameronr']
>
> http://forums.java.net/jive/thread.jspa?messageID=473476
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

cameronr
Offline
Joined: 2006-07-27

Thanks Sahoo - I will try and let you know. I was hoping someone may have walked this path already :)

Cheers
Cameron

cameronr
Offline
Joined: 2006-07-27

Hi Sahoo,

I have taken your EJB as OSGI service example (http://weblogs.java.net/blog/ss141213/archive/2010/03/30/ejb-osgi-servic...) and modified the pom.xml and persistence.xml to use Hibernate. Unfortunately it doesn't seem to work.

I am using Glassfish 3.1 b04 with the 15 Jun snapshots of osgi-jpa and osgi-ejb. When deploying your unmodified examples it works fine, I can use the webclient to create users and login. When I use the hibernate sample it deploys, but does not attempt to do anything with the database. If I don't bundle the hibernate dependencies it will complain about not finding the necessary hibernate provider so I think my persistence.xml is setup ok.

Attempting to create a user with Hibernate I get a null pointer when accessing the injected EntityManager in UserAuthServiceEJB.

I will attached the modified pom.xml and persistence.xml for the ejb service project. If you are able to have a quick look into it that would be fantastic.

Many thanks
Cameron

Here is the deployment log from the Hibernate service bundle:
--------------------------------------------------------------
INFO: Bundle having id 299 is a JPA bundle
INFO: Exploded bundle sahoo.hybridapp.example2.service [299] at C:\DOCUME~1\CAMERO~1\LOCALS~1\Temp\osgiapp4222932932078197703
INFO: Source = C:\DOCUME~1\CAMERO~1\LOCALS~1\Temp\osgiapp4222932932078197703, Target = C:\DOCUME~1\CAMERO~1\LOCALS~1\Temp\enhanced-osgiapp9151953982023520446
WARNING: Unable to delete C:\DOCUME~1\CAMERO~1\LOCALS~1\Temp\osgiapp4222932932078197703
INFO: Deleted C:\DOCUME~1\CAMERO~1\LOCALS~1\Temp\enhanced-osgiapp9151953982023520446
INFO: Installed C:\web\glassfish-3.1-b04\glassfish\domains\domain1\autodeploy\bundles\hybridapp2-service.jar
INFO: Expanded at file:/C:/DOCUME~1/CAMERO~1/LOCALS~1/Temp/osgiapp3738875961028657485/
INFO: Portable JNDI names for EJB UserAuthServiceEJB : [java:global/sahoo.hybridapp.example2.service_1.0.0.SNAPSHOT/UserAuthServiceEJB, java:global/sahoo.hybridapp.example2.service_1.0.0.SNAPSHOT/UserAuthServiceEJB!sahoo.hybridapp.example2.UserAuthService]
INFO: addingService: Found 1 no. of EJBs
INFO: Session descriptor
sessionType StatelessDisplay Names:
lang[en] = UserAuthServiceEJB
<== No attribute ==>
homeClassName null
remoteClassName null
remoteBusinessIntfs []
localhomeClassName null
localClassName null
localBusinessIntfs [sahoo.hybridapp.example2.UserAuthService]
isLocalBean false
jndiName
ejbClassName sahoo.hybridapp.example2.service.UserAuthServiceEJB
transactionType Container
methodContainerTransactions {Method Descriptor name: login params: (java.lang.String p1, java.lang.String p2) intf: Local=Container Transaction: Required@, Method Descriptor name: register params: (java.lang.String p1, java.lang.String p2) intf: Local=Container Transaction: Required@, Method Descriptor name: remove params: (java.lang.Object p1) intf: LocalHome=Container Transaction: Required@, Method Descriptor name: remove params: () intf: Local=Container Transaction: Required@, Method Descriptor name: create params: (java.lang.String p1) intf: LocalHome=Container Transaction: Required@}
environmentProperties
ejbReferences
jmsDestReferences
messageDestReferences
resourceReferences
serviceReferences
roleReferences
method-permission->method: unchecked -> [Method Descriptor name: register params: (java.lang.String p1, java.lang.String p2) intf: Local, Method Descriptor name: login params: (java.lang.String p1, java.lang.String p2) intf: Local]
INFO: deployed bundle sahoo.hybridapp.example2.service [299] at file:/C:/DOCUME~1/CAMERO~1/LOCALS~1/Temp/osgiapp3738875961028657485/
INFO: Started bundle: file:/C:/web/glassfish-3.1-b04/glassfish/domains/domain1/autodeploy/bundles/hybridapp2-service.jar

Here is the deployment log from the eclipselink service bundle:
----------------------
INFO: Bundle having id 301 is a JPA bundle
INFO: Exploded bundle sahoo.hybridapp.example2.service [301] at C:\DOCUME~1\CAMERO~1\LOCALS~1\Temp\osgiapp7335066912067051839
INFO: Source = C:\DOCUME~1\CAMERO~1\LOCALS~1\Temp\osgiapp7335066912067051839, Target = C:\DOCUME~1\CAMERO~1\LOCALS~1\Temp\enhanced-osgiapp9141039397930523248
WARNING: Unable to delete C:\DOCUME~1\CAMERO~1\LOCALS~1\Temp\osgiapp7335066912067051839
INFO: Installed C:\web\glassfish-3.1-b04\glassfish\domains\domain1\autodeploy\bundles\hybridapp2-service.jar
INFO: Deleted C:\DOCUME~1\CAMERO~1\LOCALS~1\Temp\enhanced-osgiapp9141039397930523248
INFO: Expanded at file:/C:/DOCUME~1/CAMERO~1/LOCALS~1/Temp/osgiapp9190985392879581429/
INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
INFO: addTransformer called org.glassfish.persistence.jpa.JPADeployer$ProviderContainerContractInfoImpl$1@926e27
INFO: addTransformer called org.glassfish.persistence.jpa.JPADeployer$ProviderContainerContractInfoImpl$1@926e27
INFO: Portable JNDI names for EJB UserAuthServiceEJB : [java:global/sahoo.hybridapp.example2.service_1.0.0.SNAPSHOT/UserAuthServiceEJB, java:global/sahoo.hybridapp.example2.service_1.0.0.SNAPSHOT/UserAuthServiceEJB!sahoo.hybridapp.example2.UserAuthService]
INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
INFO: EclipseLink, version: Eclipse Persistence Services - 2.1.0.v20100529-r7411
INFO: file:/C:/DOCUME~1/CAMERO~1/LOCALS~1/Temp/osgiapp9190985392879581429/_hybridapp login successful
WARNING: Got SQLException executing statement "CREATE TABLE USERNAME (NAME VARCHAR(255) NOT NULL, PASSWORD VARCHAR(255), PRIMARY KEY (NAME))": java.sql.SQLException: Table/View 'USERNAME' already exists in Schema 'APP'.
INFO: addingService: Found 1 no. of EJBs
INFO: Session descriptor
sessionType StatelessDisplay Names:
lang[en] = UserAuthServiceEJB
<== No attribute ==>
homeClassName null
remoteClassName null
remoteBusinessIntfs []
localhomeClassName null
localClassName null
localBusinessIntfs [sahoo.hybridapp.example2.UserAuthService]
isLocalBean false
jndiName
ejbClassName sahoo.hybridapp.example2.service.UserAuthServiceEJB
transactionType Container
methodContainerTransactions {Method Descriptor name: login params: (java.lang.String p1, java.lang.String p2) intf: Local=Container Transaction: Required@, Method Descriptor name: register params: (java.lang.String p1, java.lang.String p2) intf: Local=Container Transaction: Required@, Method Descriptor name: remove params: (java.lang.Object p1) intf: LocalHome=Container Transaction: Required@, Method Descriptor name: remove params: () intf: Local=Container Transaction: Required@, Method Descriptor name: create params: (java.lang.String p1) intf: LocalHome=Container Transaction: Required@}
environmentProperties
ejbReferences
jmsDestReferences
messageDestReferences
resourceReferences
serviceReferences
roleReferences
method-permission->method: unchecked -> [Method Descriptor name: register params: (java.lang.String p1, java.lang.String p2) intf: Local, Method Descriptor name: login params: (java.lang.String p1, java.lang.String p2) intf: Local]
INFO: deployed bundle sahoo.hybridapp.example2.service [301] at file:/C:/DOCUME~1/CAMERO~1/LOCALS~1/Temp/osgiapp9190985392879581429/
INFO: Started bundle: file:/C:/web/glassfish-3.1-b04/glassfish/domains/domain1/autodeploy/bundles/hybridapp2-service.jar

Sanjeeb Sahoo

I think I know why it is not working. The osgi/jpa module is making a
strong assumption about eclipselink. I need to make it extensible to
support other persistence providers. Would you mind filing an RFE? I
will get to it at some pointin GFv3.1 time frame.

Thanks,
Sahoo
On Wednesday 16 June 2010 01:11 PM, glassfish@javadesktop.org wrote:
> Hi Sahoo,
>
> I have taken your EJB as OSGI service example (http://weblogs.java.net/blog/ss141213/archive/2010/03/30/ejb-osgi-servic...) and modified the pom.xml and persistence.xml to use Hibernate. Unfortunately it doesn't seem to work.
>
> I am using Glassfish 3.1 b04 with the 15 Jun snapshots of osgi-jpa and osgi-ejb. When deploying your unmodified examples it works fine, I can use the webclient to create users and login. When I use the hibernate sample it deploys, but does not attempt to do anything with the database. If I don't bundle the hibernate dependencies it will complain about not finding the necessary hibernate provider so I think my persistence.xml is setup ok.
>
> Attempting to create a user with Hibernate I get a null pointer when accessing the injected EntityManager in UserAuthServiceEJB.
>
> I will attached the modified pom.xml and persistence.xml for the ejb service project. If you are able to have a quick look into it that would be fantastic.
>
> Many thanks
> Cameron
>
> Here is the deployment log from the Hibernate service bundle:
> --------------------------------------------------------------
> INFO: Bundle having id 299 is a JPA bundle
> INFO: Exploded bundle sahoo.hybridapp.example2.service [299] at C:\DOCUME~1\CAMERO~1\LOCALS~1\Temp\osgiapp4222932932078197703
> INFO: Source = C:\DOCUME~1\CAMERO~1\LOCALS~1\Temp\osgiapp4222932932078197703, Target = C:\DOCUME~1\CAMERO~1\LOCALS~1\Temp\enhanced-osgiapp9151953982023520446
> WARNING: Unable to delete C:\DOCUME~1\CAMERO~1\LOCALS~1\Temp\osgiapp4222932932078197703
> INFO: Deleted C:\DOCUME~1\CAMERO~1\LOCALS~1\Temp\enhanced-osgiapp9151953982023520446
> INFO: Installed C:\web\glassfish-3.1-b04\glassfish\domains\domain1\autodeploy\bundles\hybridapp2-service.jar
> INFO: Expanded at file:/C:/DOCUME~1/CAMERO~1/LOCALS~1/Temp/osgiapp3738875961028657485/
> INFO: Portable JNDI names for EJB UserAuthServiceEJB : [java:global/sahoo.hybridapp.example2.service_1.0.0.SNAPSHOT/UserAuthServiceEJB, java:global/sahoo.hybridapp.example2.service_1.0.0.SNAPSHOT/UserAuthServiceEJB!sahoo.hybridapp.example2.UserAuthService]
> INFO: addingService: Found 1 no. of EJBs
> INFO: Session descriptor
> sessionType StatelessDisplay Names:
> lang[en] = UserAuthServiceEJB
> <== No attribute ==>
> homeClassName null
> remoteClassName null
> remoteBusinessIntfs []
> localhomeClassName null
> localClassName null
> localBusinessIntfs [sahoo.hybridapp.example2.UserAuthService]
> isLocalBean false
> jndiName
> ejbClassName sahoo.hybridapp.example2.service.UserAuthServiceEJB
> transactionType Container
> methodContainerTransactions {Method Descriptor name: login params: (java.lang.String p1, java.lang.String p2) intf: Local=Container Transaction: Required@, Method Descriptor name: register params: (java.lang.String p1, java.lang.String p2) intf: Local=Container Transaction: Required@, Method Descriptor name: remove params: (java.lang.Object p1) intf: LocalHome=Container Transaction: Required@, Method Descriptor name: remove params: () intf: Local=Container Transaction: Required@, Method Descriptor name: create params: (java.lang.String p1) intf: LocalHome=Container Transaction: Required@}
> environmentProperties
> ejbReferences
> jmsDestReferences
> messageDestReferences
> resourceReferences
> serviceReferences
> roleReferences
> method-permission->method: unchecked -> [Method Descriptor name: register params: (java.lang.String p1, java.lang.String p2) intf: Local, Method Descriptor name: login params: (java.lang.String p1, java.lang.String p2) intf: Local]
> INFO: deployed bundle sahoo.hybridapp.example2.service [299] at file:/C:/DOCUME~1/CAMERO~1/LOCALS~1/Temp/osgiapp3738875961028657485/
> INFO: Started bundle: file:/C:/web/glassfish-3.1-b04/glassfish/domains/domain1/autodeploy/bundles/hybridapp2-service.jar
>
> Here is the deployment log from the eclipselink service bundle:
> ----------------------
> INFO: Bundle having id 301 is a JPA bundle
> INFO: Exploded bundle sahoo.hybridapp.example2.service [301] at C:\DOCUME~1\CAMERO~1\LOCALS~1\Temp\osgiapp7335066912067051839
> INFO: Source = C:\DOCUME~1\CAMERO~1\LOCALS~1\Temp\osgiapp7335066912067051839, Target = C:\DOCUME~1\CAMERO~1\LOCALS~1\Temp\enhanced-osgiapp9141039397930523248
> WARNING: Unable to delete C:\DOCUME~1\CAMERO~1\LOCALS~1\Temp\osgiapp7335066912067051839
> INFO: Installed C:\web\glassfish-3.1-b04\glassfish\domains\domain1\autodeploy\bundles\hybridapp2-service.jar
> INFO: Deleted C:\DOCUME~1\CAMERO~1\LOCALS~1\Temp\enhanced-osgiapp9141039397930523248
> INFO: Expanded at file:/C:/DOCUME~1/CAMERO~1/LOCALS~1/Temp/osgiapp9190985392879581429/
> INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
> INFO: addTransformer called org.glassfish.persistence.jpa.JPADeployer$ProviderContainerContractInfoImpl$1@926e27
> INFO: addTransformer called org.glassfish.persistence.jpa.JPADeployer$ProviderContainerContractInfoImpl$1@926e27
> INFO: Portable JNDI names for EJB UserAuthServiceEJB : [java:global/sahoo.hybridapp.example2.service_1.0.0.SNAPSHOT/UserAuthServiceEJB, java:global/sahoo.hybridapp.example2.service_1.0.0.SNAPSHOT/UserAuthServiceEJB!sahoo.hybridapp.example2.UserAuthService]
> INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
> INFO: EclipseLink, version: Eclipse Persistence Services - 2.1.0.v20100529-r7411
> INFO: file:/C:/DOCUME~1/CAMERO~1/LOCALS~1/Temp/osgiapp9190985392879581429/_hybridapp login successful
> WARNING: Got SQLException executing statement "CREATE TABLE USERNAME (NAME VARCHAR(255) NOT NULL, PASSWORD VARCHAR(255), PRIMARY KEY (NAME))": java.sql.SQLException: Table/View 'USERNAME' already exists in Schema 'APP'.
> INFO: addingService: Found 1 no. of EJBs
> INFO: Session descriptor
> sessionType StatelessDisplay Names:
> lang[en] = UserAuthServiceEJB
> <== No attribute ==>
> homeClassName null
> remoteClassName null
> remoteBusinessIntfs []
> localhomeClassName null
> localClassName null
> localBusinessIntfs [sahoo.hybridapp.example2.UserAuthService]
> isLocalBean false
> jndiName
> ejbClassName sahoo.hybridapp.example2.service.UserAuthServiceEJB
> transactionType Container
> methodContainerTransactions {Method Descriptor name: login params: (java.lang.String p1, java.lang.String p2) intf: Local=Container Transaction: Required@, Method Descriptor name: register params: (java.lang.String p1, java.lang.String p2) intf: Local=Container Transaction: Required@, Method Descriptor name: remove params: (java.lang.Object p1) intf: LocalHome=Container Transaction: Required@, Method Descriptor name: remove params: () intf: Local=Container Transaction: Required@, Method Descriptor name: create params: (java.lang.String p1) intf: LocalHome=Container Transaction: Required@}
> environmentProperties
> ejbReferences
> jmsDestReferences
> messageDestReferences
> resourceReferences
> serviceReferences
> roleReferences
> method-permission->method: unchecked -> [Method Descriptor name: register params: (java.lang.String p1, java.lang.String p2) intf: Local, Method Descriptor name: login params: (java.lang.String p1, java.lang.String p2) intf: Local]
> INFO: deployed bundle sahoo.hybridapp.example2.service [301] at file:/C:/DOCUME~1/CAMERO~1/LOCALS~1/Temp/osgiapp9190985392879581429/
> INFO: Started bundle: file:/C:/web/glassfish-3.1-b04/glassfish/domains/domain1/autodeploy/bundles/hybridapp2-service.jar
> [Message sent by forum member 'cameronr']
>
> http://forums.java.net/jive/thread.jspa?messageID=474446
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

cameronr
Offline
Joined: 2006-07-27

Thanks Sahoo - I have filed an RFE and assigned it to you.

https://glassfish.dev.java.net/issues/show_bug.cgi?id=12275

Regards
Cameron