RE: Cannot override security annotations

2009-01-12 Thread Marcin Kwapisz
Hi,

  I think this property should be set in System, not in InitialContext.
 
  System
  .setProperty(log4j.category.OpenEJB.startup.attributes,DEBUG);
 
 I'm not sure if you're stating a preference or reporting that setting
 via InitialContext didn't work.  Both approaches should work in the
 current release.

[Marcin Kwapisz] 
p.setProperty(log4j.category.OpenEJB.startup.attributes, DEBUG);
ctx = new InitialContext(p);

It does not work. That’s why I have set that value as a system property.

 We achieve this by translating the annotation into their *exact* xml
 equivalent and processing them together as if everything had been
 declared in xml.

[Marcin Kwapisz] 
Thanks David for very extensive and exhaustive explanation. More precise method 
description helps to override the security annotation. Glassfish accepts such 
deployment descriptor also so there is no problem now. I am curious how other 
application servers process security annotations and if OpenEJB is 
distinguished by that.
I take as a common rule that any value set in a deployment descriptor overrides 
an annotation value. I think, that rule comes from JEE specification so I was a 
little surprised when it did not work in OpenEJB.

Best regards
-- 
Marcin Kwapisz
Division of Computer Networks
Technical Univeristy of Lodz, Poland





RE: Cannot override security annotations

2009-01-08 Thread Marcin Kwapisz
Hi David,

I think this property should be set in System, not in InitialContext.

System.setProperty(log4j.category.OpenEJB.startup.attributes,DEBUG);

Scenario 1.
--EJB--
@RolesAllowed({StudentAdmin})
public void createStudent
--EJB--

--ejb-jar.xml--
assembly-descriptor
security-role
role-nameSysAdmin/role-name
/security-role
method-permission
role-nameSysAdmin/role-name
method
ejb-nameStudentEndpoint/ejb-name
method-namecreateStudent/method-name
/method
/method-permission
--ejb-jar.xml--

DEBUG - Security Attribute: public void 
pl.zsk.sos.ejb.endpoint.StudentEndpointBean.createStudent(pl.zsk.sos.dto.StudentDTO,pl.zsk.sos.dto.AccountDTO)
 throws pl.zsk.sos.exception.StudentException -- StudentEndpoint : * : 
pl.zsk.sos.ejb.endpoint.StudentEndpointBean : 
createStudent(pl.zsk.sos.dto.StudentDTO, pl.zsk.sos.dto.AccountDTO) 
StudentAdmin  

Scenario 2.
ejb-jar.xml unchanged
RolesAllowed annotation is commented in createStudent as follows
--EJB--
//@RolesAllowed({StudentAdmin})
public void createStudent
--EJB--

DEBUG - Security Attribute: public void 
pl.zsk.sos.ejb.endpoint.StudentEndpointBean.createStudent(pl.zsk.sos.dto.StudentDTO,pl.zsk.sos.dto.AccountDTO)
 throws pl.zsk.sos.exception.StudentException -- StudentEndpoint : * : * : 
createStudent(*) SysAdmin

Regards
-- 
Marcin Kwapisz
Division of Computer Networks
Technical Univeristy of Lodz, Poland



Maven and OpenEJB unit testing

2008-12-08 Thread Marcin Kwapisz
Hi.

My ejb module (PersonAccountModule) depends on ejb facade components in 
different project (EJBFacades). So I had to configure classpath as follows:

p.put(openejb.deployments.classpath.include, 
.*/(PersonAccountModule|EJBFacades)/target/classes.*);

ejb-jar.xml in PersonAccountModule is not empty.

All unit tests work fine, but log looks rather strange. I do not understand the 
third line below. Why openejb takes jar from my local repository and doesn't 
take classes from target/classes folder as specified in classpath.include 
pattern?

INFO - Found EjbModule in classpath: 
D:\JavaProg\MySamples\EJB\Samplev7\JEEMavenProject2\PersonAccountModule\target\classes
INFO - Found EjbModule in classpath: 
D:\JavaProg\MySamples\EJB\Samplev7\JEEMavenProject2\PersonAccountModule\target\test-classes
INFO - Found EjbModule in classpath: e:\Profiles\Marcin 
Kwapisz\.m2\repository\zsk\samples\EJBFacades\1.0-SNAPSHOT\EJBFacades-1.0-SNAPSHOT.jar

Regards
-- 
Marcin Kwapisz
Division of Computer Networks
Technical Univeristy of Lodz, Poland




RE: Override annotations in ejb-jar.xml for a test case

2008-10-09 Thread Marcin Kwapisz
Hi,

 We don't have any functionality for supplying an alternate ejb-jar.xml
 for testing purposes.  It's not a bad idea and is something we might
 be able to add after we get the 3.1 release out the door.

