Database lock acquisition failure and hsqldb - hsqldb

I was trying to connect to a hsql db. I created one by running from C:\myhsql:
java -cp .;C:\hsql\lib\hsqldb.jar org.hsqldb.Server -database.0 file:db\mydb -dbname.0 MYDB
This created mydb in a directory called db. This folder now has a .lck,tmp,script,properties files with name mydb, and similar files with name MYDB in current folder .
In java code I tried
Class.forName("org.hsqldb.jdbcDriver");
connection = DriverManager.getConnection("jdbc:hsqldb:file:db/sjdb", "SA", "");
When I run the program, I am getting this error:
java.sql.SQLException: Database lock acquisition failure: lockFile: org.hsqldb.persist.LockFile#f3811c1a[file =C:\myhsql\db\mydb.lc
k, exists=true, locked=false, valid=false, ] method: checkHeartbeat read: 2010-10-19 12:46:09 heartbeat - read: -6750 ms.
...
Here is the stacktrace:
java.sql.SQLException: Database lock acquisition failure: lockFile: org.hsqldb.persist.LockFile#f3811c1a[file =C:\myhsql\db\sjdb.lc
k, exists=true, locked=false, valid=false, ] method: checkHeartbeat read: 2010-10-19 12:46:09 heartbeat - read: -6750 ms.
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCConnection.<init>(Unknown Source)
at org.hsqldb.jdbc.JDBCDriver.getConnection(Unknown Source)
at org.hsqldb.jdbc.JDBCDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at ConnectHSQLDB.main(ConnectHSQLDB.java:20)
Caused by: org.hsqldb.HsqlException: Database lock acquisition failure: lockFile: org.hsqldb.persist.LockFile#f3811c1a[file =C:\myhsql\db\sjdb.lck, exists=true, locked=false, valid=false, ] method: checkHeartbeat read: 2010-10-19 12:46:09 heartbeat - read: -6750 ms.
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.persist.LockFile.newLockFileLock(Unknown Source)
at org.hsqldb.persist.Logger.acquireLock(Unknown Source)
at org.hsqldb.persist.Logger.openPersistence(Unknown Source)
at org.hsqldb.Database.reopen(Unknown Source)
at org.hsqldb.Database.open(Unknown Source)
at org.hsqldb.DatabaseManager.getDatabase(Unknown Source)
at org.hsqldb.DatabaseManager.newSession(Unknown Source)
... 6 more
java.lang.NullPointerException
at ConnectHSQLDB.main(ConnectHSQLDB.java:32)
Can somebody tell me what I am doing wrong? I can connect to the db using SwingDBManager and can insert, delete, and select records in the db. I was not running DBManager when I tried the java code. Still the lock problem happens.

The first command starts a server. This server locks the database files so that "others" cannot modify them. You should use "-dbname.0 mydb" instead of "MYDB" as it should be in lowercase.
Your Java connection URL to connect to the database is wrong. You should use "jdbc:hsqldb:hsql://localhost/mydb" as the connection string. While the database files are locked by the server, you can access the database server but you cannot access the database "in-process" with a file: URL.

I face this error because I wanted to view a currently opened database in another client like IntelliJ database while the server is using the same db
so to make hsql db able to be connected to multiple clients, use
hsqldb.lock_file=false
so the connection url will be like
jdbc:hsqldb:file:./db/myDbInFile;hsqldb.lock_file=false

If you have any other client running that connects to your db you need to close that.

Whatever way you have tried is correct.
You don't have to start the HSQLDB Server using seperate java command, below line is not required, as it will lock the database. Prevent other process from starting and locking db.
java -cp .;C:\hsql\lib\hsqldb.jar org.hsqldb.Server -database.0 file:db\mydb -dbname.0 MYDB
just run the jdbc program
java -cp hsqldb.jar HSQLAccess
below line
jdbc:hsqldb:file:db/sjdb
will start the database and will give result.
in this way you don't have to start the server seperately, just have to run the program, which will start and stop HSQLDB for you.
import java.sql.*;
public class HSQLAccess {
public static void main(String args[]) throws Exception
{
Connection con = null;
try
{
Class.forName("org.hsqldb.jdbcDriver");
con = DriverManager.getConnection("jdbc:hsqldb:file:db/sjdb", "sa","");
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("SELECT * FROM CMDS_WO_MASTER");
while(rs.next())
{
System.out.println(rs.getString(1));
}
con.close();
}
catch(Exception ex )
{
ex.printStackTrace();
}
finally
{
if(con!=null)
{
con.close();
}
}
}
}

