Re: How to determine in which container code is running?

2012-12-31 Thread Markku Saarela

JPA is one implementation of DataMapper.

One idea of Domain Model with UOW is that it decouples persistence layer 
from domain implementation and tracking changes of the domain objects.


Domain Model does not know anything about persistence. When domain 
object is created or otherway manipulated it register that it's state 
has changed to the UOW instance and when user or service decide to save 
state of the domain objects they call UOW method commit() which delegate 
work to actual persistence implementation(JPA for example).


So these patterns are not reinventing the wheel again (persistence), 
instead it describe how to build  effective software with domain model 
that is totally independent of EIS layer.


rgds,

markku

On 12/31/2012 06:55 PM, David Jencks wrote:

I'm not familiar with this particular way of describing UOW or data mapper, but 
you might consider whether they are irrelevant with ee facilities.  The whole 
purpose of EJBs is to provide declarative transaction management, which is what 
UOW usually means.  A tiny bit of googling of data mapper makes me ask why you 
wouldn't use jpa.  I haven't read Fowler's books for many years, I thought his 
refactoring book was really good, but the design patterns ones seemed to me to 
be reinventing the wheel as far as ee goes.

thanks
david jencks

On Dec 31, 2012, at 8:18 AM, Markku Saarela wrote:


My use case is to implement Martin Fowler's Domain Model enterprise design 
pattern with Unit Of Work and  Data Mapper.

This UOW does not work with ThreadLocal in every app server due to thread 
pooling.

So only solution to use different UOW storing mechanism in different layers;
session persistence in web container and pass UOW instance to the EJB container 
and store it to TransactionSynchronizationRegistry. Of course standalone Java 
client could use TrhreadLocal implementation.

In UOW static methods to manipulate current UOW instance (getCurrent(), 
newCurrent() etc,) must some how decide which implementation to use.

Markku

On 12/31/2012 06:06 PM, David Jencks wrote:

On Dec 31, 2012, at 7:57 AM, Markku Saarela wrote:


Hi,

Has Java EE spec any API to determine is code running in EJB or WEB container?

no.

Or is there any better way than examine stacktrace?

I'm imagining that you have some library or perhaps CDI code that is called 
from both a servlet and an ejb?  Why do you care?  Just to figure out why 
something is working the way it is, or do you need to take different action 
depending on what calls this code?  You could pass appropriate context 
information to the code in question from the caller.

david jencks


Rgds,

Markku




Re: How to determine in which container code is running?

2012-12-31 Thread Markku Saarela
My use case is to implement Martin Fowler's Domain Model enterprise 
design pattern with Unit Of Work and  Data Mapper.


This UOW does not work with ThreadLocal in every app server due to 
thread pooling.


So only solution to use different UOW storing mechanism in different layers;
session persistence in web container and pass UOW instance to the EJB 
container and store it to TransactionSynchronizationRegistry. Of course 
standalone Java client could use TrhreadLocal implementation.


In UOW static methods to manipulate current UOW instance (getCurrent(), 
newCurrent() etc,) must some how decide which implementation to use.


Markku

On 12/31/2012 06:06 PM, David Jencks wrote:

On Dec 31, 2012, at 7:57 AM, Markku Saarela wrote:


Hi,

Has Java EE spec any API to determine is code running in EJB or WEB container?

no.

Or is there any better way than examine stacktrace?

I'm imagining that you have some library or perhaps CDI code that is called 
from both a servlet and an ejb?  Why do you care?  Just to figure out why 
something is working the way it is, or do you need to take different action 
depending on what calls this code?  You could pass appropriate context 
information to the code in question from the caller.

david jencks


Rgds,

Markku




How to determine in which container code is running?

2012-12-31 Thread Markku Saarela

Hi,

Has Java EE spec any API to determine is code running in EJB or WEB 
container?


Or is there any better way than examine stacktrace?

Rgds,

Markku


[RESOLVED]Re: Geronimo not found at login subject for Jackrabbit JCA.

2008-11-10 Thread Markku Saarela
After removing   from geronimo-ra.xml and 
res-auth element from jackrabbit resource-ref in web.xml it works.


jackrabbit in my case is running in-vm so i remove any pooling.

Thanks to all for help.

- markku

ps. still my ultimate goal is to go for container managed security, so i 
look for code to realize that.


David Jencks wrote:


On Nov 8, 2008, at 2:27 AM, Markku Saarela wrote:


Here is configuration documentation:
http://jackrabbit.apache.org/jackrabbit-configuration.html#JackrabbitConfiguration-Securityconfiguration 



After read this documentation i thought that i do not need to use 
jaas, but now i realize that there is jaas available and in 
geronimo-ra.xml i found element  so i'm 
actually using container managed security.


So how to configure that (geronimo documentation is little bit 
confusing)?


I looked around the somewhat confusingly organized jackrabbit svn 
(j2ca stuff seems to be present only in branches???) and found 
http://svn.eu.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jca which 
seems like it might bear some resemblance to the code you are using.  
This code does not support container managed security at all.  Unless 
you want to add this capability to jackrabbit you need to stop 
configuring container managed security in your geronimo plan.


If you do want to add this capability to jackrabbit, the place to 
start is in 
http://svn.eu.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/JCAManagedConnectionFactory.java?annotate=703899 



162 :  public ManagedConnection 
createManagedConnection(Subject subject, ConnectionRequestInfo cri)

163 : throws ResourceException {
164 : dpfister 510465
165 : if (cri == null) {

166 : return new AnonymousConnection();
167 : }
168 : dpfister 230772 return 
createManagedConnection((JCAConnectionRequestInfo) cri);

169 : }


and

182 :  public ManagedConnection 
matchManagedConnections(Set set, Subject subject, 
ConnectionRequestInfo cri)

183 : throws ResourceException {
184 : for (Iterator i = set.iterator(); i.hasNext();) {
185 : Object next = i.next();
186 :
187 : if (next instanceof JCAManagedConnection) {
188 : JCAManagedConnection mc = (JCAManagedConnection) 
next;

189 : if (equals(mc.getManagedConnectionFactory())) {
190 : JCAConnectionRequestInfo otherCri = 
mc.getConnectionRequestInfo();

191 : if (equals(cri, otherCri)) {
192 : return mc;
193 : }
194 : }
195 : }
196 : }
197 :
198 : return null;

199 : }


where the Subject supplied from container managed security is ignored.

Out of curiousity, does jackrabbit run in-vm or are connections to a 
remote server?  If in-vm it might be better to run with pooling turned 
off as it is likely that creating a new managed connection is lighter 
weight than the synchronization involved in pooling existing connections.


thanks
david jencks






- markku

David Jencks wrote:
Could you point to some documentation on the JCARepositoryHandle  
and the ra.xml for this connector?


For container managed security you need to use something like the 
plugins/connector/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/security/CallerIdentityPasswordCredentialLoginModule.java 
which you can deploy in a JAAS configuration using the 
PasswordCredentialLoginModuleWrapperGBean.java


Since you are trying to supply the credentials in what appears to be 
a "get connection" call I wonder if you actually want container 
managed security?


thanks
david jencks


On Nov 7, 2008, at 11:17 PM, Markku Saarela wrote:


Hi,

Jackrabbit 1.4 (1.4.1 core)  JCA deployed to Geronimo 2.1.1. Web 
application or ejb session bean  failed with repository login. 
InitialContext lookup find Repository but calling repository.login( 
new SimpleCredentials( "system", "manager".toCharArray() ) ); 
method results exception:


