Tim Storms

Ranch Hand
+ Follow
since Apr 27, 2006
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 Tim Storms

Hi Ran,

Thanks for your reply. You object structure suggestion seems to be better than mine. I've quickly created the new model classes. This is what they look like:





The attachment contains the generated database schema.
Do you still see some improvements, or is it fine as it is?
Hi ranchers,

I'm struggeling with a mapping strategy for a couple of entities. Note that I'm using JPA 2.0 and Hibernate 3.5.6. The application serves as a learing app for this frameworks. This is the scenario I've implemented:

- a person can be an actor or a director
- both of the previous types can participate in one or multiple (different) movies
- a movie can include one or multiple actors and one or more directors
- and what's giving me a headache: an actor and a director can be one and the same person!

This is what my mapping is looking like:





I've not included the getters and setters, plus the builder classes to easily create a director or an actor. Just for now, suppose I've created an actor like this:

As this is the first entity to be saved, an identifier with value 1 will be generated. Now here comes the part I'm struggling with. This actor should also be known as an director of several other movies. The (dirty) solution I was thinking about, was to copy all the values of the actor into the director, including the identifer. But because the identifier is auto generated when an entity is persisted, the given identifier will be overridden by a new generated id. Thus the director and the actor are two different persons in the database. Does anyone know a clean sollution for this? Should I map my entities differently? Should I choose another id generation strategy? Thanks for sharing your thoughts!
Guys,

I'm very comfused about some concepts. I've listed them below and I would like to know whether everything I state is correct. There are also a few questions listed. I would really appreciate your inputs!

CONTAINER-MANAGED TRANSACTION-SCOPED ENTITYMANAGER
- Uses JTA for transaction management (single or extended)
- Created with @PersistenceContext(type=TRANSACTIONAL/EXTENDED)
- The transactional persistence context begins when the EntityManager is invoked in the scope of an active JTA transaction, and there is no persistence context currently associated with the transaction
- The transactional persistence context ends when the JTA transaction commits or rolls back (so entities become detached)
- When there is no transaction available, a new temporary persistence context will be created upon a method invocation (e.g. entityManager.find())
- An extended persistence context can only be used in stateful beans. The extended persistence context exists from the point a stateful bean declared an EntityManager. The extended persistence context is maintained during the entire lifecycle of the bean. This means that all returned entities are always in an attached (managed) state.
- An extended persistence context is closed when the @Remove annotated method has ended

APPLICATION-MANAGED TRANSACTION-SCOPED ENTITYMANAGER
- Uses JTA for transaction management (always extended, so single is not possible??)
- Created with @PersistenceUnit

APPLICATION-MANAGED RESOURCE-LOCAL ENTITYMANAGER
- Uses EntityTransaction for transaction management
- Created with @PersistenceUnit

COMMON PROPERTIES FOR APPLICATON-MANAGED ENTITYMANAGERS
- All application-managed persistence contexted are extended in scope, and therefore may span multiple transactions. An extended persistence context exists from the moment the EntityManager is created and ends when entityManager.close() is called.
- You should call entityManager.close() when you want to release the peristence context. After you've invoked this method, you can only call isOpen() and getTransaction() or you will get an IllegalStateException. If entityManger.close() within an active transaction, the persistence context will remain managed until the transaction completes.
- An extended persistence context obtained from an application-managed EntityManager is a stand-alone persistence context; it will never be propagated.
- When a JTA application-managed EntityManager is used, if the EntityManager is created outside the scope of the current JTA transaction, it is the responsiblity of the application to associate the EntityManager with the transaction by calling entityManager.joinTransaction().