try using the following connection url in windows
connection = DriverManager.getConnection("jdbc:hsqldb:file:///c:/hsqldb/mydb", "SA", "");

You can access HSQLDB database that has lock by:
1- updating my-db-name.properties file and add:
hsqldb.lock_file=false
2- or removing my-db-name.lck file.
3- or connect to the database using pass the properties as parameters:
#Without Sqltool:
java -cp [jar-path]/hsqldb-2.4.0.jar --inlineRc=url=jdbc:hsqldb:file:/[my-db-file-path]/[db-name];readonly=true;hsqldb.lock_file=false,user=sa
#With Sqltool
java -cp [jar-path]/hsqldb-2.4.0.jar:[jar-path]/sqltool-2.4.0.jar org.hsqldb.cmdline.SqlTool --inlineRc=url=jdbc:hsqldb:file:/[my-db-file-path]/[db-name];readonly=true;hsqldb.lock_file=false,user=sa
Other HSQLDB database parameters can be found here, however note that only few of them can be updated after first time.
http://hsqldb.org/doc/2.0/guide/dbproperties-chapt.html

on my Mac, the port for Connector on HTTP changed from 8080 to 8443 on server.xml. and that is what was giving me this error: both HTTP and HTTPS schema were using the same port

I just closed NetBeans, deleted database.lck and executed the application again. Everything worked fine.

I had the same situation with this error:
Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Database lock acquisition failure: lockFile: org.hsqldb.persist.LockFile#3ad4d20b[file =E:\workspace-dev\hexagonal\base\.lck, exists=true, locked=false, valid=false, ] method:
I closed the : HSQL Database Manager, and it worked fine for me!
I also had to put a slash at the end of the database url
#Bean
public DataSource dataSource() {
var ds = new SimpleDriverDataSource();
ds.setDriverClass(org.hsqldb.jdbcDriver.class);
ds.setUrl("jdbc:hsqldb:file:E:/workspace-dev/hexagonal/base/");
ds.setUsername("SA");
ds.setPassword("1234");
return ds;
}

I had the same error, the problem was caused by spaces at the of the Database URL from copy/pasting 😅

Related

Remote connection to Active-MQ Using JMX

I have a java application for monitoring the individual queues on Active MQ (version 5.13.0). The Objective of this application is to connect to the Active MQ broker and find out the in flight message count for specific queues. If the in flight message count is more than 50 then it sends an alert. This application performs this check every 10 minutes (Using Quartz Scheduler).
When I am connecting to the AMQ broker which uses the IP address to connect to the AMQ, I receive the IOException with the following stack trace -
java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:
java.net.ConnectException: Connection refused: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at javax.management.remote.rmi.RMIServerImpl_Stub.newClient(Unknown Source)
at javax.management.remote.rmi.RMIConnector.getConnection(Unknown Source)
at javax.management.remote.rmi.RMIConnector.connect(Unknown Source)
at javax.management.remote.JMXConnectorFactory.connect(Unknown Source)
at javax.management.remote.JMXConnectorFactory.connect(Unknown Source)
at com.globalcharge.quartz.job.CheckPendingConsumer.execute(CheckPendingConsumer.java:51)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown Source)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown Source)
... 12 more
I am using the following code to connect to the AMQ broker over JMX
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://192.168.11.72:1099/jmxrmi");
JMXConnector jmxc = JMXConnectorFactory.connect(url);
MBeanServerConnection conn = jmxc.getMBeanServerConnection();
ObjectName activeMq = new ObjectName("org.apache.activemq:Type=Broker,BrokerName=localhost");
BrokerViewMBean mbean = (BrokerViewMBean)MBeanServerInvocationHandler.newProxyInstance(conn, activeMq, BrokerViewMBean.class, true);
//for each queue
for(ObjectName name : mbean.getQueues())
{
if(("dbg.notmanager.netsizeDelivery".equals(name)))
{
//obtain an instance of QueueViewMBean
QueueViewMBean queueMbean = (QueueViewMBean)MBeanServerInvocationHandler.newProxyInstance(conn, name, QueueViewMBean.class, true);
long inFlight = queueMbean.getInFlightCount();
if(inFlight >= 50)
{
sender.sendPassiveCriticalAlert(hostname, "Passive.GCDBG", "InFlight Messages for a consumer on " + name);
}
}
Notes:
1. If I install the AMQ on my local machine and deploy the code above on Tomcat running on my local machine it works. What I mean is, when both (Java Client and AMQ ) are on same machine, it works.
2. I have done the necessary configurations on AMQ server as mentioned here configure JMX for ActiveMQ for remoting access
3. I have checked the connectivity to IP and port mentioned in the code through telnet and it works.
4. I have also recorded the TCP dump on the AMQ server machine and I can see the request reaching there.
5. Both machines (where Tomcat and AMQ run) are not virtual machines, but are dedicated physical machines in the same network.
Please help :)
as logs say Connection refused, i think connection configs error.
you need these credentials too
JMXServiceURL url = ...;
Map env = ...;
String[] creds = {"admin", "activemq"};
env.put(JMXConnector.CREDENTIALS, creds);
JMXConnector jmxc = JMXConnectorFactory.connect(url, env);
I am able to connect now using the JConsole as well as the Java Code I have written. The Problem was in the env file (under amqHome/bin/) had a property java.rmi.server.hostname which had a value 127.0.0.1
I changed this value to 192.168.11.72 (the IP of the machine) and it worked ....
Thanks all for the support ....

