[JBoss Seam] - Re: Basic Seam questions
by lightbulb432
I have made a simple example below that doesn't seem to be working. It creates an entity (Person) over two independent JSF action methods:
@Stateful
| @Name("register")
| public class RegisterBean implements Register {
|
| @PersistenceContext(type=EXTENDED)
| private EntityManager em;
|
| @In(create=true) @Out
| private Person person;
|
| private String firstName;
| private String lastName;
|
| public String firstName() {
|
| person.setFirstName(getFirstName());
|
| em.persist(person);
|
| return "success";
|
| }
|
| public String lastName() {
|
| person.setLastName(getLastName());
|
| em.merge(person);
|
| return "success";
|
| }
|
| @Remove
| @Destroy
| public void destroy() {
|
| }
|
| }
I have a few questions on this example, but first, am I doing this correctly? Do I have the persist() and merge() in the correct places? Or should I remove the persist() and merge() and just have one persist() in lastName() - assuming lastName() is the second method to be called?
Is an EXTENDED persistence context correct here?
I'm getting an error in the second method, saying that "Exception during INVOKE_APPLICATION(5): javax.persistence.PersistenceException: org.hibernate.PropertyValueException: not-null property references a null or transient value: "
Here's the problem. When I call the firstName() method, followed by the lastName() method, the lastName() method seems to create a brand new Person. This Person gets a lastName, does not pick up the firstName from the previous method invocation, and triggers a PropertyValueException because of the validation annotation on the entity...whoa!
What am I doing wrong? Any help would be greatly appreciated. Thanks.
P.S. I don't call the destroy() method anywhere in the code at all. And, while I define destroy in the business interface, I don't define the annotations there...should I?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3993733#3993733
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3993733
19 years, 4 months
[Security & JAAS/JBoss] - Re: User credentials lost after remote EJB call
by annie1234
I have tried this with SP1 & with 4.0.5GA as suggested and still encountered the same problem.
Just to clarify:
Before we make the remote call, we can see the original user:
org.jboss.security.SecurityAssociation.pushSubjectContext,subject=Subject: Principal:AdminPrincipal:Roles(members:Admin),sc=org.jboss.security.SecurityAssociation$SubjectContext@1dadaa{principal=Admin,subject=7645779}
org.jboss.security.SecurityAssociation.getSubject,sc=org.jboss.security.SecurityAssociation$SubjectContext@1dadaa{principal=Admin,subject=7645779}
And then when we make the remote call, we can see the remote user being setup:
org.jboss.security.SecurityAssociation.setCredential,sc=org.jboss.security.SecurityAssociation$SubjectContext@1bb7285{principal=null,subject=null}
org.jboss.security.SecurityAssociation.setPrincipal,p=remoteAdmin,server=true
org.jboss.security.SecurityAssociation.setPrincipal,sc=org.jboss.security.SecurityAssociation$SubjectContext@1bb7285{principal=remoteAdmin,subject=null}
org.jboss.security.SecurityAssociation.getPrincipal,principal=remoteAdmin
And then we see the original security logs I posted before.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3993731#3993731
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3993731
19 years, 4 months
[JNDI/Naming/Network] - java.lang.ClassNotFoundException: org.jnp.interfaces.NamingC
by forumer
JBoss 4.0.4-CR2, EJB 3.0
I have a client which accesses EJB's successfully when I create the InitialContext as follows:
| ctx.addToEnvironment("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
| ctx.addToEnvironment("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
| ctx.addToEnvironment(Context.PROVIDER_URL,"jnp://localhost:1099");
|
|
|
However, if I place these properties in a jndi.properties file, instead, under a folder and include this folder in the classpath
|
| java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
| java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
| java.naming.provider.url=jnp://localhost:1099
|
|
I get the error:
|
| javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory ]
| at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
| at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
| at javax.naming.InitialContext.init(InitialContext.java:223)
| at javax.naming.InitialContext.<init>(InitialContext.java:175)
|
|
I'd like to use a jndi.properties file instead of doing it in the code.
I'd appreciate any suggestions on why this might be happening.
Thanks
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3993730#3993730
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3993730
19 years, 4 months