[JBoss Microcontainer Users] - Re: How to get DeploymentUnit?
by Juergen.Zimmermann
I've to implement a class as follows:
| import java.lang.reflect.Type;
| import javax.ejb.EJB;
| import javax.naming.Context;
| import javax.naming.InitialContext;
| import javax.naming.NamingException;
| import javax.ws.rs.ext.Provider;
| import com.sun.jersey.core.spi.component.ComponentContext;
| import com.sun.jersey.spi.inject.Injectable;
| import com.sun.jersey.spi.inject.InjectableProvider;
|
| @Provider
| public class EJBProvider implements InjectableProvider<EJB, Type> {
| public Injectable<Object> getInjectable(ComponentContext componentCtx,
| EJB ejbAnnotation,
| Type type) {
| if (!(type instanceof Class<?>))
| return null;
|
| Class<?> clazz = (Class<?>) type;
|
| String beanInterface = ejbAnnotation.beanInterface().getName();
| if (Object.class.getName().equals(beanInterface)) {
| beanInterface = clazz.getName();
| }
|
| String jndiName = ???; // get jndi name via beanInterface
|
| Context ctx = null;
| try {
| ctx = new InitialContext();
| Object obj = ctx.lookup(jndiName);
|
| return new Injectable<Object>() {
| public Object getValue() {
| return obj;
| }
| };
| }
| catch (NamingException e) { /* error handling */ }
| finally { /* close ctx */ }
| }
| }
So my 1st problem is: how to get the jndi name when the interface of an EJB is available?
I was trying the following where I only would need the DeploymentUnit object. Perhaps there are alternatives. Any hint is highly appreciated!
//import org.jboss.deployers.structure.spi.DeploymentUnit;
| //import org.jboss.ejb3.common.resolvers.plugins.FirstMatchEjbReferenceResolver;
| //import org.jboss.ejb3.common.resolvers.spi.EjbReference;
| //import org.jboss.ejb3.common.resolvers.spi.EjbReferenceResolver;
|
| EjbReference ref = new EjbReference(ejbAnnotation.beanName(),
| beanInterface,
| ejbAnnotation.mappedName());
| EjbReferenceResolver resolver = new FirstMatchEjbReferenceResolver();
|
| DeploymentUnit du = ???; // How to get DeploymentUnit? Via ClassLoader?
|
| String jndiName = resolver.resolveEjb(du, ref);
|
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4266911#4266911
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4266911
16 years, 5 months
[JBoss Cache Users] - Error in accessing pojocache mbean
by torakesh
Hi,
I am new to the jboss cache, I want to use jboss cache in my application using MBean feature. I have created MBean using following configuration:
<?xml version="1.0" encoding="UTF-8"?>
jboss:service=TransactionManager
<!-- Configure the TransactionManager -->
org.jboss.cache.JBossTransactionManagerLookup
<!-- Isolation level : SERIALIZABLE
REPEATABLE_READ (default)
READ_COMMITTED
READ_UNCOMMITTED
NONE
-->
REPEATABLE_READ
<!-- Valid modes are LOCAL, REPL_ASYNC and REPL_SYNC -->
REPL_SYNC
<!-- Just used for async repl: use a replication queue -->
false
<!-- Replication interval for replication queue (in ms) -->
0
<!-- Max number of elements which trigger replication -->
0
<!-- Name of cluster. Needs to be the same for all clusters, in order to find each other -->
TreeCache-Cluster
<!-- JGroups protocol stack properties. Can also be a URL, e.g. file:/home/bela/default.xml
-->
<!-- UDP: if you have a multihomed machine,
set the bind_addr attribute to the appropriate NIC IP address, e.g bind_addr="192.168.0.2"
-->
<!-- UDP: On Windows machines, because of the media sense feature
being broken with multicast (even after disabling media sense)
set the loopback attribute to true
-->
<UDP mcast_addr="228.1.2.3" mcast_port="48866" ip_ttl="64" ip_mcast="true" mcast_send_buf_size="150000" mcast_recv_buf_size="80000" ucast_send_buf_size="150000" ucast_recv_buf_size="80000" loopback="false" />
<PING timeout="2000" num_initial_members="3" up_thread="false" down_thread="false" />
<MERGE2 min_interval="10000" max_interval="20000" />
<FD_SOCK />
<VERIFY_SUSPECT timeout="1500" up_thread="false" down_thread="false" />
<pbcast.NAKACK gc_lag="50" retransmit_timeout="600,1200,2400,4800" max_xmit_size="8192" up_thread="false" down_thread="false" />
<UNICAST timeout="600,1200,2400" window_size="100" min_threshold="10" down_thread="false" />
<pbcast.STABLE desired_avg_gossip="20000" up_thread="false" down_thread="false" />
<FRAG frag_size="8192" down_thread="false" up_thread="false" />
<pbcast.GMS join_timeout="5000" join_retry_timeout="2000" shun="true" print_local_addr="true" />
<pbcast.STATE_TRANSFER up_thread="true" down_thread="true" />
<!-- Whether or not to fetch state on joining a cluster -->
true
<!-- The max amount of time (in milliseconds) we wait until the
initial state (ie. the contents of the cache) are retrieved from
existing members in a clustered environment
-->
5000
<!-- Number of milliseconds to wait until all responses for a synchronous call have been received. -->
15000
<!-- Max number of milliseconds to wait for a lock acquisition -->
10000
<!-- Name of the eviction policy class. -->
--------------
Now I am using it in my application using follwing code:
MBeanServer server = MBeanServerLocator.locate();
s_cacheLoginPageRoom = (PojoCacheMBean) MBeanProxyExt.create(PojoCacheMBean.class, "jboss.cache:service=PojoCache",server);
When I am deploying my application I got follwoing error:
javax.management.InstanceNotFoundException: jboss.cache:service=PojoCache
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:1010)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBeanInfo(DefaultMBeanServerInterceptor.java:1303)
at com.sun.jmx.mbeanserver.JmxMBeanServer.getMBeanInfo(JmxMBeanServer.java:903)
at org.jboss.mx.util.MBeanProxyExt.init(MBeanProxyExt.java:407)
at org.jboss.mx.util.MBeanProxyExt.(MBeanProxyExt.java:99)
at org.jboss.mx.util.MBeanProxyExt.create(MBeanProxyExt.java:394)
at org.jboss.mx.util.MBeanProxyExt.create(MBeanProxyExt.java:349)
at org.jboss.mx.util.MBeanProxyExt.create(MBeanProxyExt.java:324)
at com.portal.cache.PortalPageCache.(LoginCache.java:34)
at com.portal.cache.LoginCache.getS_cacheSingltonInstance(LoginCache.java:61)
at com.portal.cache.LoginCache.getLoginPageData(LoginCache.java:74)
at com.portal.cache.PortalCacheClient.getLoginPageList(PortalCacheClient.java:570)
at com.portal.controller.marketingadmin.ManageSequencePrioritizationController.getSequenceLoginList(ManageSequencePrioritizationController.java:92)
at com.portal.backingbean.login.LoginBean.iniInternetTable(LoginBean.java:397)
at com.portal.backingbean.login.LoginBean.getSequenceInternetShowList(LoginBean.java:580)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
at org.apache.el.parser.AstValue.getValue(AstValue.java:97)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
at javax.faces.component.UIData.getValue(UIData.java:609)
at com.icesoft.faces.component.panelseries.UISeries.getValue(UISeries.java:572)
at com.icesoft.faces.component.panelseries.UISeries.getDataModel(UISeries.java:357)
at com.icesoft.faces.component.panelseries.UISeries.processCurrentRowData(UISeries.java:144)
at com.icesoft.faces.component.panelseries.UISeries.setRowIndex(UISeries.java:136)
at com.icesoft.faces.component.ext.renderkit.TableRenderer.renderFacet(TableRenderer.java:146)
at com.icesoft.faces.renderkit.dom_html_basic.TableRenderer.encodeBegin(TableRenderer.java:122)
at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:813)
at javax.faces.component.UIData.encodeBegin(UIData.java:962)
at com.icesoft.faces.component.panelseries.UISeries.encodeBegin(UISeries.java:298)
at com.icesoft.faces.component.ext.HtmlDataTable.encodeBegin(HtmlDataTable.java:110)
at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:356)
at com.icesoft.faces.renderkit.dom_html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:96)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:492)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:497)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:497)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:497)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:497)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:497)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:497)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:497)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:497)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:497)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:497)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:497)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:497)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:497)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:497)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:497)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:497)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:497)
at com.icesoft.faces.facelets.D2DFaceletViewHandler.renderResponse(D2DFaceletViewHandler.java:282)
at com.icesoft.faces.application.D2DViewHandler.renderView(D2DViewHandler.java:159)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:109)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at com.icesoft.faces.webapp.http.core.JsfLifecycleExecutor.apply(JsfLifecycleExecutor.java:19)
at com.icesoft.faces.context.View$2$1.respond(View.java:48)
at com.icesoft.faces.webapp.http.servlet.ServletRequestResponse.respondWith(ServletRequestResponse.java:201)
at com.icesoft.faces.context.View$2.serve(View.java:77)
at com.icesoft.faces.context.View.servePage(View.java:149)
at com.icesoft.faces.webapp.http.core.MultiViewServer.service(MultiViewServer.java:67)
at com.icesoft.faces.webapp.http.common.ServerProxy.service(ServerProxy.java:11)
at com.icesoft.faces.webapp.http.servlet.MainSessionBoundServlet$4.service(MainSessionBoundServlet.java:149)
at com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer.service(PathDispatcherServer.java:24)
at com.icesoft.faces.webapp.http.servlet.BasicAdaptingServlet.service(BasicAdaptingServlet.java:16)
at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:23)
at com.icesoft.faces.webapp.http.servlet.SessionDispatcher.service(SessionDispatcher.java:53)
at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:23)
at com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:131)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:445)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292)
at org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:694)
at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:665)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:64)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:336)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.portal.common.UserRoleCheckFilter.doFilter(UserRoleCheckFilter.java:100)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.portal.common.HitRateFilter.doFilter(HitRateFilter.java:78)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
at org.jboss.web.tomcat.service.session.ClusteredSessionValve.invoke(ClusteredSessionValve.java:97)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
at java.lang.Thread.run(Thread.java:595)
Is there something that I am missing? I appreciated your help in advance.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4266910#4266910
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4266910
16 years, 5 months
[Persistence] - Re: moving JPA application using Hibernate to JBOSS 5.01
by waltc
After much trial and error and false starts I discovered my problem.
It is important that the web-inf/lib contain NO hibernate jar files or javassist.jar. The original error, which was, the MySQLDialect could not be cast to Dialect was due to the mismatched hibernate jars. So be careful here.
The final persistence.xml is:
| I believe I could live better without the class elements as this version of hibernate will discover them.
| The c3p0 properties, even though commented out, I left in as the non-jta-data-source should have connection and statement pooling in it not here.
| <?xml version="1.0" encoding="UTF-8"?>
| <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
| <persistence-unit name="CU3JPAPU" transaction-type="RESOURCE_LOCAL">
| <provider>org.hibernate.ejb.HibernatePersistence</provider>
| <non-jta-data-source>java:/LuceneResumeDatasource</non-jta-data-source>
| <properties>
| <!--property name="jboss.entity.manager.factory.jndi.name" value="java:/UpdaterEntityManagerFactory"/-->
| <!--property name="hibernate.connection.username" value="root"/>
| <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
| <property name="hibernate.connection.password" value=""/>
| <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/upd"/-->
| <!--property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/-->
| <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
|
| <!--property name="hibernate.c3p0.min_size" value="5"/>
| <property name="hibernate.c3p0.max_size" value="50"/>
| <property name="hibernate.c3p0.max_statements" value="100"/>
| <property name="hibernate.c3p0.idle_test_period" value="3000"/>
| <property name="hibernate.c3p0.max_timeout" value="300"/>
| <property name="hibernate.show_sql" value="false"/>
| <property name="hibernate.format_sql" value="false"/-->
|
| </properties>
| </persistence-unit>
| </persistence>
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4266906#4266906
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4266906
16 years, 5 months
[Persistence] - moving JPA application using Hibernate to JBOSS 5.01
by waltc
Hi,
I apologize for this as I am sure it is a frequent question but I have not found an answer. I have a JPA servlet that was running fine under Tomcat 6 with the persistence.xml under WEB-INF/classes/META-INF.
This file pointed to the db, specified the dialect, etc etc
When I moved the war file over to JBoss 5.0.1 I first discovered I needed to add the non-jta-provider element. Originally I pointed to defaultDS as the examples I did find depicted. I then received an error that indicating I could not have the hibernate jars under the web-inf/lib for the web service webapp (javax.persistence class casting). I removed all the hibernate jars from the local web-inf/lib. I next received an error indicating the dialect (MySQLDialect) could not be cast to Dialect. As it happens I also have a Seam application that uses the same logical database So I thought perhaps it was related to the datasource specification. I next changed that specification <non-jta-data-source> to point to the same ds that the seam app uses. I still have the same error about the dialect. Below is the specified persistence.xml. Would someone be kind enough to either paste a reference to a quick how-to move a j2se based jpa web app to jboss 5.0.1 or explain what it is that is wrong with the below file.
Thanks,
Walt
Here is the error:
DEPLOYMENTS MISSING DEPENDENCIES:
Deployment "persistence.unit:unitName=#CU3JPAPU" is missing the following dependencies:
Dependency "jboss.jca:name=UpdaterDatasource transaction-type="RESOURCE_LOCAL",service=DataSourceBinding" (should be in state "Create", but is actually in state "** NOT FOUND Depends on 'jboss.jca:name=UpdaterDatasource transaction-type="RESOURCE_LOCAL",service=DataSourceBinding' **")
DEPLOYMENTS IN ERROR:
Deployment "jboss.jca:name=UpdaterDatasource transaction-type="RESOURCE_LOCAL",service=DataSourceBinding" is in error due to the following reason(s): ** NOT FOUND Depends on 'jboss.jca:name=UpdaterDatasource transaction-type="RESOURCE_LOCAL",service=DataSourceBinding' **
Here is the persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
| <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/ ... ce_1_0.xsd">
| <persistence-unit name="CU3JPAPU" transaction-type="RESOURCE_LOCAL">
| <provider>org.hibernate.ejb.HibernatePersistence</provider>
| <non-jta-data-source>java:/UpdaterDatasource transaction-type="RESOURCE_LOCAL"</non-jta-data-source>
| <properties>
| <!--property name="jboss.entity.manager.factory.jndi.name" value="java:/UpdaterEntityManagerFactory"/-->
| <property name="hibernate.connection.username" value="me"/>
| <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
| <property name="hibernate.connection.password" value="mypass"/>
| <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/upd"/>
| <!--property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/-->
| <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
|
| <!--property name="hibernate.c3p0.min_size" value="5"/>
| <property name="hibernate.c3p0.max_size" value="50"/>
| <property name="hibernate.c3p0.max_statements" value="100"/>
| <property name="hibernate.c3p0.idle_test_period" value="3000"/>
| <property name="hibernate.c3p0.max_timeout" value="300"/>
| <property name="hibernate.show_sql" value="false"/>
| <property name="hibernate.format_sql" value="false"/-->
|
| </properties>
| </persistence-unit>
| </persistence>
This works fine in tomcat using effectively the same persistence.xml.
The non-jta-data-source element was added as I worked through all sorts of deployment issues ending here. Isn't there a simple way to do this. The application is resource-local as it bootstraps its own EntityManagerFactory from the static under Persistence. I did find a jira indicating it should work and was fixed but it doesn't appear to be to me.
Thanks,
Walt
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4266895#4266895
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4266895
16 years, 5 months
[Persistence] - moving JPA application using Hibernate to JBOSS 5.01
by waltc
Hi,
I apologize for this as I am sure it is a frequent question but I have not found an answer. I have a JPA servlet that was running fine under Tomcat 6 with the persistence.xml under WEB-INF/classes/META-INF.
This file pointed to the db, specified the dialect, etc etc
When I moved the war file over to JBoss 5.0.1 I first discovered I needed to add the non-jta-provider element. Originally I pointed to defaultDS as the examples I did find depicted. I then received an error that indicating I could not have the hibernate jars under the web-inf/lib for the web service webapp (javax.persistence class casting). I removed all the hibernate jars from the local web-inf/lib. I next received an error indicating the dialect (MySQLDialect) could not be cast to Dialect. As it happens I also have a Seam application that uses the same logical database So I thought perhaps it was related to the datasource specification. I next changed that specification <non-jta-data-source> to point to the same ds that the seam app uses. I still have the same error about the dialect. Below is the specified persistence.xml. Would someone be kind enough to either paste a reference to a quick how-to move a j2se based jpa web app to jboss 5.0.1 or explain what it is that is wrong with the below file.
Thanks,
Walt
Here is the error:
DEPLOYMENTS MISSING DEPENDENCIES:
Deployment "persistence.unit:unitName=#CU3JPAPU" is missing the following dependencies:
Dependency "jboss.jca:name=UpdaterDatasource transaction-type="RESOURCE_LOCAL",service=DataSourceBinding" (should be in state "Create", but is actually in state "** NOT FOUND Depends on 'jboss.jca:name=UpdaterDatasource transaction-type="RESOURCE_LOCAL",service=DataSourceBinding' **")
DEPLOYMENTS IN ERROR:
Deployment "jboss.jca:name=UpdaterDatasource transaction-type="RESOURCE_LOCAL",service=DataSourceBinding" is in error due to the following reason(s): ** NOT FOUND Depends on 'jboss.jca:name=UpdaterDatasource transaction-type="RESOURCE_LOCAL",service=DataSourceBinding' **
Here is the persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/ ... ce_1_0.xsd">
<persistence-unit name="CU3JPAPU" transaction-type="RESOURCE_LOCAL">
org.hibernate.ejb.HibernatePersistence
<non-jta-data-source>java:/UpdaterDatasource transaction-type="RESOURCE_LOCAL"</non-jta-data-source>
<!--property name="jboss.entity.manager.factory.jndi.name" value="java:/UpdaterEntityManagerFactory"/-->
<!--property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/-->
<!--property name="hibernate.c3p0.min_size" value="5"/>
<property name="hibernate.format_sql" value="false"/-->
</persistence-unit>
This works fine in tomcat using effectively the same persistence.xml.
The non-jta-data-source element was added as I worked through all sorts of deployment issues ending here. Isn't there a simple way to do this. The application is resource-local as it bootstraps its own EntityManagerFactory from the static under Persistence. I did find a jira indicating it should work and was fixed but it doesn't appear to be to me.
Thanks,
Walt
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4266894#4266894
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4266894
16 years, 5 months
[JBoss Cache Users] - Null element in the Vector
by roman.mandeleil@gmail.com
I am chasing after a strange issue in pojo cache:
There is a Vector that I am using it as a queue
one Thread is pushing things into the tail and
the other poping the head of the Vector.
The Vector is being aspectize with the following
configuration (pojocache-aop.xml):
| <?xml version="1.0" encoding="UTF-8"?>
| <!--
| This is a variant of jboss-aop.xml.
| -->
| <aop>
| <!-- If a POJO has a Replicable annotation, it will be asepectized. -->
|
| <!--
| Supports inheritance and polymorphism. It can either be a concrete class
| or an interface. All sub-classes or interface implementors will be
|
| instrumeneted.
| -->
| <prepare expr="field(* $instanceof
|
| {(a)org.jboss.cache.pojo.annotation.Replicable}->*)" />
|
| <!-- Work around that ensures annotated classes which do not access
|
| fields are instrumented -->
| <introduction expr="class($instanceof
|
| {(a)org.jboss.cache.pojo.annotation.Replicable})"/>
|
| <!-- Array support -->
| <!-- Comment entire section to disable -->
| <arrayreplacement expr="class($instanceof
|
| {(a)org.jboss.cache.pojo.annotation.Replicable})"/>
| <interceptor name="pojocache-array"
|
| class="org.jboss.cache.pojo.interceptors.dynamic.ArrayInterceptor"/>
| <introduction expr="class($instanceof
|
| {(a)org.jboss.cache.pojo.annotation.Replicable})">
| <interfaces>org.jboss.cache.pojo.impl.ArrayInterceptable</interfaces>
| </introduction>
| <arraybind name="pojocache-array" type="READ_WRITE">
| <interceptor-ref name="pojocache-array"/>
| </arraybind>
|
| </aop>
|
I have tried different cache configurations, the last one is like this:
| Configuration config = new Configuration();
| config.setTransactionManagerLookupClass( JBossTransactionManagerLookup.class.getName() );
| config.setIsolationLevel(IsolationLevel.SERIALIZABLE);
| config.setCacheMode(CacheMode.REPL_SYNC);
| config.setLockAcquisitionTimeout(30000);
| config.setClusterName("DefaultPartition");
| config.setConcurrencyLevel(5000);
| config.setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
|
|
The vector is placed inside the pojo cache on JBoss 5.1.0 GA.
And then I see the following problem happens from time to time:
I see null elements apears inside the vector when I have cirtanly
no code that puts it there and by inspecting the logs I see
that it happens when there is concurrent activity on the Vector.
Before I am going to open a bug on it, I would like to know if
there is someone else that has similar expirience and maybe know
about any work around to prevent this behavior.
Regards
Roman
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4266892#4266892
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4266892
16 years, 5 months