Hibernate Usage in Jira Plugin Development

Hi, I'm trying to use Hibernate with PostgreSQL database in my Jira plugin,
So I added the following dependencies in pom.xml:

<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.4-1201-jdbc41</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.2.11.Final</version>
<exclusions>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
</exclusions>
</dependency>

I created hibernate.cfg.xml file in /src/main/resources

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>

<!-- Connection settings -->
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.url">jdbc:postgresql://localhost/jira</property>
<property name="hibernate.connection.username">postgres</property>
<property name="hibernate.connection.password">admin</property>

<!-- SQL dialect -->
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>

<property name="show_sql">true</property>
<property name="hibernate.hbm2ddl.auto">create-drop</property>
<property name="hibernate.current_session_context_class">thread</property>
<mapping class="com.comment.plugin.entity.CountPOSTag"/>

</session-factory>
</hibernate-configuration>

After I got error at line which is using SessionFactory:

SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();

Here is the message about javax.xml.stream.XMLEventFactory:

java.lang.ClassCastException: com.ctc.wstx.stax.WstxEventFactory cannot be cast to javax.xml.stream.XMLEventFactory
[INFO] [talledLocalContainer] at javax.xml.stream.XMLEventFactory.newInstance(XMLEventFactory.java:30)
[INFO] [talledLocalContainer] at org.hibernate.boot.jaxb.internal.MappingBinder.<init>(MappingBinder.java:40)
[INFO] [talledLocalContainer] at org.hibernate.boot.spi.XmlMappingBinderAccess.<init>(XmlMappingBinderAccess.java:43)
[INFO] [talledLocalContainer] at org.hibernate.boot.MetadataSources.<init>(MetadataSources.java:87)
[INFO] [talledLocalContainer] at org.hibernate.cfg.Configuration.<init>(Configuration.java:123)
[INFO] [talledLocalContainer] at org.hibernate.cfg.Configuration.<init>(Configuration.java:118)
[INFO] [talledLocalContainer] at com.comment.plugin.CommentIndicator.getContextMap(CommentIndicator.java:110)
[INFO] [talledLocalContainer] at com.atlassian.jira.plugin.webfragment.contextproviders.AbstractJiraContextProvider.getContextMap(AbstractJiraContextProvider.java:28)
[INFO] [talledLocalContainer] at com.atlassian.plugin.web.descriptors.DefaultWebPanelModuleDescriptor$ContextAwareWebPanel.getHtml(DefaultWebPanelModuleDescriptor.java:144)
[INFO] [talledLocalContainer] at com.atlassian.jira.web.component.ModuleWebComponentImpl.renderModule(ModuleWebComponentImpl.java:81)
[INFO] [talledLocalContainer] at com.atlassian.jira.web.component.ModuleWebComponentImpl.access$000(ModuleWebComponentImpl.java:30)
[INFO] [talledLocalContainer] at com.atlassian.jira.web.component.ModuleWebComponentImpl$1.run(ModuleWebComponentImpl.java:67)
[INFO] [talledLocalContainer] at com.atlassian.ozymandias.SafePluginPointAccess.runnable(SafePluginPointAccess.java:201)
[INFO] [talledLocalContainer] at com.atlassian.jira.web.component.ModuleWebComponentImpl.renderModuleAndLetNoThrowablesEscape(ModuleWebComponentImpl.java:63)
[INFO] [talledLocalContainer] at com.atlassian.jira.web.component.ModuleWebComponentImpl.renderModule(ModuleWebComponentImpl.java:53)
[INFO] [talledLocalContainer] ... 2 filtered
[INFO] [talledLocalContainer] at java.lang.reflect.Method.invoke(Method.java:498)
[INFO] [talledLocalContainer] at com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(ContextClassLoaderSettingInvocationHandler.java:26)
[INFO] [talledLocalContainer] at com.sun.proxy.$Proxy354.renderModule(Unknown Source)

Seems cannot find hibernate.cfg.xml file...
Sincerely,

0 answers

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 25, 2018 in Jira

Atlassian Research Workshop opportunity on Sep. 28th in Austin, TX

We're looking for participants for a workshop at Atlassian! We need Jira admins who have interesting custom workflows, issue views, or boards. Think you have a story to sha...

418 views 7 5
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you