JDBC client to Hive - No data or no sasl data in the stream Exception

We have a Kerberised cluster and I'm trying to run a Java action in Oozie where I make a JDBC connection to Hive. This JDBC connections works fine on the Sandbox without Kerberos.
The connection string is as simple as the following, where I'm providing username and password in it:
Connection con = DriverManager.getConnection("jdbc:hive2://W12345:10000/control;principal=hive/W12345.companynet.net#COMPANYNET.NET","user123","passw123");
The Oozie action (strangely) completes succesfully, and the Java action log does not present any error:
1742 [main] INFO org.apache.hive.jdbc.Utils - Supplied authorities: W12345:10000
1742 [main] INFO org.apache.hive.jdbc.Utils - Resolved authority: W12345:10000
1766 [main] INFO org.apache.hive.jdbc.HiveConnection - Will try to open client transport with JDBC Uri: jdbc:hive2://W12345:10000/control;principal=hive/W12345.companynet.net#COMPANYNET.NET
<<< Invocation of Main class completed <<<
Oozie Launcher ends
1785 [main] INFO org.apache.hadoop.mapred.Task - Task:attempt_1464245290012_0129_m_000000_0 is done. And is in the process of committing
1847 [main] INFO org.apache.hadoop.mapred.Task - Task attempt_1464245290012_0129_m_000000_0 is allowed to commit now
1854 [main] INFO org.apache.hadoop.mapreduce.lib.output.FileOutputCommitter - Saved output of task 'attempt_1464245290012_0129_m_000000_0' to hdfs://danskehadoop/user/user123/oozie-oozi/0000013-160527101253015-oozie-oozi-W/JavaAction--java/output/_temporary/1/task_1464245290012_0129_m_000000
1909 [main] INFO org.apache.hadoop.mapred.Task - Task 'attempt_1464245290012_0129_m_000000_0' done.
But in reality the Java main does not complete correctly the execution (and does not execute the needed queries) because the JDBC connection fails with an exception that I can see only in the Hive log:
ERROR [HiveServer2-Handler-Pool: Thread-78363]: server.TThreadPoolServer (TThreadPoolServer.java:run(296)) - Error occurred during processing of message.
java.lang.RuntimeException: org.apache.thrift.transport.TSaslTransportException: No data or no sasl data in the stream
at org.apache.thrift.transport.TSaslServerTransport$Factory.getTransport(TSaslServerTransport.java:219)
at org.apache.hadoop.hive.thrift.HadoopThriftAuthBridge$Server$TUGIAssumingTransportFactory$1.run(HadoopThriftAuthBridge.java:739)
at org.apache.hadoop.hive.thrift.HadoopThriftAuthBridge$Server$TUGIAssumingTransportFactory$1.run(HadoopThriftAuthBridge.java:736)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1637)
at org.apache.hadoop.hive.thrift.HadoopThriftAuthBridge$Server$TUGIAssumingTransportFactory.getTransport(HadoopThriftAuthBridge.java:736)
at org.apache.thrift.server.TThreadPoolServer$WorkerProcess.run(TThreadPoolServer.java:268)
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)
Caused by: org.apache.thrift.transport.TSaslTransportException: No data or no sasl data in the stream
at org.apache.thrift.transport.TSaslTransport.open(TSaslTransport.java:328)
at org.apache.thrift.transport.TSaslServerTransport.open(TSaslServerTransport.java:41)
at org.apache.thrift.transport.TSaslServerTransport$Factory.getTransport(TSaslServerTransport.java:216)
... 10 more
I'm actually connected to the cluster, and already done further kinit on my username.
Does anybody know what could the cause of this exception be?
Thanks in advance for the help!
Antonio
This happened to me on MapR hadoop distribution platform.
In my case it was Keepalived checking Hive port every 5 seconds and producing such error. I simply used "nc" command to check if Hive port is in use and did not use any authentication method. Later I switched to "maprcli" command which uses SASL authentication and the error was gone.