[Marcin Kwapisz] 
My Maven2 profile is as follows. resource directs to folder 
src/test/resources/Toplink (METAINF) where modified ejb-jar.xml and 
persistence.xml exist.
profile
idTestEJB_Toplink/id
activation
property
nameenv/name
valuetesttoplink/value
/property
/activation
dependencies
dependency
groupIdtoplink.essentials/groupId
artifactIdtoplink-essentials-agent/artifactId
version2.1-53/version
scopetest/scope
/dependency
dependency
groupIdtoplink.essentials/groupId
artifactIdtoplink-essentials/artifactId
version2.1-53/version
scopetest/scope
/dependency
dependency
groupIdzsk.samples/groupId
artifactIdToplinkExternalContainer/artifactId
version1.0/version
scopetest/scope
/dependency
/dependencies
build
resources
resource
directorysrc/test/resources/Toplink/directory
/resource
/resources
/build
/profile

 This might be because the ejb-jar.xml is with the ejbs that are
 annotated.
[Marcin Kwapisz] 
Correct me if I am wrong: when ejb-jar is empty OpenEJB process all class files 
(in classes and test-classes) and looks for annotated EJBs. When ejb-jar is 
modified, OpenEJB process that file and looks for annotated EJBs in 
test-classes only.

Regards
-- 
Marcin Kwapisz
Division of Computer Networks
Technical Univeristy of Lodz, Poland





RE: Rollback transactions in unit testing

2008-10-02 Thread Marcin Kwapisz
 Marcin,
 the strategy you suggest should also work and is especially good for
 prototyping or smaller projects.
 
 In our case where we have a huge application with (1.5 Mio LoC,  1000
 EJBs,  100 database tables with complex relationships) we cannot drop
 (or
 empty) and create tables in junit tests. This would heavily impact the
 development and testing.
 this is the reason why in such cases a rollback after a unit test
 instead of
 makes sense.
[Marcin Kwapisz] 
I know. That's why we run as many unit tests as it is possible between server 
startup and shutdown.
But how to properly test transaction without committing it? (The link in 
Glauber Ferreira's post concerns testing transactions).
Can I rollback transaction that has been committed? We do not use BMT in our 
project.

We tried to create unit test that in one transaction (CMT not BMT):
1. Creates initial set of data
2. Calls business method to modify/remove/(etc.) entities
3. Checks results.
And that was not a good idea. The results of unit tests depended on JPA 
provider (or JPA settings), sometimes passed or sometimes not (the same test - 
that was really crazy). Manual flushing did not helped. We had to split that 
one transaction into three to make unit tests work properly.

Regards
-- 
Marcin  Kwapisz
Samodzielny Zakład Sieci Komputerowych
Politechnika Łódzka





RE: Rollback transactions in unit testing

2008-09-30 Thread Marcin Kwapisz
[Marcin Kwapisz] 
I do not understand why you want to rollback committed transaction, especially 
in unit test. Even, I do not know how to do it in JEE application. 
Maybe our way will suit you:

1. set drop and create strategy in persistence.xml (property name depends on 
JPA provider, we have separate file for unit testing)
2. Start OpenEJB (for example: perform ejb lookup) - database should be empty 
now
3. Create initial set of data in tables
4. Run test
5. Shutdown OpenEJB

Now, you can repeat steps 2-5 for another tests

Regards
-- 
Marcin Kwapisz
Division of Computer Networks
Technical Univeristy of Lodz, Poland






RE: Unit tests for concurrent transactions

2008-09-09 Thread Marcin Kwapisz
Great, thanks for the example. We will try to prepare unit tests for concurrent 
transactions definitely (and publish as an solution/example).

[Marcin Kwapisz] 
Best regards
-- 
Marcin Kwapisz
Division of Computer Networks
Technical Univeristy of Lodz, Poland






Unit tests for concurrent transactions

2008-09-08 Thread Marcin Kwapisz
Hi,
I would like to make unit tests for concurrent transactions, for example to 
check optimistic locking.
Is it possible to perform such tests with embedded OpenEJB? If the answer is: 
yes, how can I control the order of operations in two concurrent transactions.

Thanks in advance
Regards
-- 
Marcin Kwapisz
Division of Computer Networks
Technical Univeristy of Lodz, Poland




RE: Configuring hibernate properties in unit tests

2008-09-02 Thread Marcin Kwapisz
 Thanks for the link, this post doesn't look to be able to help me with
 runtime configuration of hibernate properties though, looks like its
 not
 possible so I will settle for seperate persistence.xml files.
 
[Marcin Kwapisz] 
Maybe I misunderstood something. You want to set persistent.xml properties in 
your test code. Look carefully at setUpClass method. There are properties set 
for toplink JPA, but I think you can replace them with properties for hibernate 
easily.
The only thing I don't know is which properties are more important: those 
placed in persistent.xml or in test code.

Regards
-- 
Marcin Kwapisz
Division of Computer Networks
Technical Univeristy of Lodz, Poland





RE: Configuring hibernate properties in unit tests

2008-08-31 Thread Marcin Kwapisz
I think that blog entry can be useful. 
http://qbeukes.blogspot.com/2008/08/toplink-as-your-openejb-persistence.html

Regards
-- 
Marcin Kwapisz
Division of Computer Networks
Technical Univeristy of Lodz, Poland

 Hi,
 
 I'm using openejb with hibernate for unit tetsting my EJBs and I'm
 running
 into problems with persistence.xml. I am using a different hibernate
 dialect
 in these particular tests to my production code (because I'm using the
 HSQL
 in memory database for testing but MySQL for production) and I can't
 find
 any way to change the hibernate.dialect property other than by using a
 different persistence.xml in the test.
 
 I already ran into this problem once with the TransactionManagerLookup
 property and solved it using the suggestion
 http://openejb.apache.org/3.0/hibernate.html here  but I don't want to
 take
 this approach for every property, and besides it wouldn't even be
 appropriate for some.
 
 Basically I am asking if there is a way of programmatically setting
 hibernate properties or whether I should stick to using different
 versions
 of persistence.xml
 
 Incidentally I have had a good look through the forums and googled
 extensively (cue someone finding the answer with their first search) :)
 and
 I am no kind of expert so I expect I have just missed something obvious
 somewhere.
 
 Thanks in advance
 
 
 
 --
 View this message in context: http://www.nabble.com/Configuring-
 hibernate-properties-in-unit-tests-tp19167232p19167232.html
 Sent from the OpenEJB User mailing list archive at Nabble.com.



