[jBPM] - EntityNotFoundException: Unable to find org.jbpm.task.User with id group1
by sftzptrck
sftzptrck [https://community.jboss.org/people/sftzptrck] created the discussion
"EntityNotFoundException: Unable to find org.jbpm.task.User with id group1"
To view the discussion, visit: https://community.jboss.org/message/766763#766763
--------------------------------------------------------------
I am using JBPM 5.3 and trying to get all tasks assigned to a specific group using getTasksAssignedAsPotentialOwner.
List<String> groups = new ArrayList<String>();
groups.add("group1");
BlockingTaskSummaryResponseHandler taskSummaryResponseHandler = new BlockingTaskSummaryResponseHandler();
taskClient.getTasksAssignedAsPotentialOwner(user, groups, "en-UK", taskSummaryResponseHandler);
List <TaskSummary> tasks = taskSummaryResponseHandler.getResults();
return this.convertTasks(tasks);
I am getting an EntityNotFoundException because it looks like its searching for users based on my group name.
Hibernate: select task0_.id as col_0_0_, task0_.processInstanceId as col_1_0_, names5_.text as col_2_0_, subjects3_.text as col_3_0_, descriptio4_.text as col_4_0_, task0_.status as col_5_0_, task0_.priority as col_6_0_, task0_.skipable as col_7_0_, task0_.actualOwner_id as col_8_0_, task0_.createdBy_id as col_9_0_, task0_.createdOn as col_10_0_, task0_.activationTime as col_11_0_, task0_.expirationTime as col_12_0_, task0_.processId as col_13_0_, task0_.processSessionId as col_14_0_ from Task task0_ left outer join OrganizationalEntity user1_ on task0_.createdBy_id=user1_.id left outer join OrganizationalEntity user2_ on task0_.actualOwner_id=user2_.id left outer join I18NText subjects3_ on task0_.id=subjects3_.Task_Subjects_Id left outer join I18NText descriptio4_ on task0_.id=descriptio4_.Task_Descriptions_Id left outer join I18NText names5_ on task0_.id=names5_.Task_Names_Id inner join OrganizationalEntity user7_ on task0_.actualOwner_id=user7_.id inner join OrganizationalEntity user8_ on task0_.createdBy_id=user8_.id cross join OrganizationalEntity organizati6_ where task0_.archived=0 and (organizati6_.id=? or organizati6_.id in (?)) and (organizati6_.id in (select potentialo9_.entity_id from PeopleAssignments_PotOwners potentialo9_ where task0_.id=potentialo9_.task_id)) and (names5_.language=? or (select count(names10_.Task_Names_Id) from I18NText names10_ where task0_.id=names10_.Task_Names_Id)=0) and (subjects3_.language=? or (select count(subjects11_.Task_Subjects_Id) from I18NText subjects11_ where task0_.id=subjects11_.Task_Subjects_Id)=0) and (descriptio4_.language=? or (select count(descriptio12_.Task_Descriptions_Id) from I18NText descriptio12_ where task0_.id=descriptio12_.Task_Descriptions_Id)=0) and (task0_.status in ('Created' , 'Ready' , 'Reserved' , 'InProgress' , 'Suspended')) and (task0_.expirationTime is null)
Hibernate: select user0_.id as id9_0_ from OrganizationalEntity user0_ where user0_.id=? and user0_.DTYPE='User'
javax.persistence.EntityNotFoundException: Unable to find org.jbpm.task.User with id group1
at org.hibernate.ejb.Ejb3Configuration$Ejb3EntityNotFoundDelegate.handleEntityNotFound(Ejb3Configuration.java:137)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:233)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:285)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:152)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1090)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1038)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:630)
at org.hibernate.type.EntityType.resolve(EntityType.java:438)
at org.hibernate.type.EntityType.nullSafeGet(EntityType.java:234)
at org.hibernate.loader.hql.QueryLoader.getResultColumnOrRow(QueryLoader.java:407)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:639)
at org.hibernate.loader.Loader.doQuery(Loader.java:829)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
at org.hibernate.loader.Loader.doList(Loader.java:2542)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
at org.hibernate.loader.Loader.list(Loader.java:2271)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:459)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:365)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1268)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:246)
at org.jbpm.task.service.TaskServiceSession.getTasksAssignedAsPotentialOwner(TaskServiceSession.java:730)
at org.jbpm.task.service.TaskServerHandler.messageReceived(TaskServerHandler.java:375)
at org.jbpm.task.service.mina.MinaTaskServerHandler.messageReceived(MinaTaskServerHandler.java:41)
at org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.messageReceived(DefaultIoFilterChain.java:713)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46)
at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:793)
at org.apache.mina.filter.codec.ProtocolCodecFilter$ProtocolDecoderOutputImpl.flush(ProtocolCodecFilter.java:375)
at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:229)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46)
at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:793)
at org.apache.mina.filter.logging.LoggingFilter.messageReceived(LoggingFilter.java:176)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46)
at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:793)
at org.apache.mina.core.filterchain.IoFilterAdapter.messageReceived(IoFilterAdapter.java:119)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:426)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:638)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:598)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:587)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.access$400(AbstractPollingIoProcessor.java:61)
at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:969)
at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)
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)
I have made sure to add all of my users and groups to the TaskServiceSession.
What am I doing wrong?
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/766763#766763]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
13 years, 5 months
[JBoss Messaging] - java.lang.NullPointerException with factory.createQueueConnection
by Nigel Robbins
Nigel Robbins [https://community.jboss.org/people/nigel-robbins] created the discussion
"java.lang.NullPointerException with factory.createQueueConnection"
To view the discussion, visit: https://community.jboss.org/message/775766#775766
--------------------------------------------------------------
Hi,
Our system works fine but after a period of time (e.g. a few days) we are getting a java.lang.NullPointerException on calling factory.createQueueConnection.
Here is an extract of the code:
Hashtable<String,String> env = new Hashtable<String,String>();
env.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
env.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
env.put("java.naming.provider.url",aHost+":1099");
InitialContext ctx = new InitialContext(env);
QueueConnectionFactory factory = (QueueConnectionFactory) ctx.lookup("ConnectionFactory");
connection = factory.createQueueConnection();
The stack trace is at the bottom.
One thing we've noticed is that in wrapper.log on the server we are sending the message to, around the same time of the NullPointerException, the following is logged:
WARN | wrapper | 2012/11/01 10:01:34 | ------------------------------------------------------------------------
WARN | wrapper | 2012/11/01 10:01:34 | Shutdown: Timed out waiting for the JVM to terminate.
WARN | wrapper | 2012/11/01 10:01:34 | The JVM was launched with debug options so this may be because the JVM
WARN | wrapper | 2012/11/01 10:01:34 | is currently suspended by a debugger. Any future timeouts during this
WARN | wrapper | 2012/11/01 10:01:34 | JVM invocation will be silently ignored.
WARN | wrapper | 2012/11/01 10:01:34 | ------------------------------------------------------------------------
INFO | wrapper | 2012/11/01 10:08:43 | User logged out. Ignored.
STATUS | wrapper | 2012/11/01 10:08:45 | Machine is shutting down.
STATUS | wrapper | 2012/11/01 10:09:24 | --> Wrapper Started as Service
WARN | wrapper | 2012/11/01 10:09:25 | ------------------------------------------------------------------------
WARN | wrapper | 2012/11/01 10:09:25 | The JVM is being launched with a debugger enabled and could possibly be
WARN | wrapper | 2012/11/01 10:09:25 | suspended. To avoid unwanted shutdowns, timeouts will be disabled,
WARN | wrapper | 2012/11/01 10:09:25 | removing the ability to detect and restart frozen JVMs.
WARN | wrapper | 2012/11/01 10:09:25 | ------------------------------------------------------------------------
STATUS | wrapper | 2012/11/01 10:09:25 | Launching a JVM...
Any thoughts on why it's crashing on calling factory.createQueueConnection and why the JVM is restarting on the remote host ?
Note that both systems are on Windows and have the following setting in service.bat:
set JAVA_OPTS=-Xrs
Thanks !
Stack trace:
2012-11-08 09:25:53,252 ERROR [STDERR] (http-0.0.0.0-18080-9) at org.jboss.remoting.Client.addConnectionListener(Client.java:465)
2012-11-08 09:25:53,252 ERROR [STDERR] (http-0.0.0.0-18080-9) at org.jboss.jms.client.remoting.JMSRemotingConnection.addConnectionListener(JMSRemotingConnection.java:502)
2012-11-08 09:25:53,252 ERROR [STDERR] (http-0.0.0.0-18080-9) at org.jboss.jms.client.container.StateCreationAspect.handleCreateConnectionDelegate(StateCreationAspect.java:101)
2012-11-08 09:25:53,252 ERROR [STDERR] (http-0.0.0.0-18080-9) at org.jboss.aop.advice.org.jboss.jms.client.container.StateCreationAspect_z_handleCreateConnectionDelegate_12944434.invoke(StateCreationAspect_z_handleCreateConnectionDelegate_12944434.java)
2012-11-08 09:25:53,268 ERROR [STDERR] (http-0.0.0.0-18080-9) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
2012-11-08 09:25:53,268 ERROR [STDERR] (http-0.0.0.0-18080-9) at org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate.createConnectionDelegate(ClientConnectionFactoryDelegate.java)
2012-11-08 09:25:53,268 ERROR [STDERR] (http-0.0.0.0-18080-9) at org.jboss.jms.client.JBossConnectionFactory.createConnectionInternal(JBossConnectionFactory.java:205)
2012-11-08 09:25:53,268 ERROR [STDERR] (http-0.0.0.0-18080-9) at org.jboss.jms.client.JBossConnectionFactory.createQueueConnection(JBossConnectionFactory.java:101)
2012-11-08 09:25:53,268 ERROR [STDERR] (http-0.0.0.0-18080-9) at org.jboss.jms.client.JBossConnectionFactory.createQueueConnection(JBossConnectionFactory.java:95)
2012-11-08 09:25:53,268 ERROR [STDERR] (http-0.0.0.0-18080-9) at com.wss.turnover.JTSProcessRecord.sendGUIMessages(Unknown Source)
2012-11-08 09:25:53,268 ERROR [STDERR] (http-0.0.0.0-18080-9) at org.apache.jsp.jsp.JTSTurnoverProcess_jsp._jspService(JTSTurnoverProcess_jsp.java:286)
2012-11-08 09:25:53,268 ERROR [STDERR] (http-0.0.0.0-18080-9) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
2012-11-08 09:25:53,268 ERROR [STDERR] (http-0.0.0.0-18080-9) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
2012-11-08 09:25:53,284 ERROR [STDERR] (http-0.0.0.0-18080-9) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
2012-11-08 09:25:53,284 ERROR [STDERR] (http-0.0.0.0-18080-9) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322)
2012-11-08 09:25:53,284 ERROR [STDERR] (http-0.0.0.0-18080-9) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)
2012-11-08 09:25:53,284 ERROR [STDERR] (http-0.0.0.0-18080-9) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
2012-11-08 09:25:53,284 ERROR [STDERR] (http-0.0.0.0-18080-9) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
2012-11-08 09:25:53,284 ERROR [STDERR] (http-0.0.0.0-18080-9) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
2012-11-08 09:25:53,284 ERROR [STDERR] (http-0.0.0.0-18080-9) at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
2012-11-08 09:25:53,284 ERROR [STDERR] (http-0.0.0.0-18080-9) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
2012-11-08 09:25:53,284 ERROR [STDERR] (http-0.0.0.0-18080-9) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
2012-11-08 09:25:53,284 ERROR [STDERR] (http-0.0.0.0-18080-9) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
2012-11-08 09:25:53,299 ERROR [STDERR] (http-0.0.0.0-18080-9) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
2012-11-08 09:25:53,299 ERROR [STDERR] (http-0.0.0.0-18080-9) at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:183)
2012-11-08 09:25:53,299 ERROR [STDERR] (http-0.0.0.0-18080-9) at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:95)
2012-11-08 09:25:53,299 ERROR [STDERR] (http-0.0.0.0-18080-9) at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
2012-11-08 09:25:53,299 ERROR [STDERR] (http-0.0.0.0-18080-9) at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
2012-11-08 09:25:53,299 ERROR [STDERR] (http-0.0.0.0-18080-9) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
2012-11-08 09:25:53,299 ERROR [STDERR] (http-0.0.0.0-18080-9) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
2012-11-08 09:25:53,299 ERROR [STDERR] (http-0.0.0.0-18080-9) at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
2012-11-08 09:25:53,299 ERROR [STDERR] (http-0.0.0.0-18080-9) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
2012-11-08 09:25:53,299 ERROR [STDERR] (http-0.0.0.0-18080-9) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
2012-11-08 09:25:53,299 ERROR [STDERR] (http-0.0.0.0-18080-9) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
2012-11-08 09:25:53,299 ERROR [STDERR] (http-0.0.0.0-18080-9) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
2012-11-08 09:25:53,315 ERROR [STDERR] (http-0.0.0.0-18080-9) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
2012-11-08 09:25:53,315 ERROR [STDERR] (http-0.0.0.0-18080-9) at java.lang.Thread.run(Thread.java:619)
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/775766#775766]
Start a new discussion in JBoss Messaging at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
13 years, 5 months
[jBPM] - Human task : assign the good task to the launcher of a processInstance
by Sandra Renaud
Sandra Renaud [https://community.jboss.org/people/joploya] created the discussion
"Human task : assign the good task to the launcher of a processInstance"
To view the discussion, visit: https://community.jboss.org/message/775721#775721
--------------------------------------------------------------
Hello,
I have a confusion between the processInstance and the Task with Jbpm5.
My scenario is as explain bellow :
https://community.jboss.org/servlet/JiveServlet/showImage/2-775721-19863/... https://community.jboss.org/servlet/JiveServlet/downloadImage/2-775721-19...
1/ A user enters in the application and starts a new processInstance of a jbpm process.
ProcessInstance process = ksession.startProcess("com.st.ams.flow.npl", params);
System.out.println("process = "+process.getProcessId()+" : "+process.getProcessName()+" : state("+process.getState()+")");
2/ A new task is created in the database in the state Ready with the name "startNPLRequest_PM_PL", and with this code I am abble to see that my user can claim this task and complete it :
//Now the PM_PL process his task (it is already complete in reality)
List<String> groups = new ArrayList<String>();
groups.add(requestor.getRole());
System.out.println("Groups : ");
for(String grp : groups){
System.out.println(" - "+grp);
}
BlockingTaskSummaryResponseHandler taskSummaryResponseHandler = new BlockingTaskSummaryResponseHandler();
amsKnowledgeSession.getClient().getTasksAssignedAsPotentialOwner(requestor.getName(), groups, "en-UK", taskSummaryResponseHandler);
List<TaskSummary> potentialTasks = taskSummaryResponseHandler.getResults();
for(TaskSummary task : potentialTasks){
System.out.println("PM_PL can execute task " + task.getName() + " (" + task.getId() + " : " + task.getDescription() + ")");
}
3/ The problem is that several users with the role PM_PL will launch this process at the same time, so how can I assign the good task (of the good process but I know the processId) to my user?
I have not find the link between processId and taskId. And I need the taskId to start the task :
amsKnowledgeSession.getClient().start( taskId, requestorId, taskSummaryResponseHandler );
In the documentation we have this explanation but I don't really understand it :
> // adding a task
>
> BlockingAddTaskResponseHandler addTaskResponseHandler = new BlockingAddTaskResponseHandler();
>
> Task task = ...;
>
> client.addTask( task, null, addTaskResponseHandler );
>
> long taskId = addTaskResponseHandler.getTaskId();
It must be a very simple question but I will be very happy if someone can explain me this concept.
Regards,
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/775721#775721]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
13 years, 5 months
[JNDI and Naming] - Remote connection failed - Authentication failed: all available authentication mechanisms failed
by Laura delli Paoli
Laura delli Paoli [https://community.jboss.org/people/lauradp] created the discussion
"Remote connection failed - Authentication failed: all available authentication mechanisms failed"
To view the discussion, visit: https://community.jboss.org/message/775710#775710
--------------------------------------------------------------
Hello everybody,
I implemented this queue writer:
package writer;
import java.io.IOException;
import java.util.Properties;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
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;
/**
* @author Laura delli Paoli
*
*/
public class QueueWriter {
private final static String JMS_FACTORY="jms/RemoteConnectionFactory";
private ConnectionFactory conFactory;
private Connection con;
private Session session;
private static MessageProducer producer;
private Destination destination;
private static TextMessage msg;
private String username = null, password = null;
public QueueWriter(String username, String password, Context ctx, String destName) throws NamingException, JMSException {
super();
this.username = username;
this.password = password;
init(ctx, destName);
}
private void init(Context ctx, String destName)throws NamingException, JMSException {
conFactory = (ConnectionFactory) ctx.lookup(JMS_FACTORY);
//*************** Creating Queue Connection using the UserName & Password *************************
con = conFactory.createConnection(username, password);
session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
destination = (Destination) ctx.lookup("jms/"+destName);
producer = session.createProducer(destination);
msg = session.createTextMessage();
con.start();
}
public void sendTextMsg(String mess) throws IOException, JMSException {
System.out.println("Generic Sender"+"\n"+"Following Messages has been sent !!!");
String [] colors = {"BLUE", "RED", "BLUE"};
for(int j=1;j<=3;j++) {
msg.setText("Message #" + j + ": "+mess); // Messages
msg.setStringProperty("color", colors[j-1]);
producer.send(msg); // Messages sent
System.out.println("Message ("+colors[j-1]+") sent = "+j +": " + msg.getText());
}
}
public static InitialContext getInitialContext(String PROVIDER_URL, String username, String password) {
/*Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
env.put(Context.PROVIDER_URL, PROVIDER_URL);
env.put(Context.SECURITY_PRINCIPAL, username);
env.put(Context.SECURITY_CREDENTIALS, password);
env.put("jboss.naming.client.ejb.context", true);*/
Context remoteContext = null;
try {
//remoteContext = new InitialContext(env);
remoteContext = new InitialContext();
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return (InitialContext) remoteContext;
}
public void close () throws JMSException {
if (producer != null) producer.close();
if (session != null) session.close();
if (con != null) con.close();
}
}
when I tryed to run in with the folllowing main:
package writer;
import java.io.IOException;
import java.util.Properties;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
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;
/**
* @author Laura delli Paoli
* mailto:l.dellipaoli@reply.it l.dellipaoli(a)reply.it
*/
public class QueueWriter {
// private static final String INITIAL_CONTEXT_FACTORY = "org.jboss.naming.remote.client.InitialContextFactory";
private final static String JMS_FACTORY="jms/RemoteConnectionFactory";
private ConnectionFactory conFactory;
private Connection con;
private Session session;
private static MessageProducer producer;
private Destination destination;
private static TextMessage msg;
private String username = null, password = null;
public QueueWriter(String username, String password, Context ctx, String destName) throws NamingException, JMSException {
super();
this.username = username;
this.password = password;
init(ctx, destName);
}
private void init(Context ctx, String destName)throws NamingException, JMSException {
conFactory = (ConnectionFactory) ctx.lookup(JMS_FACTORY);
//*************** Creating Queue Connection using the UserName & Password *************************
con = conFactory.createConnection(username, password);
session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
destination = (Destination) ctx.lookup("jms/"+destName);
producer = session.createProducer(destination);
msg = session.createTextMessage();
con.start();
}
public void sendTextMsg(String mess) throws IOException, JMSException {
System.out.println("Generic Sender"+"\n"+"Following Messages has been sent !!!");
String [] colors = {"BLUE", "RED", "BLUE"};
for(int j=1;j<=3;j++) {
msg.setText("Message #" + j + ": "+mess); // Messages
msg.setStringProperty("color", colors[j-1]);
producer.send(msg); // Messages sent
System.out.println("Message ("+colors[j-1]+") sent = "+j +": " + msg.getText());
}
}
public static InitialContext getInitialContext(String PROVIDER_URL, String username, String password) {
/*Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
env.put(Context.PROVIDER_URL, PROVIDER_URL);
env.put(Context.SECURITY_PRINCIPAL, username);
env.put(Context.SECURITY_CREDENTIALS, password);
env.put("jboss.naming.client.ejb.context", true);*/
Context remoteContext = null;
try {
//remoteContext = new InitialContext(env);
remoteContext = new InitialContext();
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return (InitialContext) remoteContext;
}
public void close () throws JMSException {
if (producer != null) producer.close();
if (session != null) session.close();
if (con != null) con.close();
}
}
I got the following excepiton:
9-nov-2012 9.57.19 org.xnio.Xnio <clinit>
INFO: XNIO Version 3.0.3.GA
9-nov-2012 9.57.22 org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.0.3.GA
9-nov-2012 9.57.24 org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 3.2.3.GA
9-nov-2012 9.57.40 org.jboss.remoting3.remote.RemoteConnection handleException
ERROR: JBREM000200: Remote connection failed: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed
javax.naming.NamingException: Failed to create remoting connection [Root exception is java.lang.RuntimeException: Operation failed with status WAITING]
at org.jboss.naming.remote.client.ClientUtil.namingException(ClientUtil.java:36)
at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:121)
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at writer.QueueWriter.getInitialContext(QueueWriter.java:73)
at writer.runWriter.main(runWriter.java:29)
Caused by: java.lang.RuntimeException: Operation failed with status WAITING
at org.jboss.naming.remote.protocol.IoFutureHelper.get(IoFutureHelper.java:89)
at org.jboss.naming.remote.client.NamingStoreCache.getRemoteNamingStore(NamingStoreCache.java:56)
at org.jboss.naming.remote.client.InitialContextFactory.getOrCreateCachedNamingStore(InitialContextFactory.java:166)
at org.jboss.naming.remote.client.InitialContextFactory.getOrCreateNamingStore(InitialContextFactory.java:139)
at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:104)
... 6 more
Undefined initial context
Can anyone help me?
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/775710#775710]
Start a new discussion in JNDI and Naming at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
13 years, 5 months