<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Accessing jndi in activiti in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/accessing-jndi-in-activiti/m-p/148876#M103907</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a problem when accessing jndi in activiti. I have read the articles : &lt;/SPAN&gt;&lt;A href="http://forums.activiti.org/content/persistence" rel="nofollow noopener noreferrer"&gt;http://forums.activiti.org/content/persistence&lt;/A&gt;&lt;SPAN&gt; and &lt;/SPAN&gt;&lt;A href="http://forums.activiti.org/content/jdbc-datasource-out-jndi" rel="nofollow noopener noreferrer"&gt;http://forums.activiti.org/content/jdbc-datasource-out-jndi&lt;/A&gt;&lt;SPAN&gt; but still no success. We use hibernate with the jpa specification for our project. I'm able to execute hibernate queries when using Java Service Task, also I'm able to achieve the same from a Task Listener this way:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;private BeanManager getBeanManager() {&lt;BR /&gt;try {&lt;BR /&gt;return (BeanManager) InitialContext.doLookup("java:comp/BeanManager");&lt;BR /&gt;}&lt;BR /&gt;catch (final NamingException e) {&lt;BR /&gt;e.printStackTrace();&lt;BR /&gt;}&lt;BR /&gt;return null;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;@SuppressWarnings("unchecked")&lt;BR /&gt;private T lookup(final Class clazz) {&lt;BR /&gt;final BeanManager bm = getBeanManager();&lt;BR /&gt;final Iterator&amp;gt; iter = bm.getBeans(clazz).iterator();&lt;BR /&gt;if (!iter.hasNext()) {&lt;BR /&gt;throw new IllegalStateException("CDI BeanManager cannot find an instance of requested type " + clazz.getName());&lt;BR /&gt;}&lt;BR /&gt;final Bean bean = (Bean) iter.next();&lt;BR /&gt;final CreationalContext ctx = bm.createCreationalContext(bean);&lt;BR /&gt;return (T) bm.getReference(bean, clazz, ctx);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and getting the entitymanager this way:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;EntityManagerFactory emf = null;&lt;BR /&gt;EntityManager em = null;&lt;BR /&gt;BeanManager bm = getBeanManager();&lt;BR /&gt;emf = lookup(EntityManagerFactory.class);&lt;BR /&gt;System.out.println("Contents of emf ::::"+emf);&lt;BR /&gt;em = emf.createEntityManager();&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;With the entity manager in place i can then execute hibernate statements and queries.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now the problem comes in when i try the same after a trigger from a timer event e.g the timeCycle, i'm not able to access the jndi.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The exception i get is : javax.naming.NameNotFoundException: java:comp/BeanManager. We do not use spring for our application.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;My config file looks like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;BR /&gt;&amp;lt;beans xmlns="&lt;A href="http://www.springframework.org/schema/beans" rel="nofollow noopener noreferrer"&gt;http://www.springframework.org/schema/beans&lt;/A&gt;" &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:xsi="&lt;A href="http://www.w3.org/2001/XMLSchema-instance" rel="nofollow noopener noreferrer"&gt;http://www.w3.org/2001/XMLSchema-instance&lt;/A&gt;"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xsi:schemaLocation="&lt;A href="http://www.springframework.org/schema/beans" rel="nofollow noopener noreferrer"&gt;http://www.springframework.org/schema/beans&lt;/A&gt;&amp;nbsp;&amp;nbsp; &lt;A href="http://www.springframework.org/schema/beans/spring-beans.xsd" rel="nofollow noopener noreferrer"&gt;http://www.springframework.org/schema/beans/spring-beans.xsd&lt;/A&gt;"&amp;gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration"&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name="dataSourceJndiName" value="java:comp/BeanManager" /&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name="transactionsExternallyManaged" value="true" /&amp;gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name="history" value="audit" /&amp;gt;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name="jobExecutorActivate" value="true" /&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name="jdbcUrl" value="jdbc:oracle:thin:@localhost:1521:xe" /&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name="jdbcDriver" value="oracle.jdbc.driver.OracleDriver" /&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name="jdbcUsername" value="fm" /&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name="jdbcPassword" value="fm123" /&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name="databaseSchemaUpdate" value="true" /&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;/bean&amp;gt;&lt;BR /&gt;&amp;lt;/beans&amp;gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help is highly appreciated. Thank you good people.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 09 Dec 2013 05:33:02 GMT</pubDate>
    <dc:creator>chilopoda</dc:creator>
    <dc:date>2013-12-09T05:33:02Z</dc:date>
    <item>
      <title>Accessing jndi in activiti</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/accessing-jndi-in-activiti/m-p/148876#M103907</link>
      <description>I have a problem when accessing jndi in activiti. I have read the articles : http://forums.activiti.org/content/persistence and http://forums.activiti.org/content/jdbc-datasource-out-jndi but still no success. We use hibernate with the jpa specification for our project. I'm able to execute hibernate</description>
      <pubDate>Mon, 09 Dec 2013 05:33:02 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/accessing-jndi-in-activiti/m-p/148876#M103907</guid>
      <dc:creator>chilopoda</dc:creator>
      <dc:date>2013-12-09T05:33:02Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing jndi in activiti</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/accessing-jndi-in-activiti/m-p/148877#M103908</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The API-calls you trigger, run inside the thread you call them from. Any resources specific to the environment are available (eg lookup in JNDI). The job-executor, on the other hand, executes job in a single thread that is part if an internal thread-pool. These threads don't run in the same context as the API-calls you do.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You need to extends the JobExecutor and, prior to actually executing a job, make sure the thread has access to the resources it needs. not sure how you set this up for your usecase. Anyway, some piece of code (prolly in the framework you're using) makes sure JNDI-calls are possible from the threads. If you're not using anything special, It might be that the container-thread handling the request (eg. tomcat) makes sure the treads have access to the JNDI.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To make a long story short: Extend JobExecutor and override the right class (perhaps even ExecuteJobCmd) to wrap the running of the job with your environment initialisation. Does that make sense?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Dec 2013 12:29:51 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/accessing-jndi-in-activiti/m-p/148877#M103908</guid>
      <dc:creator>frederikherema1</dc:creator>
      <dc:date>2013-12-10T12:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing jndi in activiti</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/accessing-jndi-in-activiti/m-p/148878#M103909</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi, frederikheremans, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you for the quick response. The statement above makes sense especially: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;blockquote&amp;gt;The job-executor, on the other hand, executes job in a single thread that is part if an internal thread-pool. These threads don't run in the same context as the API-calls you do.&amp;lt;/blockquote&amp;gt; I think my problem is about the context, i.e when there is a trigger from the jobexecutor, I loose the context and therefore not able to access the JNDI.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;As for your suggestion, &amp;lt;blockquote&amp;gt;You need to extends the JobExecutor and, prior to actually executing a job, make sure the thread has access to the resources it needs. not sure how you set this up for your usecase.&amp;lt;/blockquote&amp;gt; I think this must be the solution but the problem I do not know how to exactly implement this. I'm still new in java but very much interested and always willing to try new stuff. I just can't figure out why if i just use a service task or tasklistener without the triggers I'm able to execute any queries but if i call say a service task as a result of a trigger, i just get an error and cant access the JNDI.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Could you please give me step by step guideline? alternatively, i can also attach any files you may need for further clarification.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;For our environment we use JbossAS 7 and stripes framework. Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Dec 2013 05:39:06 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/accessing-jndi-in-activiti/m-p/148878#M103909</guid>
      <dc:creator>chilopoda</dc:creator>
      <dc:date>2013-12-11T05:39:06Z</dc:date>
    </item>
  </channel>
</rss>

