java ee - Deploy ejb-jar to be used by multiple wars (Glassfish) -
we have project creates jar file containing jpa entity , service classes access database. have number of different applications need make use of jar file. deploy jpa jar file ejb-jar , have other apps make use of via client jar file included in war.
along entity classes, our jpa project has generic service interface defined follows:
public interface genericservice { <t> t create(t t) throws exception; <t> t find(class<t> t, object id) throws exception; <t> t update(t t); list<?> findwithnamedquery(string queryname) throws exception; list<?> findwithnamedquery(string queryname, int resultlimit) throws exception; list<?> findwithnamedquery(string namedqueryname, map<string, object> parameters) throws exception; list<?> findwithnamedquery(string namedqueryname, map<string, object> parameters, int resultlimit) throws exception; <t> list<t> findwithnativequerylistresult(string sql, class<t> type) throws illegalargumentexception; <t> list<t> findwithnativequerylistresult(string sql) throws illegalargumentexception; <t> t findwithnativequerysingleresult(string sql, class<t> type) throws illegalargumentexception; <t> t findwithnativequerysingleresult(string sql) throws illegalargumentexception; }
which implemented in stateless session bean:
@stateless @ejb(name = "java:global/dataservice", beanname = "dataservice", beaninterface = dataservice.class) @local public class dataservice implements genericservice { @persistencecontext(unitname = "database") private entitymanager em; protected entitymanager getentitymanager() { return this.em; } @override public <t> t create(t t) throws illegalargumentexception, entityexistsexception, persistenceexception { em.persist(t); return t; } .... etc .... }
we use maven our builds , set generate client jar:
<plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-ejb-plugin</artifactid> <version>2.3</version> <configuration> <!-- false default --> <generateclient>true</generateclient> <ejbversion>3.1</ejbversion> </configuration> </plugin>
and have set empty ejb-jar.xml file:
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" version="3.1" metadata-complete="false"> <enterprise-beans> </enterprise-beans> </ejb-jar>
the client file generated used dependency in our war projects:
<dependency> <groupid>my.package</groupid> <artifactid>data-model</artifactid> <version>1.0</version> <classifier>client</classifier> </dependency>
when deploy both ejb-jar , war files, looks okay. when try access service/entity classes war application, get:
[#|2014-06-02t11:14:34.323-0600|warning|glassfish3.1.2|javax.enterprise.system.container.ejb.com.sun.ejb.containers|_threadid=276;_threadname=thread-6;|javax.ejb.ejbtransactionrolledbackexception @ com.sun.ejb.containers.basecontainer.maplocal3xexception(basecontainer.java:2314) @ com.sun.ejb.containers.basecontainer.postinvoke(basecontainer.java:2096) @ com.sun.ejb.containers.basecontainer.postinvoke(basecontainer.java:1994) @ com.sun.ejb.containers.ejblocalobjectinvocationhandler.invoke(ejblocalobjectinvocationhandler.java:222) @ com.sun.ejb.containers.ejblocalobjectinvocationhandlerdelegate.invoke(ejblocalobjectinvocationhandlerdelegate.java:89) @ com.sun.proxy.$proxy133.createbatch(unknown source) @ my.package.app1.__ejb31_generated__batchprocessor__intf____bean__.createbatch(unknown source) @ my.package.app1.batchrestservice.createbatch(batchrestservice.java:58) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) ... snip ... caused by: javax.ejb.transactionrolledbacklocalexception: exception thrown bean: java.lang.nosuchmethoderror: my.package.datamodel.entity.batch.__jr_selector__(i[ljava/lang/object;)ljava/lang/object; @ com.sun.ejb.containers.basecontainer.checkexceptionclienttx(basecontainer.java:5074) @ com.sun.ejb.containers.basecontainer.postinvoketx(basecontainer.java:4906) @ com.sun.ejb.containers.statefulsessioncontainer.postinvoketx(statefulsessioncontainer.java:1648) @ com.sun.ejb.containers.basecontainer.postinvoke(basecontainer.java:2045) ... 78 more caused by: java.lang.nosuchmethoderror: my.package.datamodel.entity.batch.__jr_selector__(i[ljava/lang/object;)ljava/lang/object; @ my.package.app1.batchprocessor.createbatch(batchprocessor.java:394) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:606) @ org.glassfish.ejb.security.application.ejbsecuritymanager.runmethod(ejbsecuritymanager.java:1052) @ org.glassfish.ejb.security.application.ejbsecuritymanager.invoke(ejbsecuritymanager.java:1124) @ com.sun.ejb.containers.basecontainer.invoketargetbeanmethod(basecontainer.java:4180) @ com.sun.ejb.containers.basecontainer.__intercept(basecontainer.java:5368) @ com.sun.ejb.containers.basecontainer.intercept(basecontainer.java:5348) @ com.sun.ejb.containers.ejblocalobjectinvocationhandler.invoke(ejblocalobjectinvocationhandler.java:214) ... 76 more
obviously, there's no method defined on our batch entity class __jr_selector__
, coming from? how debug this?
any advice on how we're setting ejb-jar and/or war use appreciated well.
we deploying glassfish 3.1.2.2 server.
Comments
Post a Comment