Apache Drill Impersonation

I'm trying to build in security on our Drill (1.6.0) system. I managed to get the security user authentication to work(JPam as explained in the documentation), but the impersonation does not seem to work. It seems to execute and fetch via the the admin user regardless of who has logged in via ODBC.
My drill-override.conf file is configured as follows:
drill.exec: {
cluster-id: "drillbits1",
zk.connect: "localhost:2181",
impersonation: {
enabled: true,
max_chained_user_hops: 3
},
security.user.auth {
enabled: true,
packages += "org.apache.drill.exec.rpc.user.security",
impl: "pam",
pam_profiles: [ "sudo", "login" ]
}
}
We are also only using Drill on one server, therefore I'm running drill-embedded to start things up. Troubleshooting:
root#srv001:/opt/apache-drill-1.6.0# bin/sqlline -u "jdbc:drill:schema=dfs;zk=localhost:2181;impersonation_target=dUser001" -n entryUser -p entryUserPassword
Error: Failure in connecting to Drill: org.apache.drill.exec.rpc.RpcException: Failure setting up ZK for client. (state=,code=0)
java.sql.SQLException: Failure in connecting to Drill: org.apache.drill.exec.rpc.RpcException: Failure setting up ZK for client.
at org.apache.drill.jdbc.impl.DrillConnectionImpl.<init> (DrillConnectionImpl.java:159)
at org.apache.drill.jdbc.impl.DrillJdbc41Factory.newDrillConnection(DrillJdbc41Factory.java:64)
at org.apache.drill.jdbc.impl.DrillFactory.newConnection(DrillFactory.java:69)
at net.hydromatic.avatica.UnregisteredDriver.connect(UnregisteredDriver.java:126)
at org.apache.drill.jdbc.Driver.connect(Driver.java:72)
at sqlline.DatabaseConnection.connect(DatabaseConnection.java:167)
at sqlline.DatabaseConnection.getConnection(DatabaseConnection.java:213)
at sqlline.Commands.connect(Commands.java:1083)
at sqlline.Commands.connect(Commands.java:1015)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at sqlline.ReflectiveCommandHandler.execute(ReflectiveCommandHandler.java:36)
at sqlline.SqlLine.dispatch(SqlLine.java:742)
at sqlline.SqlLine.initArgs(SqlLine.java:528)
at sqlline.SqlLine.begin(SqlLine.java:596)
at sqlline.SqlLine.start(SqlLine.java:375)
at sqlline.SqlLine.main(SqlLine.java:268)
Caused by: org.apache.drill.exec.rpc.RpcException: Failure setting up ZK for client.
at org.apache.drill.exec.client.DrillClient.connect(DrillClient.java:200)
at org.apache.drill.jdbc.impl.DrillConnectionImpl.<init>(DrillConnectionImpl.java:151)
... 18 more
Caused by: java.io.IOException: Failure to connect to the zookeeper cluster service within the allotted time of 10000 milliseconds.
at org.apache.drill.exec.coord.zk.ZKClusterCoordinator.start(ZKClusterCoordinator.java:123)
at org.apache.drill.exec.client.DrillClient.connect(DrillClient.java:198)
... 19 more
Any ideas on this?
I have also looked at doing my own built in security, but I'm not able to retrieve the username from a SQL query. I have tried the following without any luck:
CURRENT_USER()
USER()
SESSION_USER()
Any ideas on this approach?
I suggest to create a different pam profile (say drill) rather than login and sudo.
Then create drill file under /etc/pam.d/ directory with the content:
#%PAM-1.0
auth include password-auth
account include password-auth
To get connections run:
select * from sys.connections;

