[EJB 3.0] - Re: InitialContext reference and definition
by pepelara
Hi,
How do I call a local interface?
This is then Global JNDI Namespace from then JMX Console of
JBoss 4.2.2 GA,
| +- CalculatorEAR (class: org.jnp.interfaces.NamingContext)
| | +- CalculatorBean (class: org.jnp.interfaces.NamingContext)
| | | +- local (proxy: $Proxy62 implements interface jboss.tutorial.Calculator,interface org.jboss.ejb3.JBossProxy)
|
and then client is,
| package jboss.tutorial;
|
| import java.util.Properties;
|
| import javax.ejb.EJB;
| import javax.naming.InitialContext;
| import javax.naming.Context;
|
| public class CalculatorClient {
|
| @EJB
| private static Calculator calculator;
|
| public CalculatorClient() {
| try {
| Properties props = new Properties();
| props.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
| props.put("java.naming.factory.url.pkgs", "jnp://localhost:1099");
| props.put("java.naming.provider.url", "jnp://localhost:1099");
| Context ctx = new InitialContext(props);
| calculator = (Calculator) ctx.lookup("CalculatorBean/local");
| } catch (Exception ex) {
| System.out.println("CouldnâÂÂt create calculator bean. "+
| ex.getMessage());
| }
| }
|
| /**
| * @param args
| */
| public static void main(String[] args) {
| // TODO Auto-generated method stub
| CalculatorClient cClient = new CalculatorClient();
|
| System.out.println("1 + 1 = " + calculator.add(1, 1));
| System.out.println("1 - 1 = " + calculator.subtract(1, 1));
| }
| }
|
The output gives me the Exception,
| CouldnâÂÂt create calculator bean. CalculatorBean not bound
|
Regards,
pepelara
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4204995#4204995
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4204995
17 years, 2 months
[EJB 3.0] - Re: How to inject sessionbean from sessionbean from another
by j-n00b
Jaikiran, I just tried the @Service notation:
| package ae;
|
| import javax.annotation.Resource;
| import javax.ejb.TransactionAttribute;
| import javax.ejb.TransactionAttributeType;
|
| import org.apache.log4j.Logger;
| import org.jboss.ejb3.annotation.Depends;
| import org.jboss.ejb3.annotation.Management;
| import org.jboss.ejb3.annotation.Service;
|
| @Service
| @Management(MasterMBean.class)
| @Depends( { "jboss.j2ee:jar=SubEJB.jar,name=CalculatorBean,service=EJB3" })
| public class Master implements MasterMBean {
|
| private static final Logger log = Logger.getLogger(Master.class);
|
| @EJB(mappedName = Calculator.JNDI_NAME)
| private Calculator additionBean;
|
| @TransactionAttribute(TransactionAttributeType.NEVER)
| public void start() throws Exception {
| log.info("### starting");
|
| if (additionBean == null) {
| log.error("### unable to inject CalculatorBean!!!");
| return;
| }
|
| long result = additionBean.add(new int[] { 1, 2, 3 });
| log.info(result);
|
| // TODO use a quartz job to run a calculation every 5 seconds!
| }
|
| public void stop() {
| log.info("### stopping");
| }
| }
|
After removing the master-mbean-jboss.xml and deploying the SAR into server/all/deploy-hasingleton, the Injection worked pretty fine! But the old approach still does not work. Can you tell me why?
Another thing: as you can see, I had to annotate the start() method, because I got an Exception:
anonymous wrote :
| 14:54:06,031 INFO [ConnectionFactory] org.jboss.jms.server.connectionfactory.ConnectionFactory@1e287e5 started
| 14:54:06,031 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=ConnectionFactoryBinding,name=JmsXA' to JNDI name 'java:JmsXA'
| 14:54:06,093 INFO [TomcatDeployment] deploy, ctxPath=/, vfsUrl=ROOT.war
| 14:54:06,156 INFO [TomcatDeployment] deploy, ctxPath=/jmx-console, vfsUrl=jmx-console.war
| 14:54:06,265 INFO [JBossASKernel] Created KernelDeployment for: SubEJB.jar
| 14:54:06,265 INFO [JBossASKernel] installing bean: jboss.j2ee:jar=SubEJB.jar,name=CalculatorBean,service=EJB3
| 14:54:06,265 INFO [JBossASKernel] with dependencies:
| 14:54:06,265 INFO [JBossASKernel] and demands:
| 14:54:06,265 INFO [JBossASKernel] jboss.ejb:service=EJBTimerService
| 14:54:06,265 INFO [JBossASKernel] and supplies:
| 14:54:06,265 INFO [JBossASKernel] jndi:AECalculator
| 14:54:06,265 INFO [JBossASKernel] jndi:CalculatorBean/remote-ae.Calculator
| 14:54:06,265 INFO [JBossASKernel] Class:ae.Calculator
| 14:54:06,265 INFO [JBossASKernel] Added bean(jboss.j2ee:jar=SubEJB.jar,name=CalculatorBean,service=EJB3) to KernelDeployment of: SubEJB.jar
| 14:54:06,375 INFO [SessionSpecContainer] Starting jboss.j2ee:jar=SubEJB.jar,name=CalculatorBean,service=EJB3
| 14:54:06,390 INFO [EJBContainer] STARTED EJB: ae.CalculatorBean ejbName: CalculatorBean
| 14:54:06,437 INFO [JndiSessionRegistrarBase] Binding the following Entries in Global JNDI:
|
| AECalculator - EJB3.x Default Remote Business Interface
| CalculatorBean/remote-ae.Calculator - EJB3.x Remote Business Interface
|
| 14:54:06,593 INFO [EJBContainer] STARTED EJB: ae.Master ejbName: Master
| 14:54:06,609 INFO [JndiSessionRegistrarBase] Binding the following Entries in Global JNDI:
|
|
| 14:54:06,625 INFO [JBossASKernel] installing bean: jboss.j2ee:jar=master.sar,name=Master,service=EJB3,type=ManagementInterface
| 14:54:06,625 INFO [JBossASKernel] with dependencies:
| 14:54:06,625 INFO [JBossASKernel] and demands:
| 14:54:06,625 INFO [JBossASKernel] jndi:AECalculator
| 14:54:06,625 INFO [JBossASKernel] jboss.ejb:service=EJBTimerService
| 14:54:06,625 INFO [JBossASKernel] jboss.j2ee:jar=SubEJB.jar,name=CalculatorBean,service=EJB3
| 14:54:06,625 INFO [JBossASKernel] and supplies:
| 14:54:06,625 INFO [JBossASKernel] jndi:Master/remote
| 14:54:06,625 INFO [JBossASKernel] Class:ae.MasterMBean
| 14:54:06,625 INFO [JBossASKernel] Installing bean(jboss.j2ee:jar=master.sar,name=Master,service=EJB3,type=ManagementInterface) into kernel
| 14:54:06,640 INFO [Master] ### starting
| 14:54:06,687 ERROR [ServiceContainer] Encountered an error in start of Master
| java.lang.RuntimeException: Problem registering @Management interface for @Service class ae.Master
| at org.jboss.ejb3.service.ServiceContainer.registerManagementInterface(ServiceContainer.java:727)
| [...]
| at java.lang.Thread.run(Thread.java:595)
| Caused by: java.lang.RuntimeException: javax.management.MBeanException
| at org.jboss.ejb3.deployers.JBossASKernel.installMBean(JBossASKernel.java:181)
| at org.jboss.ejb3.service.ServiceContainer.registerManagementInterface(ServiceContainer.java:699)
| ... 50 more
| Caused by: javax.management.MBeanException
| at org.jboss.ejb3.service.ServiceMBeanDelegate.invoke(ServiceMBeanDelegate.java:219)
| at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)
| at org.jboss.ejb3.deployers.JBossASKernel.invokeOptionalMethod(JBossASKernel.java:287)
| at org.jboss.ejb3.deployers.JBossASKernel.installMBean(JBossASKernel.java:177)
| ... 51 more
| Caused by: javax.ejb.EJBException: java.lang.RuntimeException: cannot import a transaction context when a transaction is already associated with the thread
| at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:77)
| at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
| at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:190)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
| at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
| at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
|
Why is that, actually? I don't have any problems when looking up the bean manually
Greetings,
Andre
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4204993#4204993
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4204993
17 years, 2 months
[EJB/JBoss] - jboss 4.4.2 hanges after tx rollback
by born_free
we are using jboss 4.2.2 and we are seeing jboss sever unresponsive after a transaction rollback.
| 2009-01-27 04:23:04,280 ERROR [org.jboss.ejb.plugins.LogInterceptor] (http-10.90.4.177-8080-31) Tran
| sactionRolledbackLocalException in method: public abstract com.comp.Types.ejb.interfaces.Types com.c
| omp.Type.ejb.interfaces.TypesHome.findByType(java.lang.Long,java.lang.Long,java.lang.Long) throws ja
| vax.ejb.FinderException, causedBy:
| java.lang.UnsupportedOperationException
| at org.jboss.ejb.GlobalTxEntityMap$1.invokeEjbStore(GlobalTxEntityMap.java:113)
| at org.jboss.ejb.GlobalTxEntityMap$GlobalTxSynchronization.synchronize(GlobalTxEntityMap.java:300)
| at org.jboss.ejb.GlobalTxEntityMap.synchronizeEntities(GlobalTxEntityMap.java:227)
| at org.jboss.ejb.EntityContainer.synchronizeEntitiesWithinTransaction(EntityContainer.java:136)
| at org.jboss.ejb.EntityContainer.findSingleObject(EntityContainer.java:1096)
| at org.jboss.ejb.EntityContainer.findLocal(EntityContainer.java:676)
| at sun.reflect.GeneratedMethodAccessor111.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.invocation.Invocation.performCall(Invocation.java:359)
| at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:1126)
| at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:105)
| at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationIntercept
| or.java:203)
| at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInte
| rceptor.java:189)
| at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:105)
| at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:136)
| at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:76)
| at org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(EntityCreationInterceptor.java:45)
| at org.jboss.ejb.plugins.CallValidationInterceptor.invokeHome(CallValidationInterceptor.java:56)
| at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:125)
| at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:350)
| at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:161)
| at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:145)
| at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:132)
| at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.jav
| a:107)
| at org.jboss.ejb.EntityContainer.internalInvokeHome(EntityContainer.java:521)
| at org.jboss.ejb.Container.invoke(Container.java:981)
| at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invokeHome(BaseLocalProxyFactory.java:359)
| at org.jboss.ejb.plugins.local.LocalHomeProxy.invoke(LocalHomeProxy.java:133)
|
|
we are using Oracle 11g as our database. Any idea whats is going wrong here. Any pointer/reference is helpfull.
-- born
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4204984#4204984
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4204984
17 years, 2 months
[Clustering/JBoss] - Strange behavior replicated session (Error)
by rengar
My enviroment is 1 apache (load balancer - mod_proxy) and 3 JBoss 5.0.0.GA-jdk6 (in cluster with session replication).
Deploy "Counter.war" application.
1.- 3 servers up. All works fine. session xxxxxxxxxxxxxxxxx.node1 - counter: 1,2,3,4
2.- node1 down. All works fine. session xxxxxxxxxxxxxxxxx.node2 - counter: 5,6
3.- node2 down. All works fine. session xxxxxxxxxxxxxxxxx.node3 - counter: 7,8,9,10
4.- node1 up
5.- node3 down. Don't work correctly!!!!!! session yyyyyyyyyyyyyyyyy.node1 - counter: 1
A random sequence is the same result. Finally it creates a new session id.
I test this enviroment in JBoss 4.2.3.GA-jdk6 and it works fine.
One difference is that session always is xxxxxxxxxxxxxxxxx.node1. Don't change name node.
This isn't correctly behaviour.
Is a bug in JBoss 5.0.0.GA?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4204975#4204975
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4204975
17 years, 2 months
[JBoss Portal] - I cant' graphically wire two events with different names but
by csantos
I cant' graphically wire two events that have different names but their payload is equal (same <value-type> in portlet.xml)
Description:
I have created two portlets: portletA and portletB, each one in its own WAR file (testing purposes)
When I click in a certain link in portletA, I want an event to be sent to portletB.
Both events have the same payload (<value-type>), but their qnames are different:
portlet.xml (portletA):
| ...
| <supported-publishing-event>
| <qname>a:senderName</qname>
| </supported-publishing-event>
| </portlet>
|
| <event-definition>
| <qname>a:senderName</qname>
| <value-type>java.lang.String</value-type>
| </event-definition>
| ...
|
portlet.xml (portletB):
| ...
| <supported-processing-event>
| <qname>a:remitente</qname>
| </supported-processing-event>
| </portlet>
| <event-definition>
| <qname>a:remitente</qname>
| <value-type>java.lang.String</value-type>
| </event-definition>
|
As you can see, portletA publishes the event senderName and portletB processes remitente.
I've carefully read Chapter 8 of the JBoss Portal Reference Manual, and I understand that I should be able to wire the event senderName and
remitente, so when portletA produces the event, portletB receives it.
I create a page in the default portal and add to it portletA and portletB.
Then I go to the Coordination section of the default page, but the Event wirings section contains:
No available events. Cannot create new event wirings.
Am I doing something wrong, or is a bug in the product?
(Some of you might think that if I'm developing both portlets, I can place them in the same .War file. But I am interested in developing a portlet that interacts with portlets not developed by me)
Thank you.
----------------------------------
My environment:
JBoss Portal Version: 2.7.1 (downloaded from the website, bundled with JBoss AS 4.2.3.GA)
S.O: Win XP Professional Service Pack 3
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4204966#4204966
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4204966
17 years, 2 months