Using two RMI configurations for a single server

2002-01-31 Thread Joni Suominen

Hello,
I am running two instances of Orion on my backend segment. Both servers
run their own EJB applications. They are not clustered, shared or
anything like that and they accept RMI connections to separate ports.
Then I have one instance of Orion running on front-end. This instance is
deployed with two web applications. The setup I'am trying to accomblish
is therefore following:


   front-end back-end

+--+
|   EJB 1  |
+---+--+--+
|WebApp1|---/
|   |
|WebApp2|---+--+
+---+   \   |   EJB 2  |
 --+--+


The problem is that I haven't found any way to specify RMI configuration
per-application. As I understood it, it can only be done per-server. A
path to rmi.xml is specified in server.xml. JNDI can be easily setup per
application in many ways but is there way to do the same for RMI
configuration? If not, I think I have to split up the frontend server
instance too?

Thanx!

-- 
Joni
[EMAIL PROTECTED]
http://www.shiftcontrol.com





ORMI problem

2001-08-29 Thread Joni Suominen

Hi all,
I've noticed a strange bug in our latest production environment relating
to the behaviour of Orion's RMI protocol (ORMI). I'm running Orion's web
containers in different network segment than Orion's ejb containers. So,
the RMI traffic is going through a firewall which is between these
segments. When there has been lots of idle time, the front-end web
container loses the RMI connection and hangs on it without ever trying
to make a new connection.

Has any of you noticed similar behaviour or do you have any guesses what
might be going on? Otherwise I have to set up a stupid ping
application which periodically makes HTTP requests and keeps the
connection alive ;)

-- 
Joni
[EMAIL PROTECTED]





Re: Some questions on Orion

2001-07-16 Thread Joni Suominen

Kevin Duffey wrote:

 I will get my try at LDAP soon and I recall seeing some posts here on LDAP,
 so I would imagine it works with LDAP..of what company I have no idea.

I've been using OpenLDAP (http://www.openldap.org) with Sun's LDAP
provider in Linux. So far I haven't had any problems. The LDAP
operations I've done are very basic though (listing, adding and deleting
entries).

-- 
Joni
[EMAIL PROTECTED]




Re: SV: LDAP and EJBs

2001-07-10 Thread Joni Suominen

Thanks Patrik!
There's one issue which still puzzles me. Do I have to write my own
rollback code for LDAP operations when a transaction rolls back? I
browsed the JNDI API and SPI and I couldn't figure out if JNDI somehow
supports transactions (like JDBC does with begin(), rollback() and
commit()).

If my code is following for instance:

UpdatingFacadeEJB implements SessionBean {
public void doTheUpdate() {
   ldapDelegate.writeLdapEntry();
   rdbmsDelegate.writeRdbmsRow();
}
}

Let's say that ldapDelegate.writeLdapEntry() succeeds but
rdbmsDelegate.writeRdbmsRow() fails by throwing an EJBException. In this
case can the container's transaction manager somehow rollback the LDAP
operations done earlier in ldapDelegate.writeLdapEntry() method?

-- 
Joni
[EMAIL PROTECTED]


 Patrik Andersson wrote:
 
 You would have one sessionbean being business delegate in front of the
 EntityBean manipulating the RDBMS and another managing the LDAP
 directory service. Then you would have a Facade in front of both these
 sessionbeans with one method that does the whole trick with
 transactional attributes set up to require a transaction before
 entering the method.
 
 interface UpdatingFacade : SessionBean {
   void doTheUpdate() throws RemoteException;
 }
 
 interface LdapDelegate : SessionBean {
   void writeLdapEntry() throws RemoteException;
 }
 
 interface RdbmsDelegate : SessionBean or EntityBean {
   void writeRdbmsRow() throws RemoteException;
 }
 
 Then you want an error in the writeLdapEntry() aswell as the
 writeRdbmsRow() to throw an EJBException breaking the transaction
 begun by doTheUpdate() method. Both writeXxx methods must require that
 a transaction already exists before being called. The doTheUpdate()
 method  can really have it either way, as long as there is an active
 transaction associated to the thread calling it.
 
 regards,
 Patrik Andersson
 
 -Ursprungligt meddelande-
 Från: Joni Suominen [mailto:[EMAIL PROTECTED]]
 Skickat: den 6 juli 2001 08:32
 Till: Orion-Interest
 Ämne: LDAP and EJBs
 
 Hi everyone!
 I have a use case where I need to interface an LDAP directory and a
 relational database within a same transaction. That is, to create a
 new
 row to RDBMS from session bean using entity bean and to create an LDAP
 
 entry from the same session bean using Sun's LDAP provider through
 JNDI.
 
 1. Is this possible?
 
 2. Can I use container managed transactions?
 
 Thanks a lot!
 
 --
 Joni
 [EMAIL PROTECTED]




Startup script for HP-UX

2001-07-10 Thread Joni Suominen

Hi!
Does any of you have a proper Orion startup script for HP-UX? I found a
one from Orion support which works fine in Linux but not in HP-UX.

I also have problems to shutdown Orion in HP-UX. Nothing happens when I
issue:
/opt/java1.3/bin/java -jar admin.jar ormi://localhost admin passwd
-shutdown force

-- 
Joni
[EMAIL PROTECTED]




LDAP and EJBs

2001-07-06 Thread Joni Suominen

Hi everyone!
I have a use case where I need to interface an LDAP directory and a
relational database within a same transaction. That is, to create a new
row to RDBMS from session bean using entity bean and to create an LDAP
entry from the same session bean using Sun's LDAP provider through JNDI.

1. Is this possible?

2. Can I use container managed transactions?

Thanks a lot! 

-- 
Joni
[EMAIL PROTECTED]




Re: Debugging and orion

2001-06-29 Thread Joni Suominen

Hi,

You can use -out and -err commandline swiches to specify where
System.outs and System.errs are written. For example:

$JAVA_HOME/bin/java -server -jar orion.jar \
  -config $ORION_HOME/config/server.xml \
  -out $ORION_HOME/log/server-out.log \
  -err $ORION_HOME/log/server-err.log 


