[JBoss Seam] - Re: the TransientObjectException with <s:convertEntity />
by filosganga
So, I discovered some problem:
The view presentation appened in a different hibernate session. if i use a stateless bean to load the selectItems entities, using the EntityManager component of Seam, it work fine.
But I have my Daos Stateless EJB, and if i use them i receive same error.
Anyone can help me?
This is the correct code:
| @Name("gruppoService")
| @Scope(ScopeType.STATELESS)
| @Stateless
| public class GruppoServiceBean implements GruppoServiceLocal {
|
| private AccountManager accountManager;
|
| /**
| *
| */
| public GruppoServiceBean() {
| // Empty
| }
|
| @EJB
| public void setAccountManagerLocal(AccountManagerLocal accountManagerLocal){
| this.accountManager = accountManagerLocal;
| }
|
| @SuppressWarnings("unchecked")
| public List<Gruppo> listGruppi(){
| Query query = entityManager.createQuery("from Gruppo as gruppo");
|
| return (List<Gruppo>)query.getResultList();
|
| }
|
| }
|
While this code cause Error. The AccountManager is a Stateless EJB.
| @Name("gruppoService")
| @Scope(ScopeType.STATELESS)
| @Stateless
| public class GruppoServiceBean implements GruppoServiceLocal {
|
| private AccountManager accountManager;
|
| /**
| *
| */
| public GruppoServiceBean() {
| // Empty
| }
|
| @EJB
| public void setAccountManagerLocal(AccountManagerLocal accountManagerLocal){
| this.accountManager = accountManagerLocal;
| }
|
| @SuppressWarnings("unchecked")
| public List<Gruppo> listGruppi(){
| return accountManager.listGruppi();
| }
|
| }
|
I've set this property on persistence.xml:
and my components.xml:
<persistence:managed-persistence-context name="entityManager"
auto-create="true"
persistence-unit-jndi-name="java:/EntityManagerFactories/siccr" />
It's right?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4085369#4085369
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4085369
18 years, 10 months
[JBoss Seam] - Re: Wannabe-Example needs help growing up
by stephen.friedrich
Thanks Pete for the quick answer! It helps somewhat, but still I don't really know how to make use of conversations.
If you could stay with me for a while that would be great! I will really try to come up with a helpful example in the end.
1) Deletion problem
You suggested calling both setInstance(null); and setId(null); in the remove method of the employee home.
That did not help. After some late night debugging I found out that page param should be read literally. The employee id is stored in Seam's page context whenever an employee is selected. It stays there if the employee is deleted, so the next creation of a new EmployeeHome will dutifully transfer it again.
Adding this in remove() helps: Contexts.getPageContext().remove("groupId");
I would prefer not to hard code parameter names in Java, though.
Of course you do not have this particular problem when you use separate pages for listing of employees and and the employee details (and only have a delete button on the details page).
It would help if the doc made it clear that page params are in fact stored in the page context. Currently all I read is "request parameter is transfered to the model according to the page param definition in pages.xml".
2) Page params vs. request params vs. DataModelSelection
Turns out in seampay the @RequestParameter field is really needed.
seampay uses two different ways to transfer an id parameter to a home object:
Account home uses the page param method. Payment home uses @RequestParameter and overrides the base class's getId() to return the id from the parameter.
An additional option would be to use neither page params nor request parameters, but to use @DataModel/@DataModelSelection (like the "clickable list" messages example does).
How should I decide which method to use?
2) Conversation scoped query result
You're right it really feels strange to update the query's result list directly.
However I do not want to refresh all entities because a single, unrelated entity has been created.
I could either wrap the query in a conversation scoped component of my own and outject a List from that component (again pretty much like the MessageManagerBean in the messages example).
(That way it wouldn't be so strange to add an element to the list after a create operation.)
Alternatively I could add that functionality to the EmployeeHome itself, but that would mix responsibility for the employee list with that for the selected employee.
Or of course I could make the query itself conversation scoped and continue to update the result list in such a strange way. In the end however I'll probably have to wrap the query anayway because the "restrictions"/query-by-example feature will be too limiting to support more complex filters.
What do you think?
3) Atomic create
Oh well, adding a newly created instance to the list myself isn't transaction-save, is it? When in the end the transaction fails I may already have added the instance. Can I do something like this (in my home object)?
| public String save() {
| if (isManaged()) {
| return update();
| }
| String result = persist();
|
| //noinspection unchecked
| List<T> resultList = getEntityQuery().getResultList();
| resultList.add(getInstance());
|
| return result;
| }
|
save() is not marked @Transactional. Will the @Transactional annotation on persist() still be honored when I call persist() directly from within the save() method as above?
4) Conversations
What annotations/tag attributes do I need to add where to start a conversation when the "Employees" header is clicked or when an employee in the list is opened in a new browser tab?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4085362#4085362
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4085362
18 years, 10 months
[JBoss Tools (users)] - Re: Publishing Ear and update - resolves in second folder f
by BerndAhrens
Hello,
I reproduced the behavior is with the new Nightly Build.
I am not sure, where and how to write a ?jira?, so here the steps for reprodducing:
I installed wtp-all-in-one-sdk-R-2.0-200706260303-win32.zip
with
JBossAS-Tools-200709180102-nightly.zip
and
JBossTools-Core-200709180102-nightly.zip
In an Eclipseextension folder.
Because with the Beta3 a got some erros in the preferences, like discussed in the forum.
Now I make a simple testear (EAR 1.4) Projekt and a testearWeb (Dynamic WebModule2.4) with a simple index.jsp.
In the EAR-Projekt under Properties / J2EE Module Dependencies I mark the ?testearWeb? Projekt.
Publishing it to the local Server, the following structure is deployed:
c:\eclipse33\server\jboss-4.0.3SP1\server\default\deploy\testear.ear\testweb.war\index.jsp
Then I make a change on the index.jsp and push ?Publish to the Server?.
Now, there is a second folder for the war with only one file:
c:\eclipse33\server\jboss-4.0.3SP1\server\default\deploy\testearWeb.war\index.jsp
The first war-folder is still there, so you have two wars wih the same Context Root.
Why is there a second folder for the war?
Any ideas?
Could an Exploded Ear/War-Configuration help me? How is it configured?
( Before I make a Test with JBossAS-Tools-200709170536-nightly.zip, there was also a second folder for the war, but with more Content, I mean?)
Thanks for help!
Bernd
PS: I will try to live for once whith the slowly WTP-Deploy-Functions, maybe, with a faster Tomcat for the Webcontainer, maybe with Sysdeo. Have you other suggestions for Eclipse33?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4085357#4085357
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4085357
18 years, 10 months
[Security & JAAS/JBoss] - Custom LoginModule, standalone application, InitialContext i
by piotr.koper
Hi.
This is my first post on JBoss forums, but not last :-).
A tried to implement my own LoginModule. It is very simple - so even it works :-). But not exactly as i want.
When I'm trying to log-in with my LoginModule (extends AbstractServerLoginModule) - it works for web applications (ever). But when i'm trying to log-in with standalone app (further SA) - i have some unstable behaviour: sometimes it works, and sometimes not. Works when i log-in with web-app earlier. When it works not - then in my debug i see, that SecurityAssociation is empty... I think it's cache guilt :-) i mean - it works on cached data, and when there is no data in cache - goodbye :-)
My LoginModule uses SecurityAssociation container (for getting principal and credential). I fill also "subject" with this data (username and credential from SecurityAssociation).
Important thing is that i have also my own client LoginModule. This login module do only two things: puts data from callback to SecurityAssociation, fill subject on commit and clear all when abort or logout is invoked. I also use sometimes ClientLoginModule, but it works (fails) exactly as mine (in standalone app).
So my questions are:
1) What things should be done at method login, commit, abort and logout?
2) My login module works only with use of LoginContext instance, but JBoss modules can also work with InitialContext env-s attributes/properies:
| Hashtable env = new Hashtable();
|
| env.put(Context.PROVIDER_URL, "jnp://192.168.25.30:1099");
|
| env.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
| env.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
| env.put(Context.SECURITY_AUTHENTICATION, "simple");
| env.put(Context.SECURITY_PRINCIPAL, "j2ee");
| env.put(Context.SECURITY_CREDENTIALS, "j2ee");
| env.put(Context.SECURITY_PROTOCOL,"domain");
|
| InitialContext ctx = new InitialContext(env);
|
how is it possible? What should I do to enable this feature in my module (client or server)?
Useful informations:
* i work with Windows XP SP2 and JBoss 4.2.1
* i load my security domain "dynamic", configs files:
application.xml - ejbs and web module
jboss-app.xml - includes module-service login-service.xml
jboss-service.xml - specify that login-config.xml is my AuthConfig
login-config.xml - defines my domain
login-service.xml - sets cache timeout
* in SA app i use auth.conf file with content:
| jbc {
| org.jboss.security.ClientLoginModule required;
| };
|
I'm trying to log-in in SA with code:
LoginContext loginContext = new LoginContext("jbc", callbackHandler);
| loginContext.login();
callbackHandler fills NameCallback and PasswordCallback.
Any suggestion will be appreciate :-)
Regards
piotr.koper
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4085356#4085356
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4085356
18 years, 10 months