2012-12-24 67 views
3

關於事務和glassfish中的CORBA有一個奇怪的問題。我可以解決這個問題,但我仍然不知道爲什麼這個錯誤發生:關於遠程EJB調用

我有兩個班,讓我們稱他們爲客戶RemoteImpl客戶端在一臺服務器上,在另一臺服務器上的遠程

客戶看起來是這樣的(簡單的例子,而不是真正的代碼):

@Stateless 
public class Client { 

    @EJB(name = "TheRemoteEJB") 
    protected Remote remoteEJB; 

    @Schedule(hour = "*", minute = "*/5", persistent = false) 
    @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) 
    public void doSomeStuff() { 
     for(int i=0;i<300000;i++){ 
     remoteEJB.theMethodToCall(i); 
     ... other code that may take a bit longer... 
     } 
    } 
} 

RemoteImpl看起來是這樣的:

@Stateless 
@Remote(RemoteInterface.class) 
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) 
public class RemoteImpl { 

    @EJB 
    private SomeJPAFacade facade; 

    @Override 
    public int theMethodToCall(int param) throws SomeException { 
    Bean products = facade.findBySomeSelect(param); 
    return bean.getAValue(); 
    } 
} 

其它使用的類:

SomeException

public class SomeException extends Exception { 
public SomeException() { 
    super(); 
} 
public SomeException(String message) { 
    super(message); 
} 
} 

RemoteInterface

public interface RemoteInterface { 
    public int theMethodToCall() throws SomeException 
} 

的問題是,當doSomeStuff時間過長,一個CORBA異常引發:

[#|2012-12-22T03:10:03.327+0100|INFO|glassfish3.1.2|com.foo.bar.Client|_ThreadID=47;_ThreadName=Thread-2;|javax.ejb.EJBException: javax.transaction.InvalidTransactionException: CORBA INVALID_TRANSACTION 0 No 
; nested exception is: 
    org.omg.CORBA.INVALID_TRANSACTION: vmcid: 0x0 minor code: 0 completed: No 
    at com.foo.bar.Client._Remote_Wrapper.theMethodToCall(com/foo/bar/_RemoteInterface_Wrapper.java) 
    at com.foo.bar.Client.doSomeStuff(Client.java:73) 
    at sun.reflect.GeneratedMethodAccessor3162.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1052) 
    at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1124) 
    at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:5388) 
    at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:619) 
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800) 
    at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:571) 
    at org.jboss.weld.ejb.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:49) 
    at sun.reflect.GeneratedMethodAccessor80.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:861) 
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800) 
    at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:571) 
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doAround(SystemInterceptorProxy.java:162) 
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundTimeout(SystemInterceptorProxy.java:149) 
    at sun.reflect.GeneratedMethodAccessor371.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:861) 
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800) 
    at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:370) 
    at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:5360) 
    at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:5348) 
    at com.sun.ejb.containers.BaseContainer.callEJBTimeout(BaseContainer.java:4058) 
    at com.sun.ejb.containers.EJBTimerService.deliverTimeout(EJBTimerService.java:1832) 
    at com.sun.ejb.containers.EJBTimerService.access$100(EJBTimerService.java:108) 
    at com.sun.ejb.containers.EJBTimerService$TaskExpiredWork.run(EJBTimerService.java:2646) 
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) 
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:138) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) 
    at java.lang.Thread.run(Thread.java:662) 
Caused by: javax.transaction.InvalidTransactionException: CORBA INVALID_TRANSACTION 0 No; nested exception is: 
    org.omg.CORBA.INVALID_TRANSACTION: vmcid: 0x0 minor code: 0 completed: No 
    at com.sun.corba.ee.impl.javax.rmi.CORBA.Util.mapSystemException(Util.java:281) 
    at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.privateInvoke(StubInvocationHandlerImpl.java:213) 
    at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:152) 
    at com.sun.corba.ee.impl.presentation.rmi.codegen.CodegenStubBase.invoke(CodegenStubBase.java:227) 
    at com.foo.bar.__RemoteInterface_Remote_DynamicStub.matchByParityId(com/foo/bar/__RemoteInterface_Remote_DynamicStub.java) 
    ... 39 more 
Caused by: org.omg.CORBA.INVALID_TRANSACTION: vmcid: 0x0 minor code: 0 completed: No 
    at com.sun.jts.CosTransactions.CurrentTransaction.sendingRequest(CurrentTransaction.java:812) 
    at com.sun.jts.CosTransactions.SenderReceiver.sending_request(SenderReceiver.java:138) 
    at com.sun.jts.pi.InterceptorImpl.send_request(InterceptorImpl.java:338) 
    at com.sun.corba.ee.impl.interceptors.InterceptorInvoker.invokeClientInterceptorStartingPoint(InterceptorInvoker.java:290) 
    at com.sun.corba.ee.impl.interceptors.PIHandlerImpl.invokeClientPIStartingPoint(PIHandlerImpl.java:376) 
    at com.sun.corba.ee.impl.protocol.CorbaClientRequestDispatcherImpl.beginRequest(CorbaClientRequestDispatcherImpl.java:304) 
    at com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.request(CorbaClientDelegateImpl.java:228) 
    at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.privateInvoke(StubInvocationHandlerImpl.java:194) 
    ... 42 more 
Caused by: org.omg.CosTransactions.Unavailable: IDL:omg.org/CosTransactions/Unavailable:1.0 
    at com.sun.jts.CosTransactions.TopCoordinator.get_txcontext(TopCoordinator.java:2787) 
    at com.sun.jts.CosTransactions.ControlImpl.getTXContext(ControlImpl.java:824) 
    at com.sun.jts.CosTransactions.CurrentTransaction.sendingRequest(CurrentTransaction.java:804) 
    ... 49 more 
|#] 

我明確告訴ApllicationServer @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)因爲我不想跨越交易。但是異常看起來像是一個事務。我一直認爲事務不能跨越另一個glassfish實例的遠程調用?

我可以通過刪除@TransactionAttribute而不是在客戶端 -class中添加@TransactionManagement(TransactionManagementType.BEAN)來解決問題。

但我仍想知道爲什麼會發生這種錯誤。

感謝您的回覆。

UPDATE: 錯誤報告已經提交下:https://java.net/jira/browse/GLASSFISH-17535

回答

1

NOT_SUPPORTED意味着The container invokes an enterprise bean method whose transaction attribute NOT_SUPPORTED with an unspecified transaction context.

看來,非特定背景下導致了無效的事務異常。

通過使用bean管理的事務,您告訴容器不要提供任何事務上下文,以防止該異常。

這對我來說就像是一個錯誤,我對我的直覺並不是很瞭解玻璃魚,告訴我這應該起作用。

+0

感謝您的回覆,我想也是,這是一個錯誤。也許我會提交一個bugreport。 – McIntosh