Caused by: javax.resource.ResourceException: No subject for 
container managed security
at 
org.apache.geronimo.connector.outbound.SubjectInterceptor.getConnection(SubjectIntercepto 


r.java:51)
at 
org.apache.geronimo.connector.outbound.ConnectionHandleInterceptor.getConnection(Connecti 


onHandleInterceptor.java:43)
at 
org.apache.geronimo.connector.outbound.TCCLInterceptor.getConnection(TCCLInterceptor.java 


:39)
at 
org.apache.geronimo.connector.outbound.ConnectionTrackingInterceptor.getConnection(Connec 


tionTrackingInterceptor.java:66)
at 
org.apache.geronimo.connector.outbound.AbstractConnectionManager.allocateConnection(Abstr 


a

Re: Geronimo not found at login subject for Jackrabbit JCA.

2008-11-08 Thread Markku Saarela

Also i add Jackrabbit security realm with Geronimo console.

- markku

Markku Saarela wrote:
i debug further and figured out taht 
org.apache.geronimo.connector.outbound.GenericConnectionManagerGBean 
class has no subject, so how to inject one in it?


- markku

Ivan wrote:
Currently in Geronimo, we could not use JVM's JAAS configuration, for 
it is replaced with Geronimo's security realm.


2008/11/8 Markku Saarela <[EMAIL PROTECTED] 
<mailto:[EMAIL PROTECTED]>>


Here is configuration documentation:

http://jackrabbit.apache.org/jackrabbit-configuration.html#JackrabbitConfiguration-Securityconfiguration 



After read this documentation i thought that i do not need to use
jaas, but now i realize that there is jaas available and in
geronimo-ra.xml i found element  so
i'm actually using container managed security.

So how to configure that (geronimo documentation is little bit
confusing)?

- markku


David Jencks wrote:

Could you point to some documentation on the
JCARepositoryHandle  and the ra.xml for this connector?

For container managed security you need to use something like
the

plugins/connector/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/security/CallerIdentityPasswordCredentialLoginModule.java 


which you can deploy in a JAAS configuration using the
PasswordCredentialLoginModuleWrapperGBean.java

Since you are trying to supply the credentials in what appears
to be a "get connection" call I wonder if you actually want
container managed security?

thanks
david jencks


    On Nov 7, 2008, at 11:17 PM, Markku Saarela wrote:

Hi,

Jackrabbit 1.4 (1.4.1 core)  JCA deployed to Geronimo
2.1.1. <http://2.1.1.> Web application or ejb session bean
 failed with repository login. InitialContext lookup find
Repository but calling repository.login( new
SimpleCredentials( "system", "manager".toCharArray() ) );
method results exception:

Caused by: javax.resource.ResourceException: No subject
for container managed security
at

org.apache.geronimo.connector.outbound.SubjectInterceptor.getConnection(SubjectIntercepto 



r.java:51)
at

org.apache.geronimo.connector.outbound.ConnectionHandleInterceptor.getConnection(Connecti 



onHandleInterceptor.java:43)
at

org.apache.geronimo.connector.outbound.TCCLInterceptor.getConnection(TCCLInterceptor.java 



:39)
at

org.apache.geronimo.connector.outbound.ConnectionTrackingInterceptor.getConnection(Connec 



tionTrackingInterceptor.java:66)
at

org.apache.geronimo.connector.outbound.AbstractConnectionManager.allocateConnection(Abstr 



actConnectionManager.java:87)
at

org.apache.jackrabbit.jca.JCARepositoryHandle.login(JCARepositoryHandle.java:98) 




So how to configure Geronimo to provide subject to 
connector?


rgds,

Markku






--
Ivan






Re: Geronimo not found at login subject for Jackrabbit JCA.

2008-11-08 Thread Markku Saarela
i debug further and figured out taht 
org.apache.geronimo.connector.outbound.GenericConnectionManagerGBean 
class has no subject, so how to inject one in it?


- markku

Ivan wrote:
Currently in Geronimo, we could not use JVM's JAAS configuration, for 
it is replaced with Geronimo's security realm.


2008/11/8 Markku Saarela <[EMAIL PROTECTED] 
<mailto:[EMAIL PROTECTED]>>


Here is configuration documentation:

http://jackrabbit.apache.org/jackrabbit-configuration.html#JackrabbitConfiguration-Securityconfiguration

After read this documentation i thought that i do not need to use
jaas, but now i realize that there is jaas available and in
geronimo-ra.xml i found element  so
i'm actually using container managed security.

So how to configure that (geronimo documentation is little bit
confusing)?

- markku


David Jencks wrote:

Could you point to some documentation on the
JCARepositoryHandle  and the ra.xml for this connector?

For container managed security you need to use something like
the

plugins/connector/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/security/CallerIdentityPasswordCredentialLoginModule.java
which you can deploy in a JAAS configuration using the
PasswordCredentialLoginModuleWrapperGBean.java

Since you are trying to supply the credentials in what appears
to be a "get connection" call I wonder if you actually want
container managed security?

thanks
david jencks


    On Nov 7, 2008, at 11:17 PM, Markku Saarela wrote:

Hi,

Jackrabbit 1.4 (1.4.1 core)  JCA deployed to Geronimo
2.1.1. <http://2.1.1.> Web application or ejb session bean
 failed with repository login. InitialContext lookup find
Repository but calling repository.login( new
SimpleCredentials( "system", "manager".toCharArray() ) );
method results exception:

Caused by: javax.resource.ResourceException: No subject
for container managed security
at

org.apache.geronimo.connector.outbound.SubjectInterceptor.getConnection(SubjectIntercepto

r.java:51)
at

org.apache.geronimo.connector.outbound.ConnectionHandleInterceptor.getConnection(Connecti

onHandleInterceptor.java:43)
at

org.apache.geronimo.connector.outbound.TCCLInterceptor.getConnection(TCCLInterceptor.java

:39)
at

org.apache.geronimo.connector.outbound.ConnectionTrackingInterceptor.getConnection(Connec

tionTrackingInterceptor.java:66)
at

org.apache.geronimo.connector.outbound.AbstractConnectionManager.allocateConnection(Abstr

actConnectionManager.java:87)
at

org.apache.jackrabbit.jca.JCARepositoryHandle.login(JCARepositoryHandle.java:98)


So how to configure Geronimo to provide subject to connector?

rgds,

Markku






--
Ivan




Re: Geronimo not found at login subject for Jackrabbit JCA.

2008-11-08 Thread Markku Saarela

Here is configuration documentation:
http://jackrabbit.apache.org/jackrabbit-configuration.html#JackrabbitConfiguration-Securityconfiguration

After read this documentation i thought that i do not need to use jaas, 
but now i realize that there is jaas available and in geronimo-ra.xml i 
found element  so i'm actually using 
container managed security.


So how to configure that (geronimo documentation is little bit confusing)?

- markku

David Jencks wrote:
Could you point to some documentation on the JCARepositoryHandle  and 
the ra.xml for this connector?


For container managed security you need to use something like the 
plugins/connector/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/security/CallerIdentityPasswordCredentialLoginModule.java 
which you can deploy in a JAAS configuration using the 
PasswordCredentialLoginModuleWrapperGBean.java


Since you are trying to supply the credentials in what appears to be a 
"get connection" call I wonder if you actually want container managed 
security?


thanks
david jencks


On Nov 7, 2008, at 11:17 PM, Markku Saarela wrote:


Hi,

Jackrabbit 1.4 (1.4.1 core)  JCA deployed to Geronimo 2.1.1. Web 
application or ejb session bean  failed with repository login. 
InitialContext lookup find Repository but calling repository.login( 
new SimpleCredentials( "system", "manager".toCharArray() ) ); method 
results exception:


Caused by: javax.resource.ResourceException: No subject for container 
managed security
 at 
org.apache.geronimo.connector.outbound.SubjectInterceptor.getConnection(SubjectIntercepto 


r.java:51)
 at 
org.apache.geronimo.connector.outbound.ConnectionHandleInterceptor.getConnection(Connecti 


onHandleInterceptor.java:43)
 at 
org.apache.geronimo.connector.outbound.TCCLInterceptor.getConnection(TCCLInterceptor.java 


:39)
 at 
org.apache.geronimo.connector.outbound.ConnectionTrackingInterceptor.getConnection(Connec 


tionTrackingInterceptor.java:66)
 at 
org.apache.geronimo.connector.outbound.AbstractConnectionManager.allocateConnection(Abstr 


actConnectionManager.java:87)
 at 
org.apache.jackrabbit.jca.JCARepositoryHandle.login(JCARepositoryHandle.java:98) 



So how to configure Geronimo to provide subject to connector?

rgds,

Markku






Geronimo not found at login subject for Jackrabbit JCA.

2008-11-07 Thread Markku Saarela

Hi,

Jackrabbit 1.4 (1.4.1 core)  JCA deployed to Geronimo 2.1.1. Web 
application or ejb session bean  failed with repository login. 
InitialContext lookup find Repository but calling repository.login( new 
SimpleCredentials( "system", "manager".toCharArray() ) ); method results 
exception:


Caused by: javax.resource.ResourceException: No subject for container 
managed security
  at 
org.apache.geronimo.connector.outbound.SubjectInterceptor.getConnection(SubjectIntercepto 


r.java:51)
  at 
org.apache.geronimo.connector.outbound.ConnectionHandleInterceptor.getConnection(Connecti 


onHandleInterceptor.java:43)
  at 
org.apache.geronimo.connector.outbound.TCCLInterceptor.getConnection(TCCLInterceptor.java 


:39)
  at 
org.apache.geronimo.connector.outbound.ConnectionTrackingInterceptor.getConnection(Connec 


tionTrackingInterceptor.java:66)
  at 
org.apache.geronimo.connector.outbound.AbstractConnectionManager.allocateConnection(Abstr 


actConnectionManager.java:87)
  at 
org.apache.jackrabbit.jca.JCARepositoryHandle.login(JCARepositoryHandle.java:98) 



So how to configure Geronimo to provide subject to connector?

rgds,

Markku