[Microcontainer] - Conflict between ejb3 deployer and custom GenericAnnotationD
by gregory.mostizky@gmail.com
Using JBoss AS 5.0.1 GA
I am trying to write custom deployer that will scan classes for annotation during POST_CLASSLOADING phase, save the found classes into metadata and then use that to perform some extra steps during REAL phase (similar to WS stuff but for QMF protocol).
I have a test enviroment with sample EJB3 app and a custom deployer. However when I start JBoss I get the following exception:
| 10:59:20,213 ERROR [AbstractKernelController] Error installing to Real: name=vfszip:/home/gmostizk/java/jboss-5.0.1.GA/server/default/deploy/vdcServer-0.0.1-SNAPSHOT.ear/ state=PreReal mode=Manual requiredState=Real
| org.jboss.deployers.spi.DeploymentException: Error deploying vdcServer-0.0.1-SNAPSHOT.ear: Container jboss.j2ee:ear=vdcServer-0.0.1-SNAPSHOT.ear,jar=vdcServer-0.0.1-SNAPSHOT.ear,name=ConfigManagerBean,service=EJB3 failed to resolve persistence unit null
| at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:201)
| at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:103)
| at org.jboss.deployers.vfs.spi.deployer.AbstractVFSRealDeployer.internalDeploy(AbstractVFSRealDeployer.java:45)
| at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)
| at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)
| at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
| at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
| at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
| at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
| at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1598)
| at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
| at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1062)
| at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
| at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
| at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
| at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
| at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:698)
| at org.jboss.system.server.profileservice.ProfileServiceBootstrap.loadProfile(ProfileServiceBootstrap.java:304)
| at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:205)
| at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:405)
| at org.jboss.Main.boot(Main.java:209)
| at org.jboss.Main$1.run(Main.java:547)
| at java.lang.Thread.run(Thread.java:619)
| Caused by: java.lang.IllegalArgumentException: Container jboss.j2ee:ear=vdcServer-0.0.1-SNAPSHOT.ear,jar=vdcServer-0.0.1-SNAPSHOT.ear,name=ConfigManagerBean,service=EJB3 failed to resolve persistence unit null
| at org.jboss.injection.PersistenceUnitHandler.addPUDependency(PersistenceUnitHandler.java:135)
| at org.jboss.injection.PersistenceContextHandler.loadXml(PersistenceContextHandler.java:76)
| at org.jboss.ejb3.EJBContainer.processMetadata(EJBContainer.java:588)
| at org.jboss.ejb3.Ejb3Deployment.processEJBContainerMetadata(Ejb3Deployment.java:415)
| at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:523)
| at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:194)
| ... 22 more
| Caused by: java.lang.IllegalArgumentException: Can't find a persistence unit named 'null' in AbstractVFSDeploymentContext@5463591{vfszip:/home/gmostizk/java/jboss-5.0.1.GA/server/default/deploy/vdcServer-0.0.1-SNAPSHOT.ear/}
| at org.jboss.jpa.resolvers.BasePersistenceUnitDependencyResolver.resolvePersistenceUnitSupplier(BasePersistenceUnitDependencyResolver.java:107)
| at org.jboss.ejb3.Ejb3Deployment.resolvePersistenceUnitSupplier(Ejb3Deployment.java:720)
| at org.jboss.ejb3.EJBContainer.resolvePersistenceUnitSupplier(EJBContainer.java:1428)
| at org.jboss.injection.PersistenceUnitHandler.addPUDependency(PersistenceUnitHandler.java:130)
| ... 27 more
|
The exception thrown during deployment of the sample application.
My custom GenericAnnotationDeployer:
| public class QmfTypeAnnotationDeployer extends GenericAnnotationDeployer {
| @Override
| protected void visitModule(DeploymentUnit deploymentUnit, Module module, GenericAnnotationResourceVisitor genericAnnotationResourceVisitor) {
| super.visitModule(deploymentUnit, module, genericAnnotationResourceVisitor);
|
| AnnotationEnvironment annotationEnvironment = genericAnnotationResourceVisitor.getEnv();
| Set<Element<QMFSeeAlso,Class<?>>> qmfSeeAlsoAnnotations = annotationEnvironment.classIsAnnotatedWith(QMFSeeAlso.class);
|
| QmfRegisteredClassesMetaData metaData = new QmfRegisteredClassesMetaData();
|
| // create metadata for each class we need to register
| for (Element<QMFSeeAlso, Class<?>> qmfSeeAlsoAnnotation : qmfSeeAlsoAnnotations) {
|
| // add the root class
| Class<?> annotatedClass = qmfSeeAlsoAnnotation.getAnnotatedElement();
| metaData.add(annotatedClass);
|
| // add all the children
| Class[] subClasses = qmfSeeAlsoAnnotation.getAnnotation().value();
| for (Class subClass : subClasses) {
| metaData.add(subClass);
| }
| }
|
| // attach metadata to unit
| deploymentUnit.addAttachment(QmfRegisteredClassesMetaData.class, metaData);
| }
| }
|
REAL phase deployer:
| private void registerQmfTypes(DeploymentUnit unit) {
| QmfRegisteredClassesMetaData metadata = unit.getAttachment(QmfRegisteredClassesMetaData.class);
| if(metadata==null) return;
|
| for (Class classToRegister : metadata.getAnnotatedClasses()) {
| log.info("Exposing "+classToRegister.getSimpleName()+" as QMFType");
| qmfAgent.registerClass(classToRegister);
| }
| }
|
jboss-beans.xml
| <bean name="QmfServiceDeployerEJB" class="org.jboss.qmf.core.deployers.QmfServiceDeployerEJB">
| <depends>EJB2xDeployer</depends>
| <depends>Ejb3Deployer</depends>
|
| <property name="qmfAgent">
| <inject bean="QmfAgent" />
| </property>
| </bean>
|
|
| <bean name="QmfTypeAnnotationDeployer" class="org.jboss.qmf.core.deployers.QmfTypeAnnotationDeployer"/>
|
If I comment out the last line from XML everything loads perfectly (without my custom work) so it seems there is some potential conflict between GenericAnnotationDeployer and normal EJB3 deployment process.
I am stuck on this so I would appreciate your help.
Thanks,
Gregory
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4228225#4228225
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4228225
16 years, 11 months
[JBoss Portal] - Problem with PortletSession
by aspdeepak
Jboss App Server V 4.2.2
Jboss Portal - V 2.7.0
DB - Mysql 5.0
I need to perform certain logic when the user logs in.
ie, for each session I need to perform certain logic, that too in start of the session.
This is my code, where i get a PortletSession attribute IS_FIRST_LOAD which is obviously null at the start of every new session. Then i am setting some value, so that the IS_FIRST_LOAD attribute will not be null afterwards.
Portlet A - doView() implementation
String isFirst =(String) request.getPortletSession().getAttribute(IS_FIRST_LOAD);
| log.info(" IS_FIRST_LOAD (before) = "+isFirst);
|
|
| if ( isFirst == null) { // if this is the first time loading
| request.getPortletSession().setAttribute(IS_FIRST_LOAD,"false",PortletSession.PORTLET_SCOPE);
|
| log.info(" showing the default charts(COLLECTION since IS_FIRST_LOAD )");
|
|
| log.info(" IS_FIRST_LOAD (after) = "+request.getPortletSession().getAttribute(IS_FIRST_LOAD));
|
| ..............................................
| ..............................................
|
| }
In my case the PortletA's doView() will be called more than once.
let's say minimum of 3 times. before the page gets completely rendered.
when PortletA's doView() called for the first time the PortletSession attribute returns null so the logic works fine, (note: that the page is still not rendered completely).
when it is called for 2 nd time PortletSession attribute returns null, which is not desirable,
when it is called for 3rd time PortletSession attribute returns non null, and from here on every thing is working fine.
So what is the reason behind the clearing of the PortletSession ?
Any help is greatly appreciable.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4228221#4228221
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4228221
16 years, 11 months