RE: OpenEJB, Maven and Hibernate problem

2008-08-21 Thread Marcin Kwapisz
 Also, we have an OpenEJB, Maven, Hibernate example here that may
 help.
 http://svn.apache.org/repos/asf/openejb/trunk/openejb3/examples/jpa-
 hibernate/
[Marcin Kwapisz] 
Hi,
After a little investigation I am almost sure that the problem is with 
hibernate, not within OpenEJB. Hibernate cannot find (it should create) table 
PERSONENT (from annotation @SecondaryTable
(name=PERSONENT,[EMAIL PROTECTED](name= ID)}) that why OpenEJB does not 
register my EJBs and I get lookup errors then. The only confusing thing was:
org.apache.openejb.OpenEJBException: createApplication.failed 
[D:\JavaProg\MySamples\EJB\Sample5\JEEMavenProject2\EjbServiceCore\target\classes]:
 null

but when I have updated Hibernate to version 3.2.6 and hibernate-entitymanager 
to 3.3.2, I get:

org.apache.openejb.OpenEJBException: createApplication.failed 
[D:\JavaProg\MySamples\EJB\OLD\JEEMavenProject2\EjbServiceCore\target\classes]: 
org.hibernate.AssertionFailure: Table PERSONENT not found. 

I think this is the right exception.

Regards
-- 
Marcin Kwapisz
Division of Computer Networks
Technical Univeristy of Lodz, Poland






OpenEJB, Maven and Hibernate problem

2008-08-20 Thread Marcin Kwapisz
activation
property
nameenv/name
valuetesttoplink/value
/property
/activation
dependencies
dependency
groupIdtoplink.essentials/groupId
artifactIdtoplink-essentials-agent/artifactId
version2.1-SNAPSHOT/version
scopetest/scope
/dependency
dependency
groupIdtoplink.essentials/groupId
artifactIdtoplink-essentials/artifactId
version2.1-SNAPSHOT/version
scopetest/scope
/dependency
dependency
groupIdzsk.samples/groupId
artifactIdToplinkExternalContainer/artifactId
version1.0/version
scopetest/scope
/dependency
/dependencies
build
resources
resource
directorysrc/test/resources/Toplink/directory
/resource
/resources
/build
/profile
/profiles
dependencies
dependency
groupIdorg.apache.openejb/groupId
artifactIdopenejb-core/artifactId
version3.0/version
scopetest/scope
/dependency
dependency
groupIdorg.apache.openejb/groupId
artifactIdjavaee-api/artifactId
version5.0-1/version
scopeprovided/scope
/dependency
dependency
groupIdorg.apache.derby/groupId
artifactIdderby/artifactId
version10.2.2.0/version
scopetest/scope
/dependency
dependency
groupIdorg.apache.derby/groupId
artifactIdderbyclient/artifactId
version10.2.2.0/version
scopetest/scope
/dependency
dependency
groupIdjunit/groupId
artifactIdjunit/artifactId
version4.1/version
scopetest/scope
/dependency
dependency
groupIdzsk.samples/groupId
artifactIdDataObjects/artifactId
version2.3/version
scopecompile/scope
/dependency
/dependencies
build
plugins
plugin
groupIdorg.apache.maven.plugins/groupId
artifactIdmaven-dependency-plugin/artifactId
executions
execution
idcopy/id
phaseprocess-resources/phase
goals
goalcopy/goal
/goals
configuration
artifactItems
artifactItem
groupIdzsk.samples/groupId
artifactIdDataObjects/artifactId
version2.3/version
typejar/type

