[Beginner's Corner] - Number of stateless beans
by piotrekde
piotrekde [http://community.jboss.org/people/piotrekde] created the discussion
"Number of stateless beans"
To view the discussion, visit: http://community.jboss.org/message/582492#582492
--------------------------------------------------------------
Hello,
I have a couple of questions related to the number of stateless beans created by JBoss. First please take a look at the following code:
@Remote
public interface ComputerRemote {
void startComputations();
}
@Stateful
public class ComputerBean implements ComputerRemote {
@EJB
private ProcessorLocal processor;
public void startComputations() {
Random r = new Random();
while(true) {
processor.compute(r.nextInt());
}
}
}
@Local
public interface ProcessorLocal {
void compute(int i);
}
@Stateless
public class ProcessorBean implements ProcessorLocal {
private static int COUNTER = 0;
public ProcessorBean() {
COUNTER ++;
}
public void compute(int i) {
System.out.println("----------------> " + COUNTER);
// some dummy computations - it's here only in order to take some time
double d = 0.3;
for (int j=0; j<100; j++) {
d+= 0.2 % 4 + i;
}
}
}
So, we got stateful ComputerBean (along with its remote interface) which holds a reference to (local) stateless ProcessorBean.
ComputerBean draws some random number and passes it into processor which do some dummy computations (just to take some time).
There is also a COUNTER integer which is expected to count the number of stateless ProcessorBeans.
If I execute it as below:
Object obj = jndiContext.lookup("app/ComputerBean/remote");
ComputerRemote computer = (ComputerRemote) obj;
computer.startComputations();
Computations are started, but on JBoss console there is still printed COUNTER=1.
So my questions are:
1. Why COUNTER is equal 1 all the time? Shouldn't it be more stateless beans? (I know that server manages them, but I thought that if stateless bean do some work for a some amount of time, and another call comes in, then server would create another instance of thise bean and processing both of them would take place simultaneously).
2. Is COUNTER=1 all the time because ComputerBean waits for ProcessorBean to end its current computations, and then call another one passing the next random number? I mean - it is blocking operation, running in one thread? Is there any way to run this computations in multiple threads and do not wait for the end of the first one in order to call second?
3. (this question is probably related to 2nd question) Is there any way to run ComputerBean in a "daemon" mode? I mean, if I execute computer.starComputations() by JNDI from the remote client it stops and waits for the return from startComputations method. It would never happen, because it runs in while(true) loop. But I'd like to call this method and process next client's instructions. E.g. ProcessorBean was a kind of CRON service / FTP server (running in background all the time, waiting for incoming requests, not blocking the rest of execution).
Thanks in advance for all hints!
Piotr
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/582492#582492]
Start a new discussion in Beginner's Corner at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
15 years, 2 months
[Javassist] - VerifyError, Bad type in putfield/putstatic
by Sergio Celentano
Sergio Celentano [http://community.jboss.org/people/sergio.celentano] created the discussion
"VerifyError, Bad type in putfield/putstatic"
To view the discussion, visit: http://community.jboss.org/message/582609#582609
--------------------------------------------------------------
Hi guys,
I am running into some problems while trying to use javassist facilities to implement a java fault injection tool.
As an application (lets call it "worklaod") invokes a method from a third-party library, my tool should intercept this method, modify the parameters value on-the-fly and call the original method.
Running through the tutorials provided with javassist library I found that the "sample/reflect/*.java" should suit my case and I took it into account as a starting point to implement my tool.
So, following that tutorial, my "Injection" class extends the "javassist.tools.reflect.Metaobject" class and implement the "trapMethodCall()" method, in which I realize the arguments substitution.
Another class (my.wrapper.Controller) implements the following snippet, in which "my.app.SubImpl" is the workload and "classNam" is the class whose methods I want to intercept:
* Loader cl = (Loader)my.app.SubImpl.class.getClassLoader();*
* String className = "org.opensplice.dds.dcps.FooTypeSupportImpl";*
* String metaObject = "my.wrapper.Injector";*
* try {*
* cl.makeReflective(className,*
* metaObject,*
* "javassist.tools.reflect.Metaobject");*
* cl.run("my.app.SubImpl", args);*
*...*
*
*
The problem rises when I run my program with this statement "java javassist.tools.reflect.Loader my.wrapper.Controller", I get this error:
*java.lang.VerifyError: (class: org/opensplice/dds/dcps/FooTypeSupportImpl, method: <clinit> signature: ()V) Bad type in putfield/putstatic*
Furthermore I must say that the class "org.opensplice.dds.dcps.FooTypeSupportImpl" is an abstract class and methods I want to intercept are public and static and I am almost sure that this is the main cause of the issue. I wonder if there's any work-around for it.
I hope my explanation was enough clear, any advice is appreciated =)
Thank in advance,
Sergio
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/582609#582609]
Start a new discussion in Javassist at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
15 years, 2 months
What is UDP Port 7500 and where to configure it
by Oliver Welter
Hi Folks,
sorry if this is a noob question but I am new to JBoss and digging the
net for hours now and dont get the clue.
I have an already running JBoss 4.2.3 GA running on Linux and now want
to run more than one JBoss on this single box. As I have only one IP, I
want to use individual port ranges for each instance. I successfully
switched on the ServiceBindingManager and configured the
Cluster-Service-Ports so they are different for both environments.
If I call netstat, I can see both JBoss binding to UDP Port 7500. I was
not successfull to find anything in the configs that explicitley uses
this port. Google tolds me that this is the Diagnostic Port of JGroups -
but all methods found to disable or move this port failed.
However the servers seem to do their work but I am uncertain if there is
any unwanted interaction between them.
Any help is appreciated
Oliver
--
Protect your environment - close windows and adopt a penguin!
PGP-Key: 3B2C 8095 A7DF 8BB5 2CFF 8168 CAB7 B0DD 3985 1721
15 years, 2 months
[JBoss Web Services] - Using mail attribute to authenticate with LdapLoginModule
by Erick Jeronimo Diaz
Erick Jeronimo Diaz [http://community.jboss.org/people/erickjd] created the discussion
"Using mail attribute to authenticate with LdapLoginModule"
To view the discussion, visit: http://community.jboss.org/message/582799#582799
--------------------------------------------------------------
Hello i'm worried about to solve this and i'd appreciate any help from you. I authenticate my web services agains a Redhat Fedora LDAP server, and i use authorization using my Database defined roles. So for authenticate i use *org.jboss.security.auth.spi.LdapLoginModule* and for authorization i use *org.jboss.security.auth.spi.DatabaseServerLoginModule,* i can to combine both login modules thanks to +password-stacking+ attribute*.* This is a fragment of my login-config.xml:
+ <application-policy name="SecurityGdm">+
+ <authentication>+
+ <login-module code="org.jboss.security.auth.spi.LdapLoginModule" flag="required">+
+ <module-option name="java.naming.factory.initial">com.sun.jndi.ldap.LdapCtxFactory</module-option>+
+ <module-option name="java.naming.provider.url">ldap://my.ldap.def:389</module-option>+
+ <module-option name="java.naming.security.authentication">simple</module-option>+
+ <module-option name="principalDNPrefix">uid=</module-option> +
+ <module-option name="principalDNSuffix">+
+ ,ou=mydomain.com,ou=People,dc=mydomain,dc=com+
+ </module-option>+
+ <module-option name="password-stacking">useFirstPass</module-option>+
+ </login-module>+
+ <login-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule" flag="required">+
+ <module-option name = "unauthenticatedIdentity">guest</module-option>+
+ <module-option name="dsJndiName"> java:/sincronizacionDS </module-option>+
+ <module-option name="rolesQuery"> SELECT FLDID_ROLSW, 'Roles' FROM crm.tbrrolesusuariossw WHERE FLDID_USUARIOSW = ?</module-option>+
+ <module-option name="password-stacking">useFirstPass</module-option>+
+ </login-module> +
+ </authentication>+
+ </application-policy>+
this configuration works if, for example, my credentials are*: user = Mary, password = *******,* BUT MY WEBMASTER NEED, INSTEAD OF LOOKING FOR AN +UID=+ AND +PASSWORD+ INSIDE MYDOMAIN, *AUTHENTICATE USING AN +EMAIL=+ AND* +*PASSWORD*.+
+THANKS IN ADVANCE+
+
+
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/582799#582799]
Start a new discussion in JBoss Web Services at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
15 years, 2 months