alexandre russel

Greenhorn
+ Follow
since Nov 28, 2005
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by alexandre russel

Hi all,
It is possible to deploy a war file to a context with Tomcat.
How can I do the same with JBoss4.0.4 without changing the jboss-web.xml and web.xml files. I want the foo.war to have the context /footest even it is set to foo1 and foo2 in the jboos/web.xml.
Any help, hint welcome.
thanks in advance,
alex
16 years ago
my mistake, it says in the errata Short story = 200.
so my question doesn't make sens anymore :-)
Hi,
I am using the SCJP book for java 5
page 266, there is a question concerning GC.
It creates 2 Cardboard objects c1 and c2 having instance variable
Short story = 5;
during main, one of the reference to Cardboard is nulled.
The book answer states that 2 object are eligible for GC, c1 and c1.story.
But according to page236, if Short is under 127 then only 1 object will be created, So c2.story points still toward c1.story and so the object in not GC. So only 1 object is GC no ?
any light welcome :-)
I actually found the answer, I think finalize() is never called more than once by the JVM. If it has been called programmmaticaly doesn't matter.
I runned:
public class A{
public int x=0;
public static void main(String[] args)throws Throwable{
A a = new A();
a.finalize();
a.finalize();
a=null;
Thread.sleep(1000);
System.gc();
}
protected void finalize(){
this.x++;
System.out.println("x is " + this.x);
}
}
and got:
java A
x is 1
x is 2
x is 3

thanks for your help,
alex
say:
public class A{
public int a = 0;
public static void main(String[] args)throws Throwable{
A b = new A();
b.finalize();
b.finalize();
System.out.println(b.a);
}
protected void finalize(){
a++;
}
}

then the output is 2, so finalize() has been called twice on the same object.
Alex :-)
thanks John,
but can it be called more than once ?
From reading the book I got the impression that If I did myObj.finalyse() then myObj was like marked and the finalyse method could not be called ever again on it so a second myOjb.finalyse() would give an exception or not do anything and when the object is garbaged collected then the finalyse method is not called.
It is what I understand when I read:
finalize() is never run more than once on any object
Alex
btw, it is question 71 on the downloaded exam from LearnKey.
So when the first Phoenix object is garbage collected, finalize is not runned on it ?

class History{
static Phoenix p2;
static void send(Phoenix p){p2=p;}
public static void main(String[] args){
new Phoenix().finalize();
new Phoenix().finalize();
Phoenix p3 = new Phoenix();
}
}

class Phoenix{
protected void finalize(){
History.send(this);
}
}
class History{
static Phoenix p2;
static void send(Phoenix p){p2=p;}

}
can finalize be called more than once on an object?
here: http://www.janeg.ca/scjp/gc/finalize.html it says:
finalize() is never run more than once on any object

but the mock exam state the opposite.
Which one is true?
maybe:
finalize() is never run more than once BY THE JVM on any object
Alex
thanks Reid and jaikiran.
I finaly found the problem. I was using a small helper class and my ejb was sending an array of that helper class. I check 10000 times that ejb and war used the "same" ejb-client and they did, but ejb and war were using different helper class.
thanks again for taking the time to reply.
alex
I have an local ejb foo. I packed it into a jar and deployed it to JBOSS.
I can test it with cactus. Take a test file, packed it into a jar, add the cactus redirector and the code:
FooHome h = (FooHome) ctx.lookUp("ejb/Foo");
will work.

Now if I create a war file, with in the lib my client-ejb.jar, and I do:
FooHome h = (FooHome) ctx.lookUp("ejb/Foo")
I got a classCastException: $proxy45.
However, if I look at the jmx-console I do have $proxy45 with ejb/Foo that reference FooHome ...
If anyone could just give a hint on what I am doing wrong?
I think it may have to do with classLoader but don't get where or why.
thanks in advance,
alex
Hi,
I created a login module with JBoss. It create the callerPrincipal:
SimpleGroup roles = new SimpleGroup("Roles");
SimpleGroup callerPrincipal = new SimpleGroup("CallerPrincipal");
SimpleGroup cpLogin = new SimpleGroup("login");
cpLogin.addMember(new SimplePrincipal("my login name"));
SimpleGroup cpId = new SimpleGroup("id");
cpId.addMember(new SimplePrincipal("my id"));
callerPrincipal.addMember(cpLogin);
callerPrincipal.addMember(cpId);
roles.addMember(new SimplePrincipal("manager"));
log.debug(callerPrincipal.toString());
Group[] roleSets = {roles, callerPrincipal};

the log file gives me: CallerPrincipal(members:login(members:my login name),id(members:my id))

Everything is fine but when I call userPrincipal from a JSP:
java.security.acl.Group group = (java.security.acl.Group) request.getUserPrincipal();
<%= group.toString() %><br/>

then only the first member of the callerPrincipal group is there .
login(members:my login)

How can I access the rest of my group?
thanks for your help.
alex
16 years ago
JSP
Reid thanks for your answer. My post wasn't really clear. In my company, the LDAP administrator doesn't want role to be mapped into the LDAP.
When you say "it would better to write a JAAS provider to hide it."
Do you mean write my own login module like in:
http://docs.jboss.org/jbossas/jboss4guide/r3/html/ch8.chapter.html#ch8.custom.sect
Another question (it is why my topic says best practices):
Once I checked password with LDAP, checked role with database I still need to get the id of the user(in LDAP) map it to an EJB Bean(made from another DB) and make that EJB a session Bean. Do you think those task still belongs to a jaas module or to the application controller or where...?

Alex.
PS: I order Core Security Patterns: Best Practices and Strategies for J2EE, Web Services, and Identity Management, I hope everything is inside or I will have to ask Kathy and Bert to write the Head First J2EE Security ;-)
16 years ago
I am using jboss4. I set it up so it check password with my LDAP. Now I want it to get the user role in a database but only the role(not checking the password once again because password are only stored in the LDAP).

from the jboss documentation:
It's often the case that a local LDAP server provides identity and authentication services but is unable to use the authorization services. This is because application roles don't always map well onto LDAP groups, and LDAP administrators are often hesitant to allow external application-specific data in central LDAP servers. For this reason, the LDAP authentication module is often paired with another login module, such as the database login module, that can provide roles more suitable to the application being developed.

but chapter 8.4.6.4 says about the databaseLoginModule:
You would use this login module if you have your username, password and role information relational database
My question:
How can I use the databaseLoginModule just to retrieve role or what module should I use to do so? I don't have the password in the database.
If not possible where and how should I assign a role to the user?

thanks in advance for help, link or anything usefull.

PS: I already posted to the jboss forum with no response. Appologies if someone had to read twice about my problem.
16 years ago
when I start jboss with my applications I end up with 57 java processes. Are each packages deployed to jboss running with their own JVM, or are they all in the same JVM( and then why so many processes)?
thanks in advance,
Alex