USERTRANSACTION
- Only to be used in session beans (or MDB's) with BMT.
- When to use EntityTransaction of UserTransaction? When a bean is CMT, we should use EntityTransaction and when it's BMT, we should use UserTransaction. Is this statement correct??
You should not read the Head First EJB book. It only covers EJB 2.1! EJB3 in action is a fine suggestion indeed.
Thanks for your reply, but can you elaborate on this? Isn't this XML configuration already taken care of in my annotations? Also I don't need to configure a realm, but a security domain.

Thanks for the info!
I'm trying to secure a web service which is an EJB. I'm trying to accomplish this by adding the following jboss.xml in the META-INF folder.

As you can see, this EJB is the only EJB that should be "behind" a security domain. I tried doing this with the SecurityDomain annotation on my EJB, but it gave me a nullpointer in my Seam application on deployment.

Now, this web service is indeed protected by this security domain. So far, so good. But now it seams that the rest of my application is also trying to pass this security domain. What am I forgetting here, or what am I doing wrong?

Btw, my EJB is annotated with the following annotations:
These are my imports regarding EJB's/Web Services:



The imports should be fine I guess.
12 years ago
Guys, any help on this?

I've managed to get this thing working in a very small dummy application but this problem is still occuring in my companies application. It's a seam application running on JBoss 4.2.3. Could seam somehow be causing this nullpointer?

I've also posted this problem on https://coderanch.com/t/457907/JBoss/HTTP-authentication-accessing-WSDL because I don't really know where to put his problem. Sorry for the duplication!

This is the dependency I use to get the EJB's working:
12 years ago
Guys, any help on this?

I've managed to get this thing working in a very small dummy application but this problem is still occuring in my companies application. It's a seam application running on JBoss 4.2.3. Could seam somehow be causing this nullpointer?

This is the dependency I use to get the EJB's working:
12 years ago
Hi,

I've got the org.jboss.annotation.security.SecurityDomain annotation on my web service class. I do this to reach the application policy in login-config.xml of jboss 4.2.3.

So my annotation:

And my login-config.xml:

On deployment of my EAR file, I always get a Nullpointer:


Does anyone have any idea why this happens? I've been looking for more then 10 hours, so all your help is much appreciated!

Btw, RoleBasedAuthorizationInterceptorFactory.java:49 is this:
12 years ago
Hi,

I'm trying to use HTTP authenitication when my WSDL is accessed. Authetication should only happen on user/pass and not on roles. During deploy time, I'm getting the following stacktrace in my JBoss 4.2.3:

I've looked into the source of the RoleBasedAuthorizationInterceptorFactory and on line 49, the following happens:

This could mean that the "securityAnnotation" variable, which is the SecurityDomain annotation of my web service, is not gathered.
These are my annotations in my web service class:

In the web.xml of my web app, I've configured the following:

My Jboss login-config.xml contains:

The props/jbossws-users.properties file exists.
I've also tried the approach given on http://jbossws.jboss.org/mediawiki/index.php?title=Authentication, but without any result.
Tips, hints, etc. are very welcome!
12 years ago
Does it make any sense for me to go for the 256 exam because I already have a SCWCD certificate? Does it have much added value? Otherwise I'd better choose the 255 exam.

Also, are there any books about these exams available? (except IBM's redbook)

Thanks again!
Hi Ranchers,

As a SCJP and SCWCD, I would like to go for a product certification. The IBM 255 and 256 exams caught my eye. Can somebody tell me (out of experience) what the biggest differences are between them and which one would suit me best (I'm a web developer)?

Some advice about books/tools for the exam preparation are also appreciated. ;-)

Thanks!
That's a great score Rancy! Congrats!

Sun sometimes adds an extra question for test purposes (so they can see if they could include this question in a future exam verson). Your answer on that question is not included in the final score. Don't bother!
Wow, that was more than I expected!

The things I used to prepare for the exam:
- "Off course" the HFSJ book. Almost, yes ALMOST, everything you need for the exam is in there. I got 74% on the final mock exam, so the 20% rule almost applies here.
- Bought the Whizlabs SCWCD simulator. It provides good questions and more difficult exams then the real one. Though, I was a bit dissapointed with this product. It contains quite a lot of errors, not all grammar mistakes, but also wrong code examples etc. This product needs an urgent update!
- Did a couple of small mock exams on the internet.

In my opinion the exam was not that hard and does not go as much in detail as I expected. Don't get me wrong, you still need to study a lot to make a good score!

Final note: This calls for a celebration!