outputDirectory${project.build.directory}/classes/outputDirectory
/artifactItem
/artifactItems
/configuration
/execution
/executions
/plugin
plugin
artifactIdmaven-compiler-plugin/artifactId
version2.0.2/version
configuration
source1.5/source
target1.5/target
encodingUTF-8/encoding
/configuration
/plugin
plugin
artifactIdmaven-resources-plugin/artifactId
version2.2/version
configuration
encodingUTF-8/encoding
/configuration
/plugin
plugin
groupIdorg.apache.maven.plugins/groupId
artifactIdmaven-ejb-plugin/artifactId
configuration
archive
manifest
addClasspathtrue/addClasspath
/manifest
/archive
generateClienttrue/generateClient
clientIncludes !--Dołącz do klienta tylko zdalne 
interfejsy--

clientIncludezsk/samples/EjbService/*Remote.class/clientInclude
/clientIncludes
ejbVersion3.0/ejbVersion
/configuration
/plugin
/plugins
/build
properties
netbeans.hint.deploy.serverJ2EE/netbeans.hint.deploy.server
/properties
/project

Thanks in advance
Regards
-- 
Marcin Kwapisz
Division of Computer Networks
Technical Univeristy of Lodz, Poland




RE: OpenEJB, Maven and Hibernate problem

2008-08-20 Thread Marcin Kwapisz
Hi,

I tried to reproduce the problem with Hibernate and OpenEJB. 

The previous message in the log file was:
 org.apache.openejb.OpenEJBException: createApplication.failed
 [D:\JavaProg\MySamples\EJB\Sample5\JEEMavenProject2\EjbServiceCore\targ
 et\classes]: null

Now I get:
org.apache.openejb.OpenEJBException: createApplication.failed 
[D:\JavaProg\MySamples\EJB\OLD\JEEMavenProject2\EjbServiceCore\target\classes]: 
org.hibernate.AssertionFailure: Table PERSONENT not found: Table PERSONENT not 
found

In that case the problem is with annotation processing and database schema 
creation:
@Entity
@Table(name=ACCOUTENT)
@Inheritance(strategy=InheritanceType.JOINED)
@DiscriminatorColumn(name=typ, discriminatorType=DiscriminatorType.STRING)
@SecondaryTable(name=PERSONENT,[EMAIL PROTECTED](name= ID)})
public class PersonAccountEnt implements Serializable

I found that inheritance JOINED and SecondaryTable does not work with 
Hibernate. So the problem is not with OpenEJB (I think).

I don’t know why I get null in original project. Can it be the same problem 
or a different one?

Regards
-- 
Marcin Kwapisz
Division of Computer Networks
Technical Univeristy of Lodz, Poland





RE: Propblem with OpenEJB + Toplink unit tests

2008-08-04 Thread Marcin Kwapisz
 It may be that TopLink doesn't know how to find our
 TransactionManager.  OpenJPA finds it automatically by calling
 org.apache.openejb.OpenEJB.getTransactionManager().  For Hibernate,
 there's the TransactionManagerLookup which can be configured.  Do you
 know if there's anything similar in TopLink?
 
[Marcin Kwapisz] 
Thanks David for the hint.

There is such feature and similar problem (solution also) is described here:
http://forums.oracle.com/forums/thread.jspa?threadID=625250tstart=0messageID=2390496
and here:
http://www.jroller.com/guruwons/entry/use_glassfish_java_persistence_provider

The only one thing I had to find was TransactionManager jndi name: 
java:comp/TransactionManager

public class OpenEJBTransactionController extends JTATransactionController
{

public static final String JNDI_TRANSACTION_MANAGER_NAME = 
java:comp/TransactionManager;

public OpenEJBTransactionController()
{
super();
}

@Override
protected TransactionManager acquireTransactionManager() throws Exception
{
return (TransactionManager) jndiLookup(JNDI_TRANSACTION_MANAGER_NAME);
}
}

and in persistence.xml

property name=toplink.target-server 
value=pl.zsk.samples.ejbservice.OpenEJBTransactionController/

Regards
-- 
Marcin Kwapisz
Division of Computer Networks
Technical Univeristy of Lodz, Poland