Spring Session, Embedded Redis Server Error

Unable to start embedded Redis server, its giving the following error. What could be the possible reason. I'm working on Wildfly, Ubuntu. Following is the stacktrace.
... 25 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisServer' defined in org.egov.infra.config.session.RedisHttpSessionConfiguration: Invocation of init method failed; nested exception is java.lang.RuntimeException: Can't start redis server. Check logs for details.
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1566)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:116)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:606)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:462)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:93)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [rt.jar:1.8.0_31]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) [rt.jar:1.8.0_31]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [rt.jar:1.8.0_31]
at java.lang.reflect.Constructor.newInstance(Constructor.java:408) [rt.jar:1.8.0_31]
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
... 27 more
Caused by: java.lang.RuntimeException: Can't start redis server. Check logs for details.
at redis.embedded.AbstractRedisInstance.awaitRedisServerReady(AbstractRedisInstance.java:66)
at redis.embedded.AbstractRedisInstance.start(AbstractRedisInstance.java:37)
at redis.embedded.RedisServer.start(RedisServer.java:11)
at org.egov.infra.config.redis.EmbeddedRedisServer.afterPropertiesSet(EmbeddedRedisServer.java:20)
This is a bug that has been reported here https://github.com/spring-projects/spring-session/issues/150
In my case I was running embedded redis-server on port 1337 and this port was locked and went into a loop sometime back when I was running my testcases in debug mode. After that I also started spring-boot app which created another server connection on the port 6379. But I failed to terminate the server running on the port 1337. Since then I had been getting the exception when I was trying to execute test cases "Can't start redis server. Check logs for details.", since 1337 was locked. Debugging line-my-line "AbstractRedisInstance" class and "awaitRedisServerReady" method revealed "1337 Already in use" which was never logged at all. Killed this port and re-run testcases and again I was on fly. Hope this helps

AS 7.1.1 : JNDI Look up for JMS connection factroy is not working

I am trying to write a sample program for JMS using Jboss. I went through the following link for how to use Jboss for JMS
http://docs.jboss.org/jbossmessaging/docs/usermanual-2.0.0.beta1/html/using-jms.html
I am getting an exception while looking up for ConnectionFactory i.e. "iniCtx.lookup("ConnectionFactory")"
javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out]
at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1058)
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1127)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:478)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:471)
at javax.naming.InitialContext.lookup(Unknown Source)
at MessageProducer.main(MessageProducer.java:46)
Caused by: java.net.SocketTimeoutException: Receive timed out
at java.net.PlainDatagramSocketImpl.receive0(Native Method)
at java.net.PlainDatagramSocketImpl.receive(Unknown Source)
at java.net.DatagramSocket.receive(Unknown Source)
at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1038)
The reason is, Jboss Naming Service is not running(netstat -an doesn't show any result for port 1099) .
I didn't configure any specific setting for Naming Service. I let it to take default port 1099.
Am I missing any configuration? Kindly help me in running the Jboss naming service.
Specification :
Jboss : AS 7.1.1 Final
JRE : 1.6
OS : Windows 7
Seems that you mixed Jboss version with manual version. AS7 does not use jnp and the jndi port is 4447.
So having following setup in standalone-full.xml
<security-enabled>false</security-enabled>
...
<jms-destinations>
<jms-queue name="testQueue">
<entry name="queue/test"/>
<entry name="java:jboss/exported/jms/queue/test"/>
</jms-queue>
</jms-destinations>
I am able to connect with client, code as follows:
Connection connection = null;
InitialContext initialContext = null;
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
props.put(Context.PROVIDER_URL, "remote://localhost:4447");
props.put(Context.SECURITY_PRINCIPAL, "appuser");
props.put(Context.SECURITY_CREDENTIALS, "password");
try {
// Step 1. Create an initial context to perform the JNDI lookup.
initialContext = new InitialContext(props);
// Step 2. Perfom a lookup on the queue
Queue queue = (Queue)initialContext.lookup("jms/queue/test");
// Step 3. Perform a lookup on the Connection Factory
ConnectionFactory cf = (ConnectionFactory)initialContext.lookup("jms/RemoteConnectionFactory");
// Step 4.Create a JMS Connection
connection = cf.createConnection();