[JNDI and Naming] - Call JNDI Remotely outside of JAVA
by Haitham Safi
Haitham Safi [https://community.jboss.org/people/haithamnor] created the discussion
"Call JNDI Remotely outside of JAVA"
To view the discussion, visit: https://community.jboss.org/message/807179#807179
--------------------------------------------------------------
Hi expert,
I create JAR file for class in eclipse like:
Package Haitham
import java.io.IOException;
import java.net.URISyntaxException;
import java.rmi.RemoteException;
import java.util.Properties;
import java.util.logging.Logger;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class TracingMessages
{
public static void main(String[] args)
{
}
public static String SendMessages(String Queuename,String msg) throws IOException, URISyntaxException
{
String body="";
try
{
Context init =TracingMessages.getInitialContext();
javax.jms.Queue destination = (javax.jms.Queue) init.lookup("/queue/" +Queuename);
ConnectionFactory connectionFactory = (ConnectionFactory) init.lookup("ConnectionFactory");
Connection connection = connectionFactory.createConnection();//
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(destination);
TextMessage message = session.createTextMessage();
message.setText(msg );
connection.start();
System.out.println("connect strat");
producer.send(message);
body = message.getText();
session.close();
connection.close();
}
catch (Exception e)
{
return(e.toString());
}
return body ;
}
public static Context getInitialContext () throws JMSException,NamingException,RemoteException
{
Properties prop = new Properties();
prop.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
prop.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
prop.setProperty("java.naming.provider.url", "jnp://127.0.0.1:1099");
Context context = new InitialContext(prop);
return context;}
Then i converts JAR file to DLL after that i used in VISUAL STUDIO 2012 to send message to Jboss 4.2.3 ,it is worning Well if i used inside WINDOWS APPLICATION
but
if i used the same DLL class inside web application i got the follwoing error:
*** javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory***
why??????
*any one have idea?*
*Thanks in advanced
*
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/807179#807179]
Start a new discussion in JNDI and Naming at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
12 years, 11 months
[jBPM] - Pass the result of a workitem to the next workitem with a workitemhandler
by hansi007
hansi007 [https://community.jboss.org/people/hansi007] created the discussion
"Pass the result of a workitem to the next workitem with a workitemhandler"
To view the discussion, visit: https://community.jboss.org/message/738803#738803
--------------------------------------------------------------
Is it possible to pass the results of a workitem to the next workitem with a workitemhandler:
public class MyHandlerWorkItemTypeA implements WorkItemHandler{
@Override
public final void executeWorkItem(WorkItem wItem, WorkItemManager wItemManager) {
Map<String,Object> objectToPassToTheNextWorkItem = ...
wItemManager.completeWorkItem(wItem.getId(), objectToPassToTheNextWorkItem ); //That doesnt work
}
@Override
public final void abortWorkItem(WorkItem wItem, WorkItemManager wItemManager) {
}
}
public class MyHandlerWorkItemTypeB implements WorkItemHandler{
@Override
public final void executeWorkItem(WorkItem wItem, WorkItemManager wItemManager) {
Map<String,Object> objectToGetFromThePreviousWorkItem = wItem.getResults(); //That doesnt work
}
@Override
public final void abortWorkItem(WorkItem wItem, WorkItemManager wItemManager) {
}
}
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/738803#738803]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
12 years, 11 months
[jBPM] - Re: Session and thread safety
by Sebastian Calbaza
Sebastian Calbaza [https://community.jboss.org/people/calbazasebastian] created the discussion
"Re: Session and thread safety"
To view the discussion, visit: https://community.jboss.org/message/760010#760010
--------------------------------------------------------------
Here is my thread safe ProcessPersistenceContextManager if someone needs it.
It needs to be set on the Environment param (env.set(EnvironmentName.PERSISTENCE_CONTEXT_MANAGER, persistenceContextManager);) before you pass it to JPAKnowledgeService.newStatefulKnowledgeSession(kbase,null, env)
-----------------------------------------
public class MyJpaProcessPersistenceContextManager implements
ProcessPersistenceContextManager, PersistenceContextManager {
private EntityManagerFactory emf;
private ThreadLocal<EntityManager> appScopedEntityManager=new ThreadLocal<EntityManager>();
protected ThreadLocal<EntityManager> cmdScopedEntityManager=new ThreadLocal<EntityManager>();
public ProcessPersistenceContext getProcessPersistenceContext() {
return new JpaProcessPersistenceContext(cmdScopedEntityManager.get());
}
public MyJpaProcessPersistenceContextManager(Environment env) {
this.emf = (EntityManagerFactory) env.get(EnvironmentName.ENTITY_MANAGER_FACTORY);
}
public PersistenceContext getApplicationScopedPersistenceContext() {
if (this.appScopedEntityManager.get() == null) {
this.appScopedEntityManager.set(this.emf.createEntityManager());
}
return new JpaPersistenceContext(appScopedEntityManager.get());
}
public PersistenceContext getCommandScopedPersistenceContext() {
return new JpaPersistenceContext(this.cmdScopedEntityManager.get());
}
public void beginCommandScopedEntityManager() {
if (cmdScopedEntityManager.get() == null ||
(this.cmdScopedEntityManager.get() != null && !this.cmdScopedEntityManager.get().isOpen())) {
this.cmdScopedEntityManager.set( this.emf.createEntityManager());
}
cmdScopedEntityManager.get().joinTransaction();
appScopedEntityManager.get().joinTransaction();
}
public void endCommandScopedEntityManager() {
if (this.cmdScopedEntityManager.get()!=null){
this.cmdScopedEntityManager.get().flush();
this.cmdScopedEntityManager.get().close();
}
}
public ThreadLocal<EntityManager> getCmdScopedEntityManager() {
return cmdScopedEntityManager;
}
public ThreadLocal<EntityManager> getAppScopedEntityManager() {
return appScopedEntityManager;
}
public void dispose() {
if (this.appScopedEntityManager.get() != null && this.appScopedEntityManager.get().isOpen()) {
this.appScopedEntityManager.get().flush();
this.appScopedEntityManager.get().close();
}
this.appScopedEntityManager.set(null);
if (this.cmdScopedEntityManager.get() != null && this.cmdScopedEntityManager.get().isOpen()) {
this.cmdScopedEntityManager.get().flush();
this.cmdScopedEntityManager.get().close();
}
this.cmdScopedEntityManager.set(null);
}
}
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/760010#760010]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
12 years, 11 months
[JBoss Tools] - JBoss 4.1.0.Alpha1 memory leak?
by Jesper Skov
Jesper Skov [https://community.jboss.org/people/jskovjyskebankdk] created the discussion
"JBoss 4.1.0.Alpha1 memory leak?"
To view the discussion, visit: https://community.jboss.org/message/804026#804026
--------------------------------------------------------------
A few of us has started using the new Alpha1 with Kepler M5.
The impression is there is a much higher memory load. Especially on XP where our Heap is limited to 1GB this becomes a problem.
Since I don't have a specific use case I can repeat, I have a little trouble providing you with some useful information.
However, I got a heap dump from one of the sessions where things was at a crawl. Analyzing it, I find this in Memory Analysis's leak suspects:
900 instances of *"org.jboss.tools.common.model.filesystems.impl.JarAccess"*, loaded by *"org.jboss.tools.common.model"* occupy *68.321.856 (18,11%)* bytes.
These instances are referenced from one instance of *"org.eclipse.jdt.core.IElementChangedListener[]"*, loaded by *"org.eclipse.jdt.core"*
20% of memory locked up by a single plugin seems excessive, but I don't really have anything to compare it with. So it may be OK?!?
What do you think?
Is there something I can provide you to resolve if this is a JBossTools leak?
Cheers,
Jesper
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/804026#804026]
Start a new discussion in JBoss Tools at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
12 years, 11 months