[EJB3] - Using ejb-jar.xml for @Singleton bean
by Benoit Heinrich
Benoit Heinrich [http://community.jboss.org/people/benoit.heinrich] created the discussion
"Using ejb-jar.xml for @Singleton bean"
To view the discussion, visit: http://community.jboss.org/message/586995#586995
--------------------------------------------------------------
Hi everyone,
I'm new to EJB3.1 and I'm not sure if I'm posting the question to the right forum, so be nice with me to redirect me to the right section if you think it's not ok here.
I'm converting an old jboss @Service (that was running on jboss 4.2.3) to the new @Singleton pattern that I'm deploying to jboss 6.0.0.Final.
My singleton has a lot of dependencies to a lot of beans and to prevent to workaround the issue with dependency resolution for transitive relationships ( https://issues.jboss.org/browse/EJBTHREE-2227 https://issues.jboss.org/browse/EJBTHREE-2227) I've moved my Singleton to a separate ear file and then I've set my ears to deploy the one after the other.
Both ears are using the same jboss-app.xml to share the same classloader and I've got two deployment scenario where one work and the other fails.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss-app PUBLIC
"-//JBoss//DTD Java EE Application 5.0//EN"
" http://www.jboss.org/j2ee/dtd/jboss-app_5_0.dtd http://www.jboss.org/j2ee/dtd/jboss-app_5_0.dtd">
<jboss-app>
<loader-repository>
com.example:loader=01-services
<loader-repository-config>java2ParentDelegation=false</loader-repository-config>
</loader-repository>
</jboss-app>
To reproduce the problem I've created a small example:
*Scenario 1, no ejb-jar.xml*
Here I'm not using ejb-jar.xml and I'm setting the lookup name inside the @EJB annotation
package com.example.services.startup;
import com.example.services.version.VersionManager;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.ejb.Singleton;
import javax.ejb.Startup;
@Singleton
@Startup
public class StartupBean {
private static final Log log = LogFactory.getLog(StartupBean.class);
@EJB(lookup = "01-services/VersionManagerBean/local")
private VersionManager versionManager;
@PostConstruct
public void startup() {
log.info("System started (version " + versionManager.getVersion() + ")");
}
}
When I deploy this to jboss 6 it sucessfully logs the message and so:
This one works
*Scenario 2, jndi mapping done through ejb-jar.xml*
In this scenario I've got the same @Singleton bean but now the @EJB is using a name to reference the ejb from the ejb-jar.xml
<code>
package com.example.services.startup;
import com.example.services.version.VersionManager;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.ejb.Singleton;
import javax.ejb.Startup;
@Singleton
@Startup
public class StartupBean {
private static final Log log = LogFactory.getLog(StartupBean.class);
@EJB(name = "ejb/VersionManager")
private VersionManager versionManager;
@PostConstruct
public void startup() {
log.info("System started (version " + versionManager.getVersion() + ")");
}
}
</code>
And here is the ejb-jar.xml:
This one fails
And here are the logs from JBoss:
21:34:04,762 INFO org.jboss.deployment.dependency.ContainerDependencyMetaData org.jboss.deployment.dependency.ContainerDependencyMetaData addJndiDependency, JndiDependencyMetaData@ae8e56{01-services/VersionManagerBean/local}
21:34:04,762 WARN org.jboss.deployment.MappedReferenceMetaDataResolverDeployer org.jboss.deployment.MappedReferenceMetaDataResolverDeployer Unresolved references exist in JBossMetaData:[startup-1.19.0-SNAPSHOT.jar#StartupBean:AnnotatedEJBReferenceMetaData{name=ejb/VersionManager,ejb-ref-type=null,link=null,ignore-dependecy=false,mapped/jndi-name=null,resolved-jndi-name=null,beanInterface=interface com.example.services.version.VersionManager}]
21:34:04,763 INFO org.jboss.ejb3.deployers.Ejb3DependenciesDeployer org.jboss.ejb3.deployers.Ejb3DependenciesDeployer Encountered deployment AbstractVFSDeploymentContext@10013305
21:34:04,763 INFO org.jboss.ejb3.deployers.Ejb3DependenciesDeployer org.jboss.ejb3.deployers.Ejb3DependenciesDeployer Encountered deployment AbstractVFSDeploymentContext@10013305
21:34:04,767 ERROR org.jboss.kernel.plugins.dependency.AbstractKernelController org.jboss.kernel.plugins.dependency.AbstractKernelController Error installing to Real: name=vfs:///opt/src/jboss-6.0.0.Final/server/default/deploy/99-example-startup.ear state=PreReal mode=Manual requiredState=Real: org.jboss.deployers.spi.DeploymentException: Error during deploy: org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData.StartupBean
at org.jboss.deployers.spi.DeploymentException.rethrowAsDeploymentException(DeploymentException.java:49) :2.2.0.GA
at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:185) :2.2.0.GA
...
Caused by: java.lang.RuntimeException: Could not resolve @EJB reference: EJB Reference: beanInterface 'com.example.services.version.VersionManager', beanName 'null', mappedName 'null', lookupName 'null', owning unit 'ComponentDeploymentContext(a)7745010{org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData.StartupBean}' for environment entry: env/ejb/VersionManager in unit ComponentDeploymentContext(a)7745010{org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData.StartupBean}
at org.jboss.ejb3.jndi.deployers.resource.provider.AnnotatedEJBRefResourceProvider.provide(AnnotatedEJBRefResourceProvider.java:99) http://community.jboss.org/message/586995#586995 Using ejb-jar.xml for @Singleton bean
at org.jboss.ejb3.jndi.deployers.resource.provider.AnnotatedEJBRefResourceProvider.provide(AnnotatedEJBRefResourceProvider.java:50) http://community.jboss.org/message/586995#586995 Using ejb-jar.xml for @Singleton bean
at org.jboss.switchboard.mc.JndiEnvironmentProcessor.process(JndiEnvironmentProcessor.java:68) http://community.jboss.org/message/586995#586995 Using ejb-jar.xml for @Singleton bean
at org.jboss.switchboard.mc.deployer.AbstractSwitchBoardDeployer.process(AbstractSwitchBoardDeployer.java:119) http://community.jboss.org/message/586995#586995 Using ejb-jar.xml for @Singleton bean
at org.jboss.switchboard.mc.deployer.EJBEnvironmentSwitchBoardDeployer.internalDeploy(EJBEnvironmentSwitchBoardDeployer.java:87) http://community.jboss.org/message/586995#586995 Using ejb-jar.xml for @Singleton bean
at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:55) :2.2.0.GA
at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:179) :2.2.0.GA
... 39 more
So I'm probably doing something wrong here, but really I don't see what it is.
Do I need to provide more information in the ejb-jar.xml? Is it ok to reference a @Singleton bean from the ejb-jar.xml?
I'm really lost here, so any help will be greatly appreciated.
Cheers,
/Benoit
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/586995#586995]
Start a new discussion in EJB3 at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
13 years, 4 months
[JBoss Portal] - Run Portlet in parallel
by Ophir Tahor
Ophir Tahor [http://community.jboss.org/people/vatoslokos83] created the discussion
"Run Portlet in parallel"
To view the discussion, visit: http://community.jboss.org/message/586939#586939
--------------------------------------------------------------
Hi,
As I saw in JBoss Portal documents it seems that the portlets can be run on parallel on the server side. I am using JBoss Portal version 2.6.5SP1 and at the login page I have at least 5 different portlets. The portlets haven't any dependencies between them which mean that from my prespective there is no reason that they will loaded in parallel.
At the current situation I see in the log file that they are going to the server one by one and also if we have Ajax call on each one of them I see the Ajax call going to the server sequentially instead of parallel or according to the queue that I can define.
Do you know how I can run them in parallel instead of sequentially?
I also have a gap between each call and according to the hibernate debug log I see that in the gap there are some Portal DB queries that run in order to load entities. I am using EHCache so I don't know why things run again.
Thanks for any response!
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/586939#586939]
Start a new discussion in JBoss Portal at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
13 years, 4 months
[JBoss Portal] - Too much time to download
by Ophir Tahor
Ophir Tahor [http://community.jboss.org/people/vatoslokos83] created the discussion
"Too much time to download"
To view the discussion, visit: http://community.jboss.org/message/586937#586937
--------------------------------------------------------------
Hi,
We are using JBoss Portal version 2.6.5SP1 in our comopany. We didn't change the configuration of JBoss Portal that come with a default option of EHCache for the portal DB. I also checked the configuration of the hibernate and it seems correct which mean that the first\second levels are true and everything there seems fine.
The issue is that we have some gaps in our log files and we found out that the times spent on the Jboss Portal DB. The issue is that in every login we spend at least 300ms for it and also there are some places during the login that we spend the same amount of time on them (another 2-3 times).
When I checked the Hibernate logs I found out those line (this is from the first login, and those are just samples from 2000 lines):
[org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
[org.hibernate.SQL] select displaynam0_.INSTANCE_PK as INSTANCE1_0_, displaynam0_.TEXT as TEXT0_, displaynam0_.LOCALE as LOCALE0_ from JBP_PORTAL_OBJECT_DNAMES displaynam0_ where displaynam0_.INSTANCE_PK=?
[org.hibernate.cache.EhCache]: key: org.jboss.portal.core.impl.model.portal.PortalImpl.windowStates#119 \\this line showen many times with diff keys
[org.hibernate.loader.Loader]: [user:] [context:] result row: EntityKey[org.jboss.portal.core.impl.model.portal.PortalObjectImpl#95] \\this line showen many times with diff rows
and finally I see those 2 lines at the end:
[org.hibernate.engine.StatefulPersistenceContext]: initializing non-lazy collections
[org.hibernate.loader.Loader]: done loading collection
I understand that at those times we are loading things from the DB but: a. Why this is happenned every time instead of using EHCache. b. how I can avoid it or minimize the times that spend.
* I uploaded the full log file in case that you want to see everything
Thanks for any response!
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/586937#586937]
Start a new discussion in JBoss Portal at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
13 years, 4 months