First of all, I can't use Spring's #Transactional annotation. I have to use exactly JTA which in out EJB-container. Currecntly I'm using JBoss AS 7.0 Web-Profile. So what I need to do is configure Hibernate's session factory to correctly work with JTA-transaction inside the Spring's Envirnoment. My current configuration:
piece of the context.xml configuration:
<tx:annotation-driven/>
<tx:jta-transaction-manager />
<!-- Some other beans -->
<bean id="userTransaction" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/UserTransaction"></property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="annotatedClasses">
<list>
<value>com.badmitrii.db.entity.Employee</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
<prop key="hibernate.show_sql">false</prop>
</props>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="userTransaction" ref="userTransaction"></property>
</bean>
DAO-method:
public Player getPlayerById(Integer id){
try {
userTransaction.begin();
} catch (Exception e) { }
//Here is obtaining a Criteria object and setting Restrictions
try {
userTransaction.commit();
} catch (Exception e) { }
return (Player) criteria.uniqueResult();
}
But, I got the following excpetion when I was trying to get Session in the DAO method:
org.hibernate.HibernateException: Could not obtain transaction-synchronized Session for current thread
org.springframework.orm.hibernate4.SpringSessionContext.currentSession(SpringSessionContext.java:134)
org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:1024)
com.badmitrii.db.dao.EmployeeDAOImpl.getEmployeeById(EmployeeDAOImpl.java:34)
com.badmitrii.EmployeeListController.getEmployeeById(EmployeeListController.java:42)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:483)
org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:777)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:706)
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
How to configure it correctly?
First of all remove the declaration for JtaTransactionManager as that is already provided by <tx:jta-transaction-manager />.
Next there is no reason why you wouldn't be able to use #Transactional in a JTA environment that is the whole point of declarative tx management.
You should wire the configured jta transactionmanager to the LocalSessionFactoryBean to switch out the used CurrentSessionContext.
<tx:annotation-driven/>
<tx:jta-transaction-manager />
<!-- Some other beans -->
<bean id="userTransaction" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/UserTransaction"></property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jtaTransactionManager" ref="transactionManager" />
<property name="annotatedClasses">
<list>
<value>com.badmitrii.db.entity.Employee</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
<prop key="hibernate.show_sql">false</prop>
</props>
</property>
</bean>
Then in your cod eyou can simply do something like this
#Transactional
public Player getPlayerById(Integer id){
//Here is obtaining a Criteria object and setting Restrictions
return (Player) criteria.uniqueResult();
}
Update:
For JBoss the <tx:jta-transaction-manager /> doesn't work due to fact that the TransactionManager for JTA is registered in JNDI under the name java:jboss/TransactionManager instead of one of the well-known names. You will need to declare the JtaTransactionManager bean yourself and remove the <tx:jta-transaction-manager /> element. For the lookup you need to specify the transactionManagerName or do a JNDI lookup yourself.
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionManagerName" value="java:jboss/TransactionManager" />
</bean>
The UserTransaction is registered under the default name so you can omit the injection of it in the JtaTransactionManager as it will do the lookup itself.
Related
I want to make a test with HQL but the mapping tables is with Annotations.
Hibernate configuration file is in the /WEB-INF/spring-config-ws.xml :::>
<!-- Activate transaction declarations with annotations -->
<tx:annotation-driven transaction-manager="transactionManager"/>
<!-- Property files application uses -->
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:jdbc.properties</value>
</list>
</property>
</bean>
<!-- JNDI DataSource -->
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="${dataSource.jndiName}" />
<property name="lookupOnStartup" value="false"/>
<property name="cache" value="true"/>
<property name="proxyInterface" value="javax.sql.DataSource"/>
</bean>
<!-- Hibernate SessionFactory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration" />
<property name="packagesToScan">
<list>
<value>es.sergas.rprof.profesional.domain</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.default_schema">${hibernate.default_schema}</prop>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.generate_statistics">true</prop>
<prop key="hibernate.bytecode.use_reflection_optimizer">true</prop>
<prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}</prop>
</props>
</property>
</bean>
<!-- Transaction manager for Hibernate SessionFactory -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
When I run a list, I get that you do not find the hibernate cfg:
hibernate.cfg.xml not found
I just want to list a mapped class with annotations, but HQL
I feel my level of English is so low. Thank you
Make sure your hibernate.cfg.xml is inside src/main/resources, if the file is not there you need to specify the right location, so put it inside this folder that your problem will be solved.
Note that we don’t have to explicitly mention the mapping or configuration or properties
files, because the Hibernate runtime looks for default filenames, such as hibernate.
cfg.xml or hibernate.properties, in the classpath and loads them. If we have a nondefault
name, make sure you pass that as an argument—like configure("my-hibcfg.
xml"), for example.
I am running spring 4.1.4, hibernate 4.3.8, atomikos 3.9.3, java 8, tomcat 8.
I see the above exception in localhost.log when I start my server but I'm not sure where to configure the TransactionManagerLookup apart from where I am already configuring it. This wasn't happening before upgrading hibernate so it is most likely a versioning issue. Could anyone help please?
FYI: catalina.out shows nothing useful. Just:
SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal Error listenerStart
SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal Context [] startup failed due to previous errors
My appContext defines :
<prop key="hibernate.transaction.factory_class">org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory</prop>
<prop key="hibernate.transaction.manager_lookup_class">com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup</prop>
and the full stack trace is:
22-Jan-2015 10:07:25.734 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class com.my.app.web.InitializerListener
org.hibernate.HibernateException: No TransactionManagerLookup specified
at org.hibernate.context.internal.JTASessionContext.currentSession(JTASessionContext.java:85)
at org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:1014)
at com.my.app.dao.AbstractMyDAO.currentSession(AbstractMyDAO.java:116)
at com.my.app.dao.AbstractMyDAO.criteria(AbstractMyDAO.java:86)
at com.my.app.dao.AbstractMyDAO.count(AbstractMyDAO.java:79)
at com.my.app.initialize.MyInitializerImpl.initializeApplicaiton(MyInitializerImpl.java:69)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
at com.sun.proxy.$Proxy220.initializeApplicaiton(Unknown Source)
at com.my.app.web.MyInitializerListener.contextInitialized(MyInitializerListener.java:42)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4772)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5196)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:917)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1701)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
EDIT: The Atomikos Transaction manager is configured as such
<bean id="atomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager" init-method="init" destroy-method="close">
<property name="forceShutdown" value="true" />
<!-- in secs -->
<property name="transactionTimeout" value="300"/>
</bean>
<bean id="atomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp">
<!-- in secs -->
<property name="transactionTimeout" value="300" />
</bean>
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionManager" ref="atomikosTransactionManager" />
<property name="userTransaction" ref="atomikosUserTransaction" />
<property name="transactionSynchronizationName" value="SYNCHRONIZATION_ON_ACTUAL_TRANSACTION" />
<property name="allowCustomIsolationLevels" value="true"/>
</bean>
EDIT 2:
I think I need to clarify things a bit here.
I have a DAO object called AbstractMyDAO (as you can see from the stack). In this object is defined a session factory
#Autowired
private SessionFactory mySessionFactory;
when currentSession is called the above error is thrown because hibernate cannot find the transaction manager lookup associated with this session factory.
public Session currentSession() {
return mySessionFactory.getCurrentSession();
}
This session factory is defined in my app context file as such:
<bean id="mySessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="myDataSource" />
</property>
<property name="annotatedClasses">
<list>
<value>some values... </value>
...
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
${gst.hibernate.dialect}
</prop>
<prop key="query.factory_class">
org.hibernate.hql.ast.ASTQueryTranslatorFactory
</prop>
<prop key="hibernate.max_fetch_depth">3</prop>
<prop key="hibernate.show_sql">${my.hibernate.showsql}</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.cache.use_structured_entries">true</prop>
<prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory</prop>
<prop key="net.sf.ehcache.configurationResourceName">${ehcache.my.persist.config}</prop>
<prop key="hibernate.connection.isolation">3</prop>
<prop key="connection.release_mode">auto</prop>
<prop key="hibernate.current_session_context_class">jta</prop>
<prop key="hibernate.transaction.factory_class">org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory</prop>
<prop key="hibernate.transaction.manager_lookup_class">com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup</prop>
<prop key="hibernate.search.default.directory_provider">filesystem</prop>
<prop key="hibernate.search.default.indexBase">/var/log/my/lucene/indexes</prop>
</props>
</property>
</bean>
As you can see, the property hibernate.transaction.manager_lookup_class is being defined but can't be found when the bean is created and I have no idea why. Has the configuration changed?
EDIT 3:
When I debug:
final JtaPlatform jtaPlatform = factory().getServiceRegistry().getService( JtaPlatform.class );
It returns a NoJTAPlatform. I guess this is my problem.
EDIT 4:
There doesn't seem to be anything that implements JtaPlatform that is suitable for tomcat or am I being mental?
Make sure you also configure the Atomikos Transaction Manager too, so the TransactionManagerLookup can locate the UserTransaction accordingly:
<bean id="atomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager"
init-method="init" destroy-method="close">
<property name="transactionTimeout" value="300" />
</bean>
<bean id="atomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp">
<property name="transactionTimeout" value="300" />
</bean>
<bean id="transactionManager"
class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionManager" ref="atomikosTransactionManager" />
<property name="userTransaction" ref="atomikosUserTransaction" />
</bean>
Then, you should use Spring EntityManager factory too:
<bean id="entityManager"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
p:dataSource-ref="dataSource"
p:persistenceXmlLocation="**/persistence.xml"
p:persistenceUnitName="persistenceUnit"
depends-on="dataSource, transactionManager">
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
</bean>
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.transaction.factory_class">org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory</prop>
<prop key="hibernate.transaction.manager_lookup_class">com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup</prop>
...
</props>
</property>
</bean>
Then the DAOs should inject the EntityManager:
#PersistenceContext(unitName = "persistenceUnit")
private EntityManager entityManager;
Instead of calling currentSession(AbstractMyDAO) directly:
at com.my.app.dao.AbstractMyDAO.currentSession(AbstractMyDAO.java:116)
The answer to my question is here.
"In Hibernate 4.3 the long deprecated TransactionManagerLookup got removed. Now the JTA provider must implement org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform."
I Solved it by
into the hibernate.cfg.xml file
changing the
<property name="hibernate.current_session_context_class">thread</property>
to thread instead of jta .
More details here
I´ve my hibernate configuration inside my spring-context, but after a little time of use I´m getting the too many connections error. Here is my code:
Spring context:
<!-- Beans Declaration -->
<bean id="Usuarios" class="com.proximate.model.Usuarios"/>
<!-- Service Declaration -->
<bean id="UsuariosService" class="com.proximate.service.UsuariosService">
<property name="usuariosDAO" ref="UsuariosDAO" />
</bean>
<!-- DAO Declaration -->
<bean id="UsuariosDAO" class="com.proximate.dao.UsuariosDAO">
<property name="sessionFactory" ref="SessionFactory" />
</bean>
<bean id="DataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="com.mysql.jdbc.Driver" />
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/mydb" />
<property name="user" value="user" />
<property name="password" value="password" />
<property name="maxPoolSize" value="50" />
<property name="maxStatements" value="0" />
<property name="minPoolSize" value="5" />
</bean>
<!-- Session Factory Declaration -->
<bean id="SessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="DataSource" />
<property name="annotatedClasses">
<list>
<value>com.proximate.model.Usuarios</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
</bean>
<!-- Enable the configuration of transactional behavior based on annotations -->
<tx:annotation-driven transaction-manager="txManager"/>
<context:annotation-config />
<!-- Transaction Manager is defined -->
<bean id="txManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="SessionFactory"/>
</bean>
and here is how I use my session factory inside my dao:
private SessionFactory sessionFactory;
private HibernateTemplate hibernateTemplate;
public SessionFactory getSessionFactory() {
return sessionFactory;
}
public void setSessionFactory(SessionFactory sessionFactory) {
this.hibernateTemplate = new HibernateTemplate(sessionFactory);
}
Query query = hibernateTemplate.getSessionFactory().getCurrentSession().createSQLQuery("SELECT ID FROM usuarios");
Integer cantidad = new Integer(((BigInteger) query.uniqueResult()).intValue());
Why is my code opening so many connections. I heard that using a HibernateUtil class to load a session after logging might be what I need, but how do you implement it when using spring??
Thanks in advance!!
I don't know much about hibernate itself, but i think closing the session might help.
That's how JPAs EntityManager works - you have to close it to close underlaying connection.
It looks like your hibernate query is global? I would guess the cause is probably because it is not contained in a method with a transactional annotation around it.
What is the difference between using datasource and using hibernateProperties. I want to use c3P0 with spring in my app. I found 2 ways to do so but I'm unable to understand the difference between the two
First:
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
depends-on="dataSource">
<property name="dataSource" ref="dataSource" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.format_sql">false</prop>
<prop key="hibernate.use_sql_comments">false</prop>
</props>
</property>
<bean id="dataSource" destroy-method="close"
class="com.mchange.v2.c3p0.ComboPooledDataSource" >
<property name="maxPoolSize" value="10" />
<property name="numHelperThreads" value="5" />
</bean>
Second:
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
>
<property name="hibernateProperties">
<props>
<property name="hibernate.c3p0.maxSize" value="100" />
<property name="hibernate.c3p0.numHelperThreads" value="5" />>
</props>
</property>
</bean>
The first you get a Spring managed datasource, which you can also use for a JdbcTemplate or other work.
The second you get a hibernate managed datasource which is not reusable by Spring.
I strongly suggest the first approach as it also makes it quite easy to replace your datasource for testing (by replacing it with an in-memory database) or to replace it with a JNDI lookup.
I wonder how object (if it matter I need EJB) can be plugged to JBoss (5.0) with JNDI?
I have following bean definition in my Spring applicationContext.xml:
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
<context:annotation-config/>
<bean id="myServiceFacade" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="MyServiceFacadeBean/remote"/>
<property name="cache" value="true"/>
<property name="lookupOnStartup" value="true"/>
<property name="jndiEnvironment">
<props>
<prop key="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory
</prop>
<prop key="java.naming.provider.url">localhost:1099</prop>
<prop key="java.naming.factory.url.pkgs">org.jboss.naming:org.jnp.interfaces
</prop>
</props>
</property>
<property name="proxyInterface" value="my.company.service.facade.MyServiceFacade"/>
</bean>
when I try to run JBoss I get:
Caused by: javax.naming.NameNotFoundException: MyServiceFacadeBean/remote
at org.jboss.ha.jndi.HAJNDI.lookupRemotely(HAJNDI.java:264)
at org.jboss.ha.jndi.HAJNDI.lookup(HAJNDI.java:205)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.ha.framework.interfaces.HARMIClient.invoke(HARMIClient.java:318)
at $Proxy165.lookup(Unknown Source)
Maybe some additional steps should be made for registering objects with JBoss/JNDI?
Note, I've tried already to put ejb specific files to JBoss (jboss.xml, ejb-jar.xml) but that doesn't help.
How do you loop-up remote in your DataSource? But I am sure you can't get it from your MyServiceFacadeBean.
in applicationContext.xml:
<property name="jndiName" value="remote"/>
While loooping up,
Context ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("java:comp/env/remote");
DataSource ds = (DataSource)envCtx.lookup("remote");
or you could make an intermediate step so you don't have to specify "java:comp/env" for every resource you retrieve:
Context ctx = new InitialContext();
Context envCtx = (Context)ctx.lookup("java:comp/remote");
DataSource ds = (DataSource)envCtx.lookup("remote");
Hope it helps.