[EJB/JBoss] - EJB 3 + transaction propagation
by david81
Hi ,
I am stuck in an issue and need your help on it.
I have an ejb (Bean1) where in a transaction is started.
>From this ejb (Bean1) if I call another ejb(Bean2), and anything wrong happens in Bean2, whole of the transaction is rolled back.
This is controlled by the Jboss.
My query is..
If from Bean1, I make a call to some utility class which makes entires into DB and if an error happens in Bean1 , after utility class commits the DB changes. How can I rollback the changes made in utility class.
In short, how is the transaction in EJB3 propagated to utility class?
I am using hibernate in utility class and the application server used is JBoss4.
I set hibernate.transaction.manager_lookup_class
and set hibernate.transaction.factory_class to org.hibernate.transaction.JTATransactionFactory
My code in utility class..
UserTransaction tx = (UserTransaction)new InitialContext()
.lookup("java:comp/UserTransaction");
try {
tx.begin();
// Do some work
saved object using hibernate session
tx.commit();
}
catch (RuntimeException e) {
tx.rollback();
throw e; // or display error message
}
The logs show issue with tx.begin(); statement..
javax.transaction.NotSupportedException
at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.begin(BaseTransaction.java:79)
and on the screen I get error
java.lang.IllegalStateException: Wrong tx on thread: expected TransactionImple < ac, BasicAction: -3f5702b4:390d:474aea8d:77 status: ActionStatus.ABORTED >, actual null
at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:162)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:87)
Can you please tell what could be the problem?
Any help will be greatly appreciated.
Thanks,
David
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4107935#4107935
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4107935
18 years, 5 months
[JNDI/Naming/Network] - a stange problem with JNP
by su27
my code is
env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
env.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");
env.put(Context.PROVIDER_URL, "jnp://127.0.0.1:1099");
or
env.put(Context.PROVIDER_URL, "jnp://localhost:1099");
it's working well. everything is fine.
but if i change it to
env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
env.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");
env.put(Context.PROVIDER_URL, "jnp://192.168.1.101:1099");
an error came out
javax.naming.CommunicationException: Could not obtain connection to any of these urls: 192.168.1.101:1099
localhost, 127.0.0.1, 192.168.1.101 is the same server.
actually i wanna connect to a remote server 192.168.1.50. but i can't even connect to myself if i use 192.168.1.101 address
does anybody have any idea what's going on?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4107934#4107934
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4107934
18 years, 5 months
[JBossWS] - Re: returning array undefined in web service
by mckeno
The code looks messy, but I can't find the edit functionality in this forum ??!!?? so I did a re post....
-------------
Hi all I am having this problem, not sure whether it is related to jboss web service or the client site application:
I am writing a web service inside EJB container:
| @Stateless
| @WebService(name = "Mojo", targetNamespace = "http://myservice.com/services", serviceName = "CoolService")
| @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
| public class MyWebService {
|
| @WebMethod
| @WebResult
| public int[] getNumber(@WebParam(name = "userName") String sth) {
| int[] number = new int[3];
| number[0] = 7;
| number[1] = 2;
| number[2] = 3;
|
| log.info("ARRAY METHOD CALLED " + number.length);
| return number;
| }
|
| @WebMethod
| @WebResult
| public int getNum(int param) {
| int result = param + 2;
| return result ;
| }
|
| }
The getNum() method works fine, but the getNumber() always return undefined result(I am calling the web service using Web Sevice Connector in Flash application). So I am wondering whether I need any specific annotation for the array returning methods?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4107929#4107929
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4107929
18 years, 5 months
[JBossWS] - returning array undefined in web service
by mckeno
Hi all I am having this problem, not sure whether it is related to jboss web service or the client site application:
I am writing a web service inside EJB container:
@Stateless
@WebService(name = "Mojo", targetNamespace = "http://myservice.com/services", serviceName = "CoolService")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
public class MyWebService {
@WebMethod
@WebResult
public int[] getNumber(@WebParam(name = "userName") String sth) {
int[] number = new int[3];
number[0] = 7;
number[1] = 2;
number[2] = 3;
log.info("ARRAY METHOD CALLED " + number.length);
return number;
}
@WebMethod
@WebResult
public int getNum(int param) {
int result = param + 2;
return result ;
}
}
The getNum() method works fine, but the getNumber() always return undefined result(I am calling the web service using Web Sevice Connector in Flash application). So I am wondering whether I need any specific annotation for the array returning methods?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4107928#4107928
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4107928
18 years, 5 months
[JBoss Seam] - page navigation issue....
by minamti
This is what I have ....
Clicking on 'hello' navigates to newPage whereas clicking on 'world'
does not navigate to newPage. Any ideas...
Thanks,
M
Detail.xhtml
| <s:decorate id="button" template="layout/edit.xhtml">
| <div class="navBar">
| <h:commandButton value="Hello" action="#{test.hello}" rendered="#{test.renderHello}" view="/test2.xhtml"/>
| <h:commandButton value="World" action="#{test.world}" rendered="#{test.renderWorld}" view="/test2.xhtml"/>
| </div>
| </s:decorate>
|
Test.java
| @Name("test")
| public class Test {
|
| public boolean getRenderHello() {
| return true;
| }
|
| public boolean getRenderWorld() {
| return true;
| }
|
| public void hello() {
| System.out.println("hello");
| }
|
| public void world() {
| System.out.println("world");
| }
| }
|
pages.xml
| <page....>
| <navigation from-action="#{test.hello}">
| <redirect view-id="/newPage.xhtml"/>
| </navigation>
| <navigation from-action="#{test.world}">
| <redirect view-id="/newPage.xhtml"/>
| </navigation>
| </page>
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4107922#4107922
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4107922
18 years, 5 months