JBoss AS 5.1 JMS Queue NoInitialContextException - java

I am trying to learn about JMS Queue in JBoss, however I have run into an error. I am following the tutorial on this page: https://docs.jboss.org/jbossas/docs/Server_Configuration_Guide/4/html/JMS_Examples-A_Point_To_Point_Example.html
I get an error on this line: Object tmp = iniCtx.lookup("ConnectionFactory")
Here's the full error:
Jul 7, 2016 3:10:23 PM com.cloudlet.jms.SendRecvClient main
INFO: Begin SendRecvClient, now = 1467918623762
Jul 7, 2016 3:10:23 PM com.cloudet.jms.SendRecvClient sendRecvAsync
INFO: Begin sendRecvAsync
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at com.cloudlet.jms.SendRecvClient.setupPointToPoint(SendRecvClient.java:49)
at com.cloudlet.jms.SendRecvClient.sendRecvAsync(SendRecvClient.java:67)
at com.cloudlet.jms.SendRecvClient.main(SendRecvClient.java:106)
Exception in thread "main" java.lang.NullPointerException
at com.cloudlet.jms.SendRecvClient.sendRecvAsync(SendRecvClient.java:71)
at com.cloudlet.jms.SendRecvClient.main(SendRecvClient.java:106)
My code is exactly the same as the one in the link provided. I looked it up and found out I need some jndi.properties file inside the JBoss folder. Unfortunately, that file is not in the JBoss folder. I looked up some examples on what it would look like but every example was different.
How would I fix this? Thanks in advance!

Fixed it by manually making a Properties object with the necessary key/value pairs then passing it to the InitialContext constructor.
JBoss properties:
Properties properties = new Properties();
properties.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
properties.put("java.naming.provider.url", "jnp://localhost:1099");
properties.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
InitialContext context = new InitialContext(properties);
I get the same output from the provided link in the opening post.

Related

WebLogic doesn't loads class despite being on $domain/lib

I'm trying to add a AS400 jar to WebLogic classpath. I'm putting the jt400.jar inside $domain/lib/ as indicated by the readme.txt found in there. And when server starts I can see the line:
<Sep 14, 2017 7:12:28 PM CST> <Notice> <WebLogicServer> <BEA-000395> <The following extensions directory contents added to the end of the classpath:
{$domain}/lib/jt400.jar.>
But, when I'm testing my datasource stills throws the error message:
weblogic.common.resourcepool.ResourceSystemException: Cannot load driver class com.ibm.as400.access.AS400JDBCDriver for datasource 'MyDataSource'
I have verified that the class is indeed inside the given jar.
What am I doing wrong?
Finally I understand what was happening. I forgot to add to the question that the WebLogic had several managed cluster servers. After trying various approachs, I realized the error only occured when I selected one of the clusters I wanted that datasource to serve.
So in the end, the servers from that cluster also need the jar to connect to the selected datasource.

Exception starting AntiSamyFilter

I'm unable to run my group's web application on my local machine with the AntiSamy filter in place. The filter works on WebSphere on our development and production servers, and also runs fine on one of my colleagues' machine with what should be the same setup as mine, using Tomcat. However, on my machine and several other colleagues', if we try to start our server with AntiSamy filter in place, we get this error:
Oct 12, 2015 11:06:32 PM org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter AntiSamyFilter
java.lang.IllegalStateException: java.io.FileNotFoundException: C:\Users\myUsername\Documents\myWorkspaceDirectory.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\mobile3\WEB-INF\classes\antisamy-default.xml (The system cannot find the path specified)
I've looked in the directory cited, and there is an "antisamy-default.xml" file there, so I'm not sure where to begin to figure out what's causing the error.
Any help will be much appreciated!

Cannot find javadb client jar file for glassfish

I have wrote a simple EJB application and going to test it through a java application client. For that i am fetching the bean as below,
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
// glassfish default port value will be 3700,
props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
initialContext = new InitialContext(props);
helloWorld = (HelloWorldBean) initialContext
.lookup("HelloWorldBean/remote");
But i am getting below exception followed by lot of other null pointers,
03-Dec-2012 22:37:37
com.sun.enterprise.v3.server.CommonClassLoaderServiceImpl
findDerbyClient INFO: Cannot find javadb client jar file, derby jdbc
driver will not be available by default. java.lang.RuntimeException:
Orb initialization erorr at
org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getORB(GlassFishORBHelper.java:148)
I add this jar even in to build path but still the exception occured. Even i can found the derbyclient jar is there under glassfish\javadb\lib
Also i need to verify whether i run this client correctly?
its just after deploy the application, right click on client class and run as java application right?

