-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: trouble with resource local persistence.xml
PostPosted: Thu Aug 24, 2006 1:12 pm 
Beginner
Beginner

Joined: Wed Apr 26, 2006 2:41 pm
Posts: 30
Hibernate version:
3.2.0.CR2

Name and version of the database you are using: Oracle 9


Im having trouble setting up a persistence unit such that it is ignored by hibernate. I have one persitence unit that is supposed to be used only by a J2SE daemon and a second one that is used by the web application. My packaging seemed to work fine in the default configuration but when I switched to the ejb3 configuration I started to get warnings in the logs about services waiting on the RESOURCE_LOCAL persistence unit.

I am packaging the same ejb3 persitence jar into both my ear and jar so I wanted both defined here. I thought marking the persistence unit as RESOURCE_LOCAL would be enough to make it ignored by hibernate. I've also tried marking it as non-jta but that seemed to not help.

I am deplying in JBoss. My persistence.xml looks something like this:

Code:
<persistence-unit name="J2SE" transaction-type="RESOURCE_LOCAL">
<!-- non-JNDI (Connection specified in Hibernate properties below)-->
<non-jta-data-source>java/J2SE</non-jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9Dialect"/>
<property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver"/>
<property name="hibernate.connection.username" value=""/>
<property name="hibernate.connection.password" value=""/>
<property name="hibernate.connection.url" value="jdbc:oracle:thin:@xxx.xxx.xxx.xxx:1521:tns"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.max_fetch_depth" value="3"/>
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/>
</properties>
</persistence-unit>
</persistence>


The relevant part of the documentation appears to be http://www.hibernate.org/hib_docs/entitymanager/reference/en/html/configuration.html where it shows an example that looks similar to what i have.

The error I get from this is something like:

Code:

12:45:40,843 ERROR [[HtmlAdaptor]] Servlet.service() for servlet HtmlAdaptor threw exception
javax.management.MBeanException
   at org.jboss.mx.interceptor.ReflectedDispatcher.handleInvocationExceptions(ReflectedDispatcher.java:180)
   at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:163)
   at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
   at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
   at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
   at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
   at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
   at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
   at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
   at org.jboss.jmx.adaptor.control.Server.invokeOpByName(Server.java:258)
   at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.invokeOpByName(HtmlAdaptorServlet.java:287)
   at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.processRequest(HtmlAdaptorServlet.java:102)
   at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.doGet(HtmlAdaptorServlet.java:77)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
   at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
   at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
   at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
   at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
   at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
   at java.lang.Thread.run(Unknown Source)
Caused by: Incomplete Deployment listing:

--- MBeans waiting for other MBeans ---
ObjectName: persistence.units:ear=project.ear,unitName=DEV
  State: NOTYETINSTALLED
  I Depend On:
    jboss.jca:name=java/J2SE,service=ManagedConnectionFactory

--- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
ObjectName: jboss.jca:name=java/J2SE,service=ManagedConnectionFactory
  State: NOTYETINSTALLED
  Depends On Me:
    persistence.units:ear=project.ear,unitName=DEV


   at org.jboss.deployment.MainDeployer.checkIncompleteDeployments(MainDeployer.java:1367)
   at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:774)
   at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
   ... 31 more



Shouldn't hibernate ignore this persistence unit? Any ideas? Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 24, 2006 8:22 pm 
Newbie

Joined: Wed Aug 23, 2006 10:11 am
Posts: 9
I'm guessing, but it appears from this part of the debug output:

Code:
--- MBeans waiting for other MBeans ---
ObjectName: persistence.units:ear=project.ear,unitName=DEV
  State: NOTYETINSTALLED
  I Depend On:
    jboss.jca:name=java/J2SE,service=ManagedConnectionFactory

--- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
ObjectName: jboss.jca:name=java/J2SE,service=ManagedConnectionFactory
  State: NOTYETINSTALLED
  Depends On Me:
    persistence.units:ear=project.ear,unitName=DEV


that the other persistence unit, DEV, is complaining because it depends on the java/J2SE data source, which is either not present, or is not a ManagedConnectionFactory. Perhaps you've accidentally switched jndi names?
[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 25, 2006 2:48 pm 
Beginner
Beginner

Joined: Wed Apr 26, 2006 2:41 pm
Posts: 30
Ah, I had changed the name in my persistence.xml and I took the wrong stacktrace. There is only one persistence unit defined.

For troubleshooting here's what I've tried:

Code:
<persistence-unit name="DEV" transaction-type="RESOURCE_LOCAL">
<properties>
     <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9Dialect"/>
     <property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver"/>
         <property name="hibernate.connection.username" value=""/>
         <property name="hibernate.connection.password" value=""/>
         <property name="hibernate.connection.url" value="jdbc:oracle:thin:@xxx.xxx.xxx.xxx:1521:tns"/>
         <property name="hibernate.show_sql" value="true"/>
         <property name="hibernate.max_fetch_depth" value="3"/>
         <property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/>
      </properties>
</persistence-unit>


That's pretty much exactly what's in the hibernate documentation and it works well out of container. However, If i drop this ear into a JBoss server that doesn't have this defined as a datasource I get this:

Code:
13:36:26,281 WARN  [ServiceController] Problem starting service persistence.units:ear=aoma.ear,unitName=DEV
java.lang.RuntimeException: You have not defined a jta-data-source for a JTA enabled persistence context named: DEV
   at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:244)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)

...


I expected JBoss to ignore a RESOURCE_LOCAL datasource. Which led me to try adding that non-jta line in there:

Code:
<persistence-unit name="DEV" transaction-type="RESOURCE_LOCAL">
<non-jta-data-source>DEV</non-jta-data-source>
<properties>
     <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9Dialect"/>
     <property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver"/>
         <property name="hibernate.connection.username" value=""/>
         <property name="hibernate.connection.password" value=""/>
         <property name="hibernate.connection.url" value="jdbc:oracle:thin:@xxx.xxx.xxx.xxx:1521:tns"/>
         <property name="hibernate.show_sql" value="true"/>
         <property name="hibernate.max_fetch_depth" value="3"/>
         <property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/>
      </properties>
</persistence-unit>


But that gives the first exception I posted (where my bean is waiting on the second to deploy). It appears that the non-jta-datasource to tell hibernate that it should bind to whatever datasource is specified in there (which makes sense). What I would like to know is if there's a way to make a persistence unit that gets completely ignored by JBoss/hibernate.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.