-- 
Joni
[EMAIL PROTECTED]

 Nusairat, Joseph F. wrote:
 
 OK its an older thread ... but i dont have time to read them all 
 
 I was just wondering ... if i run Orion as a service ... how do i see
 the System.out.printlns?
 
 Does it write them to any log file?? OR is there anyway i can pick
 them up
 
 -Original Message-
 From: Justen Stepka [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, February 21, 2001 11:08 AM
 To: Orion-Interest
 Subject: Re: Debugging and orion
 
 No matter what anyone tells you,
 
 System.out.println (ObjectName:MethodName ():line number);
 
 will work wonders!
 
 Justen Stepka
 
 On Wed, 21 Feb 2001, Julian Richardson wrote:
 
  Hi,
 
  What tools / IDEs are people out there using to develop EJBs for use
 with
  Orion? At the moment we (as a project team, rather than company) are
 trying
  to standardise on an app server and IDE to use, requirements being
 the
  usual:
 
cost
speed
flexibility
resource usage
debugging support from the IDE
 
  - I saw that someone mentioned using Kawa with Orion on the
 orionsupport
  website; has this combination been used by many people? (I'm new to
 the app
  server world, although I've been doing server-side Java work for
 several
  years now - I'm not used to environments where it's even possible to
 use an
  integrated debugger, but others on the team say it's necessary :-)
 
  Comments about the speed / flexibility / resource usage of Orion are
 welcome
  too, from the website it looks pretty slick and the documentation
 looks
  good, but time will tell... also if there's any major snags with
 orion in
  terms of things that the current version doesn't do correctly or
 doesn't
  implement...
 
  cheers
 
  Jules
 
  --
 
 




Different JNDI context factories

2001-06-28 Thread Joni Suominen

Hi!
I made an experiment with a setup where ejb components are deployed in
another server than web components. Orion provides three types of JNDI
context factories:
com.evermind.server.rmi/RMIInitialContextFactory
com.evermind.server.ApplicationClientInitialContextFactory
com.evermind.server.ApplicationInitialContextFactory

ApplicationClientInitialContextFactory is meant for Java application
clients but what is the difference between the other two,
RMIInitialContextFactory and ApplicationInitialContextFactory? My
experiment worked just fine no matter which one I used when separating
web tier from ejb tier.

-- 
Joni
[EMAIL PROTECTED]




Re: Using JAAS for authentication (Was: bugs in @page extends=...)

2001-06-01 Thread Joni Suominen
 this helps! Anyway, since you already have your own implementation
which works, you don't have any hurry to start using JAAS. If I were you
I would swich to JAAS at the same time when you are considering to swich
to JDK 1.4.

--
Joni
[EMAIL PROTECTED]

 Just curious to see how I could use this standard API without losing all
 the flexibility and dynamicity that I've already accomplished with my
 own implementation.
 
 Regards and thanks for the info,
 D.
 
 Joni Suominen wrote:
 
  Hi Daniel,
 
  JAAS is not necessarily tied to the OS user. Actually you can tie it to
  the OS user by using proper login modules which can authenticate if a
  user is already logged into an OS. However, in a true Java spirit, JAAS
  is much more generic. In fact it is just a framework to implement
  versatile authentication and authorization schemes. For instance, I
  authenticate user's against a relational database (some might use LDAP).
  The JAAS provides abstractions to represent user's identity and
  permissions. It also provides algortihms to check if configured security
  policy implies certain permission.
 
  Some sample code:
 
  PagePermission pagePermission = new
  PagePermission(admin);
  PermissionCollection pc =
  Policy.getPolicy().getPermissions(user.getSubject(), null);
 
  if (pc.implies(pagePermission)) {
  // authorization succeeded...
  }
  else {
  // authorization failed, the current user don't have a permission to
  view a page on this domain.
  }
 
  Then on policy file I might have:
 
  grant Principal org.shiftctrl.framework.security.SCGroupPrincipal
  admin {
 permission
  org.shiftctrl.framework.security.permissions.PagePermission admin;
  };
 
  This way it is easy to implement multiuser Java applications where
  accesses are controlled on per-user or per-group level. JAAS is also
  integrated to the JDK 1.4, like the new logging API you mentioned.
 
  --
  Joni
  [EMAIL PROTECTED]
 
 snipped...




Re: bugs in @page extends=.... in Orion implementation?

2001-05-31 Thread Joni Suominen

Hi Daniel,

JAAS is not necessarily tied to the OS user. Actually you can tie it to
the OS user by using proper login modules which can authenticate if a
user is already logged into an OS. However, in a true Java spirit, JAAS
is much more generic. In fact it is just a framework to implement
versatile authentication and authorization schemes. For instance, I
authenticate user's against a relational database (some might use LDAP).
The JAAS provides abstractions to represent user's identity and
permissions. It also provides algortihms to check if configured security
policy implies certain permission.

Some sample code:

PagePermission pagePermission = new
PagePermission(admin);
PermissionCollection pc =
Policy.getPolicy().getPermissions(user.getSubject(), null);

if (pc.implies(pagePermission)) {
// authorization succeeded...
}
else {
// authorization failed, the current user don't have a permission to
view a page on this domain.
}

Then on policy file I might have:

grant Principal org.shiftctrl.framework.security.SCGroupPrincipal
admin {
   permission
org.shiftctrl.framework.security.permissions.PagePermission admin;
};



This way it is easy to implement multiuser Java applications where
accesses are controlled on per-user or per-group level. JAAS is also
integrated to the JDK 1.4, like the new logging API you mentioned.

--
Joni
[EMAIL PROTECTED]

Daniel López wrote:
 
 Hi Joni,
 
 I agree it can be done. My situation is that I just don't log requests
 but I can log everything that happens in the environment, security
 settings, internationalization issues, XML/XSLT performance... so my
 logging code is tightly integrated with the framework and I can control
 it from a single point. I could use a filter to check things before the
 request is served, but as the rest of the parts are going to use it,
 what do I win by externalising it. Anyway, I hope to be able to discard
 this part of the environment as soon as JDK1.4 logging features become a
 reality. With security is more or less the same, we implemented our own
 security library because we are not satisfied with the standard and we
 don't want to get container specific. I agree I could externalise this
 as a filter but I wouldn't really win much, as it is also quite tightly
 integrated with the rest of the things. IMO, things that are standard
 and can be switched on/off and replaced with another implementation
 without a hitch are candidates to be externalised, otherwise, it's not
 that it cannot be done with filters, it's that I don't see a big win in
 doing so. Of course, that's my situation because I can control the MVC 2
 implementation and I can tightly integrate these parts.
 
 Just a question. I thought JAAS was used to control if the OS user that
 was executing the Java code was/was not allowed to perform such
 execution. If the OS user that executes the servlet code is supposedly
 always the same, how is this thing related to the application user that
 performs the request? I didn't think this standard could be used for
 that, if it is, I might go for it ;).
 
 regards,
 Dan
 
 Joni Suominen wrote:
 
  Hi!
 
  I have implemented these features as externalized filters. The reason
  for this was that I use a MVC 2 product which is developed independently
  (Jakarta Struts http://jakarta.apache.org/struts/). Like Marcel said the
  beauty of filters is that they are independent from the rest of the
  application. The filters allow me to plug in these services to the
  application without any integration code. So, I have a LogFilter which
  logs the requests using log4j (http://jakarta.apache.org/log4j/). After
  that there's an AuthorizationFilter which checks if the current user has
  priviledges to execute the request. AuthorizationFilter utilizes the
  forthcoming Java Authentication and Authorization service
  (http://java.sun.com/products/jaas/). All in all, I have a pretty
  flexible system with a very little own code.
 
  Joni
  [EMAIL PROTECTED]
 
  Daniel López wrote:
  
   Hi,
  
   I've also used filters, but in this case to filter requests by IP, as I
   don't want certain IP's to be able to access certain URLs. On the other
   hand, I implemented security, logging and other features inside my own
   servlet Controller, following a Model 2 approach. I thought about
   externalizing this services as filters, but that would mean that the
   web.xml file will grow too much and that I would have to put too much
   things in the request object each time. It's not that I've discarded the
   idea, but I don't see any compelling reason to implement everything as
   filters. We don't use servlets, but ONE controller servlet and action
   classes and we use JSP as view-only, creatures (actually, we seldom use
   them as we use XML/XSLT), so as anyway all the requests go through my
   controller servlet... We implemented IP filtering as a filter because we
   also wanted to use it in other

Re: Writing an external client

2001-05-31 Thread Joni Suominen

Hi Kevin!

Please check that applications\CricetApp is in your CLASSPATH.

--
Joni
[EMAIL PROTECTED]

Kevin Jones wrote:
 
 I want to access a javax.sql.DataSource from an external client, or, failing
 that an EKB Session bean.
 
 Looking at the (scant) Orion docs I have to do something like this
 
 Hashtable env = new java.util.Hashtable();
 env.put(Context.INITIAL_CONTEXT_FACTORY,com.evermind.server.ApplicationClie
 ntInitialContextFactory);
 env.put(Context.PROVIDER_URL,ormi://localhost/CricketApp);
 
 Context initial = new InitialContext(env);
 
 However I get an exception at the call to new InitialContext(env)
 
 javax.naming.NamingException: META-INF/application-client.xml resource not
 found
 
 at
 com.evermind.server.ApplicationClientInitialContextFactory.getInitialContext
 (JAX)
 at
 javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:665)
 at
 javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:246)
 at javax.naming.InitialContext.init(InitialContext.java:222)
 at javax.naming.InitialContext.init(InitialContext.java:198)
 at SimpleClient.main(SimpleClient.java:18)
 
 I've put an application-client.xml in applications\CricketApp\META-INF, but,
 obviously it's not being found.
 
 What am I missing/doing wrong?
 
 Kevin Jones
 DevelopMentor
 www.develop.com




Re: bugs in @page extends=.... in Orion implementation?

2001-05-30 Thread Joni Suominen

Hi!

I have implemented these features as externalized filters. The reason
for this was that I use a MVC 2 product which is developed independently
(Jakarta Struts http://jakarta.apache.org/struts/). Like Marcel said the
beauty of filters is that they are independent from the rest of the
application. The filters allow me to plug in these services to the
application without any integration code. So, I have a LogFilter which
logs the requests using log4j (http://jakarta.apache.org/log4j/). After
that there's an AuthorizationFilter which checks if the current user has
priviledges to execute the request. AuthorizationFilter utilizes the
forthcoming Java Authentication and Authorization service
(http://java.sun.com/products/jaas/). All in all, I have a pretty
flexible system with a very little own code.

Joni
[EMAIL PROTECTED]

Daniel López wrote:
 
 Hi,
 
 I've also used filters, but in this case to filter requests by IP, as I
 don't want certain IP's to be able to access certain URLs. On the other
 hand, I implemented security, logging and other features inside my own
 servlet Controller, following a Model 2 approach. I thought about
 externalizing this services as filters, but that would mean that the
 web.xml file will grow too much and that I would have to put too much
 things in the request object each time. It's not that I've discarded the
 idea, but I don't see any compelling reason to implement everything as
 filters. We don't use servlets, but ONE controller servlet and action
 classes and we use JSP as view-only, creatures (actually, we seldom use
 them as we use XML/XSLT), so as anyway all the requests go through my
 controller servlet... We implemented IP filtering as a filter because we
 also wanted to use it in other applications, as well as with static
 content.
 Just my 2c,
 D.
 ---
 Daniel Lopez Janariz ([EMAIL PROTECTED])
 Web Services
 Computer Center
 Balearic Islands University
 ---
 
 Marcel Schutte wrote:
 
  Hi Randahl,
 
  I've used a filter to do gzip encoding for specific file types. Starting
  with the tutorial at http://www.orionserver.com/tutorials/filters/lesson5/,
  I've changed some things to get the hang of it and also to reduce the amount
  of buffering used. It works fine, haven't had a problem with this
  (intranet)site.
 
  The beauty of filters is that they are completely independent from your
  application, just edit your web.xml and you are set.
 
  Let me know if you wnat some more info.
 
  Marcel
 
   -Original Message-
   From: [EMAIL PROTECTED]
   [mailto:[EMAIL PROTECTED]]On Behalf Of Randahl Fink
   Isaksen
   Sent: Wednesday, May 30, 2001 9:39 AM
   To: Orion-Interest
   Subject: RE: bugs in @page extends= in Orion implementation?
  
  
   Hi Marcel
  
  
   I looked it up, and I definately see your point about the
   filter mechanism.
   Have you any experience with this on Orion? Does it work
   well? And what have
   you used it for?
  
   Of course if anyone else have tried it out, I would very much
   like to hear
   from you too.
  
  
   Yours
   Randahl
  
   -Original Message-
   From: [EMAIL PROTECTED]
   [mailto:[EMAIL PROTECTED]]On Behalf Of
   Marcel Schutte
   Sent: 30. maj 2001 00:22
   To: Orion-Interest
   Subject: Re: bugs in @page extends= in Orion implementation?
  
  
   That's right, the two examples Randahl gives can be easily
   solved using the
   servlet2.3 filter mechanism, giving a very loose coupling of
   these features
   with your actual application.
  
   Marcel
  
   - Original Message -
   From: Juan Lorandi (Chile) [EMAIL PROTECTED]
   To: Orion-Interest [EMAIL PROTECTED]
   Sent: Tuesday, May 29, 2001 10:45 PM
   Subject: RE: bugs in @page extends= in Orion implementation?
  
  
I believe this could be better modeled differently, because
   it leaves no
room for the web server to implement its callbacks and java doesn't
   support
multiple inheritance.
   
 -Original Message-
 From: Randahl Fink Isaksen [mailto:[EMAIL PROTECTED]]
 Sent: Martes, 29 de Mayo de 2001 3:01
 To: Orion-Interest
 Subject: RE: bugs in @page extends= in Orion
   implementation?


 Well, can anyone confirm that JSP pages can extend your own
 class when using
 Orion??? Or has noone been able to use @page extends?

 I see many good reasons for implementing your own super class
 for your JSP
 pages. For instance, such a superclass could do logging
   of all client
 activities or it could do security checking.


 Randahl

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED]]On Behalf Of Robert
 Nicholson
 Sent: 25. maj 2001 21:15
 To: Orion-Interest
 Subject: RE: bugs in @page extends= in Orion
   implementation?


 It's doing you a favour.Please elaborate on why you want 

Re: finderException in home interface of CMP ??

2001-05-22 Thread Joni Suominen

In theory a multi-object finder can throw an exception, at least when
using BMP. This is possible for instance when a multi-object finder
calls a single-object finder. I am not sure if it would be a good
programming practise to let this FinderException to go unchecked to a
caller though. 

--
Joni
[EMAIL PROTECTED]

Eddie wrote:
 
 I understand your point and I completely agree that it's illogical. That's
 why I started testing around and found out that it's not necessary to throw
 a finderexception in case of a return collection.
 Like I see it now: I finderException is never thrown in case of a collection
 as it always returns an empty collection when it can't find anything ? Or am
 I missing something here.
 
 Neither does Orion complain when you leave out the FinderException!
 Or are there other situations when a FinderExceptions can occur in case of a
 Collection ??
 
 Eddie
 
 - Original Message -
 From: Joni Suominen [EMAIL PROTECTED]
 To: Orion-Interest [EMAIL PROTECTED]
 Sent: Monday, May 21, 2001 6:41 PM
 Subject: Re: finderException in home interface of CMP ??
 
  Joni Suominen wrote:
  
   Eddie wrote:
   
To me it's a bit unclear when I need to throw a FinderException in the
finder methods in the Home interface with CMP. ?
Now I only throw a finderException in case of
- the findByPrimareyKey (otherwise orion complaints),
- and in case of a single return object (orion doesn't complain, but
 gives
strange runtime errors).
   
So when a finder returns a collection I don't throw a
 finderException!! Is
this correct ?
  
   No. Every finder method should declare that it throws FinderException.
  
   Joni
   [EMAIL PROTECTED]
 
  To be more specific:
  In the home interface you should declare all the fonder methods to throw
  FinderException. But when a method which returns a non-collection raises
  an exception it will be ObjectNotFoundException (which is a subclass of
  FinderException). However, if a finder method which returns a collection
  don't find any matching objects an empty collection is returned. The
  method signature must still declare the FinderException in home
  interface which seems to be a bit illogical?
 
  Joni
  [EMAIL PROTECTED]
 
 




Re: finderException in home interface of CMP ??

2001-05-21 Thread Joni Suominen

Joni Suominen wrote:
 
 Eddie wrote:
 
  To me it's a bit unclear when I need to throw a FinderException in the
  finder methods in the Home interface with CMP. ?
  Now I only throw a finderException in case of
  - the findByPrimareyKey (otherwise orion complaints),
  - and in case of a single return object (orion doesn't complain, but gives
  strange runtime errors).
 
  So when a finder returns a collection I don't throw a finderException!! Is
  this correct ?
 
 No. Every finder method should declare that it throws FinderException.
 
 Joni
 [EMAIL PROTECTED]

To be more specific:
In the home interface you should declare all the fonder methods to throw
FinderException. But when a method which returns a non-collection raises
an exception it will be ObjectNotFoundException (which is a subclass of
FinderException). However, if a finder method which returns a collection
don't find any matching objects an empty collection is returned. The
method signature must still declare the FinderException in home
interface which seems to be a bit illogical?

Joni
[EMAIL PROTECTED]




Load balancing advice needed

2001-05-18 Thread Joni Suominen

Hi!
I am currently planning the new production environment for our service.
The idea is to have following harware setup:

1 firewall (which used for loadbalancing too)
2 Linux/Intel boxes as frontend servers (both running HTTP accelerators
and web containers)
1 UNIX server as a backend server (running an EJB container and
databases)

I went through load balancing documentation which I found from
orionserver.com but I didn't find any way to separate Orion's web
container and EJB container to achieve the above setup. Is it somehow
possible to do that kind of separation? How would you distribute the
required processes on those three servers?

-- 
Joni
[EMAIL PROTECTED]




Re: Generating primary keys

2001-05-15 Thread Joni Suominen

Hi!
I use a bit similar approach that in the Brett's article. The difference
is that instead of hitting database every time a small cache is kept for
each sequence. The algorithm is simple. Each unique id consists of two
values: high and low (uid = high + low). The UidGenerator is initialized
from a database. It exclusively reads a high value from db and updates
high value in database by one. This ensures that each possible generator
gets a unique high value. Then on each getNextUid() call a value high +
low is returned and low is increased by one. If low value hits its
maximum it is set back to 0 and a new high value is read from the
database.

Consequences:
+ better scalability since most of the uids are generated in memory
without database access
+ works also in a distributed environment since each UidGenerator is
initialized with a unique high value
+ should work on any J2EE app server
- leaves unused uids every time the system is booted

This HIGH-LOW algorithm is explained in:
http://www.sdmagazine.com/articles/1999/9912/9912p/9912p.htm

Here's some sample code. My version is implemented as a BMP entity bean
and uids are Java long variables. LOW cache is set to be 16 numbers but
this is easy to change just by tweaking the constants: LOW_LENGTH and
LOW_MAX.

UidGenerator.java:
##
package org.shiftctrl.uid.persistence;

import java.rmi.RemoteException;

import javax.ejb.EJBObject;

/*
 * @author Joni Suominen
 * @version 
 */
public interface UidGenerator extends EJBObject {
public long getUid() throws RemoteException;
}


UidGeneratorHome.java
#
package org.shiftctrl.uid.persistence;

import java.rmi.RemoteException;

import javax.ejb.CreateException;
import javax.ejb.FinderException;
import javax.ejb.EJBHome;

import javax.naming.NamingException;


/**
 * The home interface of the UidGenerator EJB.
 */
public interface UidGeneratorHome extends EJBHome {

public UidGenerator create(String id)
throws RemoteException, NamingException, CreateException;

public UidGenerator findByPrimaryKey(String id) 
throws RemoteException, FinderException;

}


UidGeneratorEJB.java

package org.shiftctrl.uid.persistence;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.ejb.EntityBean;
import javax.ejb.EntityContext;
import javax.ejb.EJBException;
import javax.ejb.CreateException;
import javax.ejb.FinderException;
import javax.ejb.ObjectNotFoundException;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;

import org.shiftctrl.framework.util.JndiNames;


/**
 * A unique id generator implementing 
 * a
href=http://www.sdmagazine.com/articles/1999/9912/9912p/9912p.htm;
 * high-low algorithm/a using BMP on relational database.
 * p
 * The required database structure:br
 * CREATE TABLE uids (id VARCHAR PRIMARY KEY, high LONGINT);
 *
 * p
 * The usage:
 * pre
 *
 * UidGenerator uidGenerator = null;
 * try {
 * uidGenerator = uidGeneratorHome.findByPrimaryKey(Generator
name);
 * } catch (FinderException fe) {
 * try {
 * System.out.println(No existing UidGenerator \Generator
name\, let's create a one);
 * uidGeneratorHome.create(Generator name);
 * uidGenerator = uidGeneratorHome.findByPrimaryKey(Generator
name);
 *  } catch (Exception e) {
 *  throw new EJBException(e);
 *  }
 * }
 *
 * uidGenerator.getId();
 *
 * /pre
 *
 * @author Joni Suominen
 * @version $Revision: 1.2 $
 */
public class UidGeneratorEJB implements EntityBean {
/** 
 * An id for a generator.
 */
private String id;

/**
 * The high value which forms the most significant bits of id.
 */
private long high;
private static final int HIGH_LENGTH = 60; // 60 bits

/**
 * The low value which forms the least significant bits of id.
 */
private int low;
private static final int LOW_LENGTH = 4;   // 4 bits
private static final int LOW_MAX = 15;// 2^4 - 1

private EntityContext context;

/**
 * Creates an UidGenerator.
 *
 * @param id an id for UidGenerator
 */
public String ejbCreate(String id)
throws NamingException, CreateException {

this.id = id;
this.high = 1;
this.low = 0;

Connection con = null;
PreparedStatement pStmt = null;
try {
con = getConnection();
pStmt = con.prepareStatement(insert into uids (id, high)
values (?, ?));
pStmt.setString(1, this.id);
pStmt.setLong(2, this.high + 1);

pStmt.executeUpdate();
pStmt.close();
} catch (SQLException se) {
se.printStackTrace();
throw new EJBException(se);
} finally {
if (pStmt != null) {
try {
pStmt.close

Problems with SAPDB

2001-05-14 Thread Joni Suominen

Hi!
I am in a middle of changing our database from HypersonicSQL to SAPDB.
In theory it should be easy ;) This is how I have proceeded:

1. I created a database-schema for SAPDB (actually I found a one from
this mailing list and copied it). I put that file to
$ORION_DIR/config/database-schemas/. The schema file being used:
?xml version=1.0?
!DOCTYPE database-schema PUBLIC -//Evermind//- Database schema 
http://www.orionserver.com/dtds/database-schemas.dtd;

database-schema name=SapDB not-null=not null null=
primary-key=primary key max-table-name-length=32
  type-mapping type=boolean  name=boolean /
  type-mapping type=java.lang.Booleanname=boolean /
  type-mapping type=byte name=byte /
  type-mapping type=java.lang.Byte   name=byte /
  type-mapping type=char name=char /
  type-mapping type=java.lang.Character  name=char /
  type-mapping type=double   name=double precision
/
  type-mapping type=java.lang.Double name=double precision
/
  type-mapping type=floatname=float /
  type-mapping type=java.lang.Float  name=float /
  type-mapping type=int  name=integer /
  type-mapping type=java.lang.Integername=integer /
  type-mapping type=long name=integer /
  type-mapping type=java.lang.Long   name=integer /
  type-mapping type=shortname=smallint /
  type-mapping type=java.lang.Short  name=smallint /
  type-mapping type=java.lang.String name=varchar(255) /
  type-mapping type=java.math.BigDecimal name=fixed(15,15) /
  type-mapping type=byte[]   name=long byte /
  type-mapping type=java.sql.Datename=date /
  type-mapping type=java.sql.Timename=time /
  type-mapping type=java.sql.Timestamp   name=timestamp /
  type-mapping type=java.util.Date   name=timestamp /
  type-mapping type=java.io.Serializable name=long byte /
  
  disallowed-field name=key /
  disallowed-field name=date /
  disallowed-field name=timestamp /
  disallowed-field name=time /
  disallowed-field name=username /
  disallowed-field name=password /
  disallowed-field name=order /
  disallowed-field name=table /
  disallowed-field name=value /
  disallowed-field name=name /
  disallowed-field name=count /

/database-schema

2. I created a data-source description for SAPDB and pointed my
application to use it. The data-source description being used:
data-sources

 data-source class=com.evermind.sql.ConnectionDataSource
  inactivity-timeout=120
  location=jdbc/DefaultCoreDS
  pooled-location=jdbc/DefaultPooledDS
  name=SAPTest data-source
  schema=./database-schemas/sapdb.xml
  xa-location=jdbc/xa/DefaultXADS
  ejb-location=jdbc/DefaultDS
  url=jdbc:sapdb://localhost/testdb
  connection-driver=com.sap.dbtech.jdbc.DriverSapDB
  username=TEST
  password=TEST
  /

/data-sources

3. I added the SAPDB JDBC driver to $ORION_DIR/lib

4. I restarted Orion


I believe that in an ideal case these would be the required steps when
database is changed. However, I encountered two problems:

1. Table auto-creation was not fully successful. All the other tables
were correctly created but one. SAPDB has a limit for maximum lenght for
table row names but I didn't find any way to specify this in schema
definition. Maximum legth for table names are supported by the attribute
max-table-name-length=32 and it works fine. Do you know if there's a
similar way to restrict the length of a row? (I tried
max-row-name-length but wasn't lucky :)

2. The following exception is thrown:
com.evermind.server.rmi.OrionRemoteException: javax.ejb.EJBException:
Error saving state: Connection was closed
at com.evermind.server.ejb.EJBUtils.getUserException(JAX)
at
UserManager_StatelessSessionBeanWrapper14.getGroupNamesForUser(UserManager_StatelessSessionBeanWrapper14.java:1348)
at
org.shiftctrl.framework.security.authentication.DefaultLoginModule.commit(DefaultLoginModule.java:243)
...

Nested exception is:
javax.ejb.EJBException: Error saving state: Connection was closed
at
SCUser_EntityBeanWrapper5.saveState(SCUser_EntityBeanWrapper5.java:1057)
at
SCUser_EntityBeanWrapper5.getGroupNames(SCUser_EntityBeanWrapper5.java:712)
at
org.shiftctrl.user_management.service.UserManagerEJB.getGroupNamesForUser(UserManagerEJB.java:328)
...

The control goes so that the user is first authenticated using a session
bean + CMP entity bean. Then the user's login metadata (last login, num
of logins et.) is correctly updated using a session bean + CMP entity
bean. After that the intention is to initialize user's session by
calling getGroupNamesForUser() on a session 

Re: Problems with SAPDB (correction)

2001-05-14 Thread Joni Suominen

I meant column names when I wrote row names. As far as I know the row's
usually don't have any names ;) Stupid me...

Anyway, the problems remain...

Joni
[EMAIL PROTECTED]




Stateless bean and remove

2001-05-11 Thread Joni Suominen

Hi!
This question should propably be asked in EJB-INTEREST mailing-list but
I raise it here since I am not currently following it. So apologize me
if you feel that this is a bit offtopic. The question is simple:

Is it required to call the remove() method on stateless session bean
after finishing using it or can the container automatically restore it
to a pool (using Java garbage collection or DGC perhaps?)?

For instance, the ATM example which ships with Orion don't use remove()
after finishing the use of a stateless session bean instance. The same
goes with Sun's Java Pet Store demo. On the other hand in Wrox Press's
book Professional Java Server Programming, J2EE Edition they call
remove() on stateless session beans.

Currently I don't use remove() with stateless session beans. Should I?

-- 
Joni
[EMAIL PROTECTED]




Re: Standar Template

2001-05-11 Thread Joni Suominen

Using a filter sounds like a good idea. It is a natural way to implement
Decorator design pattern.

--
Joni
[EMAIL PROTECTED]

Smith Jason wrote:
 
 Maybe you could use a filter?
 
 Check out the filter tutorial at http://www.orionserver.com/
 
 /Jason
 
 -Original Message-
 From: Dave Ford [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, May 10, 2001 9:17 PM
 To: Orion-Interest
 Cc: Dan Tharp
 Subject: Standar Template
 
 I want to create a web app in which every page on the site has a standard
 header along the top and a standard menu along the left edge (a pretty
 standard thing).
 
 I came up with 2 ways of doing this:
 
 1. Use a table tag and jsp:include tags on EVERY page:
 
 table
   tr
 tdjsp:include page=standardHeader.jsp//td
   /tr
   tr
 td colspan=2
 table
   tr
 td valign=topjsp:include page=/menu.jsp //td
 td valign=top
  THIS IS WHERE THE PAGE-SPECIFIC CONTENT (i.e. the body)*
 /td
   /tr
 /table
 /td
   /tr
 /table
 
 2. Invert the above solution to create one master template (or controller)
 and have the content page name passed in as a parameter. Here would be the
 master template-controller page:
 
 table
   tr
 tdjsp:include page=standardHeader.jsp//td
   /tr
   tr
 td colspan=2
 table
   tr
 td valign=topjsp:include page=/menu.jsp //td
 td valign=top
  jsp:include page=%=request.getParameter(contentPage)% /*
 /td
   /tr
 /table
 /td
   /tr
 /table
 
 The key difference between these two architectures are best understood by
 looking at the 2 lines with the * at the end. Also, in option 2, there is
 only one copy of the above code. In option 1, there is one copy per content
 page
 
 Q1: Does anyone have any preference between options 1 and 2?
 Q2: Is there a better way of achieving this result?
 Q3: Do either have any negetive drawback I need to consider? (I will be
 converting an entire site)
 
 By the way, I'm currently achieving this effect VERY easily using good old
 client-side html frames. But due to popular demand, framse must go.
 
 Dave Ford
 Smart Soft - The Java Training Company
 http://www.smart-soft.com




Re: Servlet Mapping Recursion Problem

2001-05-11 Thread Joni Suominen

Hi Bill!
I am using a front servlet pattern with Orion. I use Struts but I
suppose this approach should work in any framework.

1. The front servlet mapping in web.xml:
  servlet-mapping
servlet-nameaction/servlet-name
url-pattern*.html/url-pattern
  /servlet-mapping

So all the requests ending to .html are processed by the front-end
servlet.

2. All the valid URL's are mapped in an xml config file. The front
servlet initializes its state by reading this file in a startup. An
entry in this file looks like:
  actionpath=/faq
 type=org.shiftctrl.general.interaction.EmptyAction
forward name=success  path=/faq.jsp/
  /action

This means that the request http://myserver.com/faq.html is first
processed by front servlet. The servlet searches its configured mapping
and forwards the request. In this case it would forward the request to
faq.jsp.

I haven't had problems with this setup and I really like it for
following reasons:
1. It is easy pipeline actions. Just configure the mapping so that its
forward part points to another mapping.
2. You can hide the technology being used. Clients only see URLs which
are always ending .html (so .jsps are not exposed outside, their
function is only to provide the view part in MVC pattern)
3. It is possible to dynamically change the URL mapping by calling
appropriate methods in front servlet.

--
Joni
[EMAIL PROTECTED]

 Bill Winspur wrote:
 
 In my web.xml I set up the servlet mapping, for a (front) servlet to
 handle all requests for the web app, to '/'. This works to the extent
 that all requests are passed to the servlet. BUT... if I do a forward
 to another resource from the servlet, the servlet's doGet() method is
 invoked recursively with no response generated until the jvm runs out
 of memory. The same thing happens with a url-pattern of '/*'. If the
 servlet itself generates html output, that works.  If I map my servlet
 to a specific resource, like /index.html, forwarding works fine, but
 the servlet cant handle all requests and 'http://myhost/myapp' returns
 'no directory browsing'.
 
 The url-pattern '/' seems like a valid directory specification (as per
 the servlet 2.2 spec, 'Servlet Mapping Techniques') and a front
 component, handling all requests is fundamental in the j2EE blueprints
 (http://java.sun.com/j2ee/blueprints/index.html, section 10.6), so my
 approach seems architecturally reasonable.
 
 I've looked thru the archives and found two reports of the same
 problem. A proposed workaround from Magnus seems to recommend
 explicitly mapping every request your app generates (which would make
 the web.xml coding difficult to maintain in a large app) pendng the
 delivery of 'filters', perhaps in Servlet 2.3. I dont really
 understand what Magnus is suggesting:
 
 PS: If you're bound to 2.2 or lower then you will not be able to use
 Filters, in that case you'd have to apply a more complex solution with
 duplicate resource roots and so on.
 
 It looks like 'no front servlets on Orion' to me, but I hope I'm
 wrong.
 
 I was not able to find any references to the problem on bugzilla, but
 I'm not very adept with its query interface.
 
 My hunch is that Orion's request dispatcher is invoked in two contexts
 (from a client, and from a forward) and does not distinguish between
 them when it comes to selecting a resource to respond to the client.
 If the dispatcher ignored mapping in the forward context and just
 accepted the specified resource, the recursion problem would vanish
 and the front servlet would trap ALL client requests as per the
 blueprint architecture. Just a hunch, things are probably not that
 simple.
 
 Does anyone know if this is a problem with other webservers ? My
 experience with Apache was all static pages.
 
 My environment is NT4(sp6), Orion 1.4.8, IE 5.00, JDK 1.2.2.
 
 Also, if somebody is actually using the front servlet pattern and
 univeral mapping on Orion, and could let me know how to set it up
 and/or get around the recursion I'd be a happy camper.
 
 TIA,
 
 Bill.




Re: FW: custom finder in CMPs (SLSB facade)

2001-05-07 Thread Joni Suominen

Armin Michel wrote:
 
 IMHO, facades are only useful when they do some extra-work, e.g.
 consolidating the work with many other EJBs.
 
 When you just use a facade to plainly forward any request to exactly one
 EntityBean (1:1 relationship between facades and EntityBeans) than it's not
 worth the trouble.

Except if there's a need to keep the design uniform. I am always using a
following layered architecture in my J2EE applications:

+---+---+  +---+---+---+
| P | I |  | S | D | P |
| r | n |  | e | o | e |
| e | t |  | r | m | r |
| s | e |  | v | a | s |
| e | r |  | i | i | i |
| n | a |  | c | n | s |
| t | c |  | e |   | t |
| a | t |  |   |   | e |
| t | i |  |   |   |   |
| i | o |  |   |   |   |
| o | n |  |   |   |   |
| n |   |  |   |   |   |
+---+---+--+---+---+---+
|Framework |
+--+

Presentation and interaction layers are deployed on web container.
Presentation layer contains HTML, WML or XML specific code (e.g. JSP tag
extensions). Interaction layer contains MVC command classes and
presentation related model components. The rest of the tiers, service,
domain and persistence are deployed on EJB container. Service tier,
implemented as session beans, provide the use case implementations and
serves them as a facade to the interaction tier. Domain layer contains
CMP entity beans and dependent objects. Persistency tier contains
possible data source specific code. For instance BMP entity beans. The
framework package contains some common classes used everywhere. I
usually deploy the framework jar file to ${JAVA_HOME}/jre/lib/ext.

The good thing about this architecture is that it is easy understand
even complex use case realizations since every use case follow exactly
the same design. The bad thing is that it requires some extra code (and
an extra EJB call) when doing simple things (like mentioned in previous
mails). But I later hope to resolve this extra programming overhead by
using code generators.

-- 
Joni
[EMAIL PROTECTED]




Re: remote shutdown of orion 1.4.8

2001-05-04 Thread Joni Suominen

[EMAIL PROTECTED] wrote:
 
 Folks,
 
 The following remote shutdown command does not work anymore in 1.4.8 (it
 works fine in 1.4.7), any ideas? bug?
 
 java -jar admin.jar ormi://localhost admin password -shutdown

Hi!
It is a bit unclear for me how the shutdown process should work. When I
initiate java -jar admin.jar ormi://localhost admin password -shutdown
the message Shutting down... is printed on the log. After that Orion
no longer responds to any requests but all the Java processes are still
kicking alive:

$ ps ax
21242 pts/2S  0:00 /usr/java/jdk1.3/bin/i386/native_threads/java
-server -Xms8m -Xmx192m -Djava...
21266 pts/2S  0:00 /usr/java/jdk1.3/bin/i386/native_threads/java
-server -Xms8m -Xmx192m -Djava...
...

Platform: RedHat Linux 7.0, HotSpot Virtual Machine, Orion 1.4.7

Is there a way to shutdown Orion so that it stops all Java procesesses
too?

-- 
Joni
[EMAIL PROTECTED]




Re: JavaMail

2001-05-04 Thread Joni Suominen

Nijhawan, Sumit wrote:
 
 Hi,
 
 Does anyone know of any products (other than Orion) using and being
 distributed with Sun's reference implementation of the JavaMail API
 (mail.jar and activation.jar)?  Is anyone aware of any licensing issues for
 distributing these jars freely?
 Thanks.

From JavaMail FAQ (http://java.sun.com/products/javamail/FAQ.html):

Q: Is the JavaMail API implementation completely free? Can I ship it
along with my product?

A: Yes. The current release of the JavaMail API implementation, is
completely free and you can include it in your product. This release
includes IMAP, POP3, and SMTP providers as well. Please do read the
LICENSE and ensure that you understand it. The JavaBeans Activation
Framework is also free for use under a similar license. 

-- 
Joni
[EMAIL PROTECTED]




Re: Is it possible to have Apache as Reverse Proxy (front-end) and LoadBalancer ?

2001-05-02 Thread Joni Suominen

Take a look at Squid (http://www.squid-cache.org). I have successfully
used it as a front-end accelerator with Orion. With simple redirect
rules I guess you can use it as a load balancer too. It is open source,
very stable and available for most platforms. Although I found a
possible bug in Orion relating to frontend tag. See:
http://www.mail-archive.com/orion-interest%40orionserver.com/msg12780.html

There's also Linux Virtual Server project which is aimed for load
balancing:
http://www.linuxvirtualserver.org/

Joni
[EMAIL PROTECTED]

Joseph B. Ottinger wrote:
 
 Sure, it's possible. Dumb, but possible. See www.orionsupport.com for more
 on it. Note that we saw degradation on a massive scale - something that took
 12 seconds without apache proxying took 1 minute 45 seconds with apache, in
 the worst case. :)
 
 On Mon, Apr 30, 2001 at 08:04:17PM +0200, Ismael wrote:
  Is it possible to have Apache as Reverse Proxy (front-end) and LoadBalancer
  at the same time.?
 
  I think that on the servers you define the front-end and they will collide.
 
 
  Anyone knows how to do it?
 
 
 --
 ---
 Joseph B. Ottinger   [EMAIL PROTECTED]
 http://epesh.com/ IT Consultant




Re: MVC/XML Framework Comments please

2001-04-28 Thread Joni Suominen

Cory Updyke wrote:

 My issue with XML/XSL transformations is this: My theory for the
 presentation tier is to keep it as simple as possible.  Occasionally, you
 find a designer who has every right to be a engineer, but designs because
 they enjoy it. This person will scoff(sp?) at the simplicity of XSL.  Most
 of the time you will find designers who know HTML (PDF, etc.).  Which
 concept is closer to HTML, XML/XSL or JSP?  I think JSP.  I also have found
 it easier to say Do you see the green (or whatever color depending upon
 your IDE) colored text? Please don't delete that than it is to teach
 someone the concept behind XSL.  You can have a good hour conversation, hand
 them the JSP Syntax Reference document and say DESIGN good man.

I totally agree! Some years ago (before JSP) we implemented an XML based
publishing system. We used our own template language which was a
simplified version of XSL. The platform was techinically excellent and
contained more than 150.000 lines of Java code. We had a very complex
layered caching mechanism: cache for data objects, cache for XML data
sources, cache for precompiled templates, cache for generated HTML
snippets etc. The bad news for us came later. The system was a way too
complex for our designers and HTML coders! It took relatively long time
to do simple things. In other words, we went too far with the
abstraction.

 Anyway... enough talk... we use Struts and our own Model-2-Brew.

That's what we do also nowdays. We use Struts with some own add ons
which allow us to configure the caching policies and access control
lists for each action in struts-config.xml. Business objects and
processes are without an exception implemented as EJBs.

Joni
[EMAIL PROTECTED]




sendRedirect and frontend host=.. port=.. / bug

2001-04-26 Thread Joni Suominen

Hi!
There seems to be a bug in Orion (1.4.7) with sendRedirect and frontend
host=.. port=.. / tag (from web-site.xml). I have understood the
meaning of frontend tag so that it is used in HTTP REDIRECTS if relative
URL is used in a method HttpServletResponse.sendRedirect. E.g.
response.sendRedirect(/foo.jsp) should send a redirect pointing to
http://my.server:port/foo.jsp if web-site is configured with frontend
host=my.server port=port / tag. This doesn't work in my environment
where I use Squid cache server (http://www.squid-cache.org) as a
frontend server listening port 80 and Orion is running on a same machine
on port 8080. So, my web-site configuration is:

frontend host=www.myserver.com port=80 /

The port attribute in frontend tag is working well but Orion always
incorrectly sends the redirect pointing to localhost, thus neglecting
the host attribute. Notice that the actual request comes from localhost
since Squid is listening port 80 and then issueing a new HTTP request to
port 80. 

Here's a beautiful picture depicting this architecture :)

   +-+
   |   Firewall  |
   +-+
 |
 | http://www.myserver.com:80
 V
  +---+
  |  ++   |
  |  |   Squid|   |
  |  ++   |
  |  ||
  |  | http://localhost:8080  |
  |  V|
  |  ++   |
  |  |   Orion|   |
  |  ++   |
  |   |
  +---+

The obvious (but ugly) fix for this is to always use absolute URL's when
using response.sendRedirect();

This bug propably have implications on a various load-balancing
solutions too? Has any of you seen this? I am considering to put this to
Orion bugzilla but I am still hesitating since I am not 100% sure if I
have understood the problem correctly.

BTW. This Squid set up as a front-end cache server is an excellent way
to speed up Orion. It is very fast with static files (gifs, jpegs etc.)
and with a simple rules + HTTP headers it is possible to cache dynamic
pages too. You can contact me in case you want more information.

-- 
Joni
[EMAIL PROTECTED]