How to connect a Glassfish client to Glassfish JMS server when thread creation is not allowed?

I have an application in which a client component is run in a "managed" environment (as an Adobe InDesign plugin). In this "managed" environment, it doesn't seem possible to create threads during execution, but only at application startup.
This client component connects to a Glassfish server through JNDI and RMI/IIOP to perform various EJB method calls that all work perfectly (except for some cumbersome CORBA serialization issues that are not important here). I would like to have it also connect using JMS, to perform some topic reading. The code I use to perform those topic reading is already under unit tests, making sure it can start, read the topic, and perform required integration (this is more an integration test than an unit test, but I have to be sure of my application communication layer, no ?). This code, when run in a unit test, perfectly works. Unfortunatly, when run from my client component (embedded in Indesign, and having no ability to create threads), it fails with a NullPointerException the following way :
29 mai 2012 18:07:22 com.sun.enterprise.connectors.ActiveRAFactory getActiveRA
INFO: Deployed RAR [ jmsra ] has inbound artifacts, but the runtime does not support it. Providing only outbound support
29 mai 2012 18:07:22 org.hibernate.validator.util.Version <clinit>
INFO: Hibernate Validator 4.2.0.Final
29 mai 2012 18:07:24 com.sun.messaging.jms.ra.ResourceAdapter start
INFO: MQJMSRA_RA1101: GlassFish MQ JMS Resource Adapter: Version: 4.5 (Build 29-b) Compile: Wed Feb 9 22:53:30 PST 2011
29 mai 2012 18:07:24 com.sun.messaging.jms.ra.ResourceAdapter start
INFO: MQJMSRA_RA1101: GlassFish MQ JMS Resource Adapter starting: broker is EMBEDDED, connection mode is Direct
29 mai 2012 18:12:58 com.sun.messaging.jms.blc.LifecycleManagedBroker start
GRAVE: MQJMSRA_RA4001: start:Aborting:Exception starting EMBEDDED broker=java.lang.NullPointerException
29 mai 2012 18:12:58 com.sun.messaging.jms.blc.LifecycleManagedBroker start
INFO: SJSMQ LifecycleManagedBroker configuration=
brokerInstanceName =imqbroker
brokerBindAddress =null
brokerPort =7676
brokerHomeDir =C:\Java-ext\glassfish3\mq
brokerLibDir =C:\Java-ext\glassfish3\mq\lib
brokerVarDir =C:\Java-ext\glassfish3\glassfish\domains\autocat\imq
brokerJavaDir =C:\Program Files\Java\jdk1.6.0_30\jre
brokerArgs =null
MasterBroker =null
brokerId =null
adminUsername =admin
adminPassword =<default>
adminPassFile =null
ConnectionURL =mq://localhost:7676/
dbType =null
dbProps ={}
dsProps ={}
useJNDIRmiServiceURL =true
useSSLJMXConnector =true
brokerEnableHA =false
clusterId =null
rmiRegistryPort =7776
startRmiRegistry =true
brokerStartTimeout = jmxServiceURL =null
60000
29 mai 2012 18:12:58 com.sun.enterprise.connectors.ActiveOutboundResourceAdapter init
GRAVE: RAR6035 : Resource adapter start failed.
javax.resource.spi.ResourceAdapterInternalException: MQJMSRA_RA4001: start:Aborting:Exception starting EMBEDDED broker=java.lang.NullPointerException
at com.sun.messaging.jms.blc.LifecycleManagedBroker.start(LifecycleManagedBroker.java:458)
at com.sun.messaging.jms.ra.ResourceAdapter.start(ResourceAdapter.java:380)
at com.sun.enterprise.connectors.ActiveOutboundResourceAdapter.startResourceAdapter(ActiveOutboundResourceAdapter.java:182)
at com.sun.enterprise.connectors.ActiveOutboundResourceAdapter.init(ActiveOutboundResourceAdapter.java:129)
at com.sun.enterprise.connectors.ActiveRAFactory.instantiateActiveResourceAdapter(ActiveRAFactory.java:135)
at com.sun.enterprise.connectors.ActiveRAFactory.createActiveResourceAdapter(ActiveRAFactory.java:106)
at com.sun.enterprise.connectors.service.ResourceAdapterAdminServiceImpl.createActiveResourceAdapter(ResourceAdapterAdminServiceImpl.java:212)
at com.sun.enterprise.connectors.ConnectorRuntime.createActiveResourceAdapter(ConnectorRuntime.java:379)
at com.sun.enterprise.resource.naming.AdministeredObjectFactory.getObjectInstance(AdministeredObjectFactory.java:107)
at javax.naming.spi.NamingManager.getObjectInstance(Unknown Source)
at com.sun.enterprise.naming.impl.SerialContext.getObjectInstance(SerialContext.java:556)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:514)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
at javax.naming.InitialContext.lookup(Unknown Source)
at fr.perigee.autocat.indesign.remoting.jndi.jms.AdapterJMSListener.getConsumer(AdapterJMSListener.java:261)
at fr.perigee.autocat.indesign.remoting.jndi.jms.AdapterJMSListener$AdapterJMSListenerRunnable.run(AdapterJMSListener.java:50)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRunAndReset(Unknown Source)
at java.util.concurrent.FutureTask.runAndReset(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: java.lang.NullPointerException
at com.sun.messaging.jmq.jmsclient.runtime.impl.BrokerInstanceImpl.start(BrokerInstanceImpl.java:211)
at com.sun.messaging.jms.blc.EmbeddedBrokerRunner.start(EmbeddedBrokerRunner.java:331)
at com.sun.messaging.jms.blc.LifecycleManagedBroker.start(LifecycleManagedBroker.java:454)
... 24 more
Caused by: java.lang.NullPointerException
at com.sun.messaging.jmq.jmsserver.data.TransactionList.<init>(TransactionList.java:182)
at com.sun.messaging.jmq.jmsserver.Broker._start(Broker.java:1170)
at com.sun.messaging.jmq.jmsserver.Broker.start(Broker.java:456)
at com.sun.messaging.jmq.jmsserver.BrokerProcess.start(BrokerProcess.java:164)
at com.sun.messaging.jmq.jmsserver.DirectBrokerProcess.start(DirectBrokerProcess.java:92)
at com.sun.messaging.jmq.jmsclient.runtime.impl.BrokerInstanceImpl.start(BrokerInstanceImpl.java:206)
... 26 more
From what I have discovered so far, client code obtains connection to JMS server (connection to mq://localhost://7676), but then fail to start a TransactionList. Uncompiled source code (thanks Jad !) shows that it fails there :
/* 182*/Globals.getClusterManager().addEventListener(((ClusterListener) (this)));
Trying to debug that, I also found that my client can't start the org.glassfish.enterprise.iiop.util.S1ASThreadPoolManager due to the same impossibility to create threads.
I guess there is something wrong somewhere, but what ? I don't know.
So, how can I tell the glassfish client environment that threads can only obtained from my personnal thread pool (created at application startup) instead of trying to create its own and failing miserably ?
Short version
I deployed my aplication using maven forgotting the jms-core.jar of Glassfish, as it is a runtime dependency of gf-client-module.jar, and my maven build only copied compile dependencies. Fixing the maven build fixed the issue.
Long version
Long version is more a story of fear, tears, and blood.
How did that clusterManager got null ?
As I initially had problems with that TransactionList associated ClusterManager, I tried to look into com.sun.messaging.jmq.jmsserver.Globals code how it was initialized. I foun d it was in a method aptly called Globals#initCLusterManager(MQAddress) which, using various class parameters (including a Properties object), loaded a ClusterManager that was to be used by my application. What ? A ClusterManager ? In client code ? What the hell is that (more on that later) ?
Anyway, that ClusterManager was loaded, but set to null afterwards (mainly due to a a use of loopback address in cluster config - once again, incredibly weird in a JMS client) ... So looking how it was initialized was apparently not the correct path to bug solving, which left me puzzled.
What to do when test pass, but production code stills bugs ?
As I said in question, I have a test, which does (to my understanding) exactly the same thing. Test always succeed, and production always fail. So there must be something different there, no ?
So i did something new to me : I put a breakpoint in that Globals#initClusterManager code, and tried to reach it using both code : production and test. As one may guess, breakpoint was reached in prod, but not in test ! So I moved my breakpoint at some place where I already knew it would be reached : ActiveRAFactory#getActiveRA(ConnectorDescriptor, String) ... (oh wait, no, I didn't put it there, but the place where I put that breakpoint told me the point where execution path became different was that method call, so I finally put my breakpoint there).
With that breakpoint, I immediatly noticed something strange : the call to
Collection<ActiveResourceAdapter> activeRAs = activeRAHabitat.getAllByContract(ActiveResourceAdapter.class);
returned different results depending upon the fact I was in test or in prod : I got 4 elements in my list in test (including the ActiveJmsResourceAdapter), but only 3 in production.
Different ResourceAdapter, but why ?
Then I was puzzled : I then tended to blame Glassfish HK2 for no other reason than being an IoC container I didn't yet know ... Turned out I was wrong, oh so wrong !
Revelation came from an expression eval in Eclipse debugger : I typed as an expression
com.sun.enterprise.connectors.jms.system.ActiveJmsResourceAdapter.class
And all i got was a ClassNotFoundException ... wait ... a ClassNotFoundException ? And this class is in jms-core.jar ? I'm pretty sure that jar is in my production folder, no ? ... No ? NO ?
God damn it !
Turned out the maven-dependency-plugin I use to copy jars in that folder uses copy-dependencies with an includeScope configured to "compile".
Crazy bug with simple solution
So I added an other execution to copy-dependencies, configured to incldueScope "runtime", and all worked OK.

Errors for running Mahout example

I downloaded the examples of latest version for chapter 09 of “Mahout in Action”. I can successfully run several examples, but for three files, NewsKMeansClustering.java, ReutersToSparseVectors.java, and NewsFuzzyKMeansClusteing.java. Running these three programs gives similar error messages:
Aug 3, 2011 2:03:54 PM org.apache.hadoop.metrics.jvm.JvmMetrics init
INFO: Initializing JVM Metrics with processName=JobTracker, sessionId=
Aug 3, 2011 2:03:54 PM org.apache.hadoop.mapred.JobClient configureCommandLineOptions
WARNING: Use GenericOptionsParser for parsing the arguments. Applications should
implement Tool for the same.
Aug 3, 2011 2:03:54 PM org.apache.hadoop.mapred.JobClient configureCommandLineOptions
WARNING: No job jar file set. User classes may not be found. See JobConf(Class) or
JobConf#setJar(String).
Exception in thread "main" org.apache.hadoop.mapreduce.lib.input.InvalidInputException: Input path does not exist: file:/home/user1/workspaceMahout1/recommender/inputDir
at org.apache.hadoop.mapreduce.lib.input.FileInputFormat.listStatus(FileInputFormat.java:224)
at org.apache.hadoop.mapreduce.lib.input.SequenceFileInputFormat.listStatus(SequenceFileInputFormat.java:55)
at org.apache.hadoop.mapreduce.lib.input.FileInputFormat.getSplits(FileInputFormat.java:241)
at org.apache.hadoop.mapred.JobClient.writeNewSplits(JobClient.java:885)
at org.apache.hadoop.mapred.JobClient.submitJobInternal(JobClient.java:779)
at org.apache.hadoop.mapreduce.Job.submit(Job.java:432)
at org.apache.hadoop.mapreduce.Job.waitForCompletion(Job.java:447)
at org.apache.mahout.vectorizer.DocumentProcessor.tokenizeDocuments(DocumentProcessor.java:93)
at mia.clustering.ch09.NewsKMeansClustering.main(NewsKMeansClustering.java:54)
For the above messages, I do not quite understand what do those two warnings mean? Moreover, it looks like that “input path” should have been created, how can I create this type of input? Thanks.
You can ignore the warnings. The error is that the input directory you have specified does not exist. Does it exist? What is your command line?
I ran into a similar mismatch. The MiA files at https://github.com/tdunning/MiA have some cases where a .csv file is left in the same dir as the Java source. For example https://github.com/tdunning/MiA/tree/master/src/main/java/mia/recommender/ch02 ... however via Eclipse, loading it using DataModel model = new FileDataModel(new File("intro.csv")); ...doesn't find it.
Adding
System.out.println("CWD: "+System.getProperty("user.dir"));
...will reveal where Eclipse is looking (in my case, a couple levels up the filetree, but this might vary depending on how exactly you've set things up).

Categories

Resources