I am using Selenium for web application testing. After having finished all the testing, when the command "selenium.stop()" is executed I get the following exception:
java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:519)
at java.net.Socket.connect(Socket.java:469)
at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:760)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:632)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1049)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:373)
at com.thoughtworks.selenium.HttpCommandProcessor.getResponseCode(HttpCommandProcessor.java:134)
at com.thoughtworks.selenium.HttpCommandProcessor.getCommandResponseAsString(HttpCommandProcessor.java:154)
at com.thoughtworks.selenium.HttpCommandProcessor.executeCommandOnServlet(HttpCommandProcessor.java:97)
at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:79)
at com.thoughtworks.selenium.HttpCommandProcessor.stop(HttpCommandProcessor.java:242)
at com.thoughtworks.selenium.DefaultSelenium.stop(DefaultSelenium.java:111)
at seleniumproject.orkut.tearDown(orkut.java:54)
at junit.framework.TestCase.runBare(TestCase.java:140)
at com.thoughtworks.selenium.SeleneseTestCase.runBare(SeleneseTestCase.java:212)
at junit.framework.TestResult$1.protect(TestResult.java:110)
E
at junit.framework.TestResult.runProtected(TestResult.java:128)
Time: 63.453
There was 1 error:
1) testOrkut(seleniumproject.orkut)java.lang.UnsupportedOperationException: Catch body broken: IOException from cmd=testComplete -> java.net.ConnectException: Connection refused: connect
at com.thoughtworks.selenium.HttpCommandProcessor.executeCommandOnServlet(HttpCommandProcessor.java:100)
at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:79)
at com.thoughtworks.selenium.HttpCommandProcessor.stop(HttpCommandProcessor.java:242)
at com.thoughtworks.selenium.DefaultSelenium.stop(DefaultSelenium.java:111)
at seleniumproject.orkut.tearDown(orkut.java:54)
at com.thoughtworks.selenium.SeleneseTestCase.runBare(SeleneseTestCase.java:212)
at seleniumproject.orkut.main(orkut.java:57)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at junit.framework.TestResult.run(TestResult.java:113)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at junit.framework.TestCase.run(TestCase.java:124)
at java.net.Socket.connect(Socket.java:519)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at java.net.Socket.connect(Socket.java:469)
at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
at junit.framework.TestSuite.run(TestSuite.java:227)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
at junit.textui.TestRunner.doRun(TestRunner.java:116)
at junit.textui.TestRunner.doRun(TestRunner.java:109)
at junit.textui.TestRunner.run(TestRunner.java:77)
at seleniumproject.orkut.main(orkut.java:57)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:760)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:632)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1049)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:373)
at com.thoughtworks.selenium.HttpCommandProcessor.getResponseCode(HttpCommandProcessor.java:134)
at com.thoughtworks.selenium.HttpCommandProcessor.getCommandResponseAsString(HttpCommandProcessor.java:154)
at com.thoughtworks.selenium.HttpCommandProcessor.executeCommandOnServlet(HttpCommandProcessor.java:97)
... 16 more
Here's is code which is executing the stop() command
public class orkut extends SeleneseTestCase {
public void setUp() throws Exception {
setUp("https://www.google.com/");
}
public void testOrkut() throws Exception {
Parser parser = new Parser();
try {
.......
.......
.......
}catch(Exception ex) {
}finally {
parser.closeConnection();
selenium.shutDownSeleniumServer();
}
}
public static Test suite() {
return new TestSuite(orkut.class);
}
public void tearDown(){
selenium.stop();
}
public static void main(String args[]) {
junit.textui.TestRunner.run(suite());
}
}
It looks like your shutting down the Selenium server before the command to close the browser session. Try commenting out the line with selenium.shutDownSeleniumServer();
I was getting the same error. I cleared my jar files and re-added them and the exception was gone.
Related
This is my testrunner file. It throws exception in the tearDownClass().
public class testrunner extends AbstractTestNGCucumberTests {
private TestNGCucumberRunner testNGCucumberRunner;
WebDriver driver;
WebDriverManager webDriverManager;
#BeforeClass(alwaysRun = true)
public void setUpClass() {
if(testNGCucumberRunner == null){
testNGCucumberRunner = new TestNGCucumberRunner(this.getClass());
}
}
#Test(dataProvider = "scenarios")
public void feature(PickleEventWrapper pickleEvent, CucumberFeatureWrapper cucumberFeature) throws Throwable {
testNGCucumberRunner.runScenario(pickleEvent.getPickleEvent());
}
#Override
#DataProvider(parallel=true)
public Object[][] scenarios() {
return testNGCucumberRunner.provideScenarios();
}
#AfterClass(alwaysRun = true)
public void tearDownClass() {
testNGCucumberRunner.finish();
}
}
From the console:
FAILURE! - in runner.testrunner
runScenario(runner.testrunner) Time elapsed: 0.01 sec <<< FAILURE!
java.lang.NullPointerException
runScenario(runner.testrunner) Time elapsed: 0.011 sec <<< FAILURE!
java.lang.NullPointerException
tearDownClass(runner.testrunner) Time elapsed: 56.248 sec <<< FAILURE!
java.lang.RuntimeException: java.io.IOException: Stream closed
at runner.testrunner.tearDownClass(testrunner.java:82)
Caused by: java.io.IOException: Stream closed
at runner.testrunner.tearDownClass(testrunner.java:82)
Results :
Failed tests:
runner.testrunner.runScenario(runner.testrunner)
Run 1: testrunner>AbstractTestNGCucumberTests.runScenario:24 » NullPointer
Run 2: testrunner>AbstractTestNGCucumberTests.runScenario:24 » NullPointer
testrunner.tearDownClass:82 » Runtime java.io.IOException: Stream closed
i have been trying to get a Spring RabbitMQ publisher with publisher confirms turned on . The first calls goes through fine and confirm callback is returned. from second call onwards it fails with following error message
javax.servlet.ServletException: org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.amqp.UncategorizedAmqpException: java.lang.IllegalArgumentException: Listener not registered: org.springframework.amqp.rabbit.core.RabbitTemplate#42802df2 []
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:146)
at org.eclipse.jetty.server.handler.StatisticsHandler.handle(StatisticsHandler.java:169)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.Server.handle(Server.java:564)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:317)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:128)
at org.eclipse.jetty.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:199)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:672)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:590)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.amqp.UncategorizedAmqpException: java.lang.IllegalArgumentException: Listener not registered: org.springframework.amqp.rabbit.core.RabbitTemplate#42802df2 []
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:982)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:841)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:535)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1253)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1155)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126)
... 15 common frames omitted
Caused by: org.springframework.amqp.UncategorizedAmqpException: java.lang.IllegalArgumentException: Listener not registered: org.springframework.amqp.rabbit.core.RabbitTemplate#42802df2 []
at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:83)
at org.springframework.amqp.rabbit.core.RabbitTemplate.doSendAndReceiveWithDirect(RabbitTemplate.java:1650)
at org.springframework.amqp.rabbit.core.RabbitTemplate.doSendAndReceive(RabbitTemplate.java:1531)
at org.springframework.amqp.rabbit.core.RabbitTemplate.sendAndReceive(RabbitTemplate.java:1320)
at com.example.messagequeueintegration.impl.RabbitMQFacade.sendMessage(RabbitMQFacade.java:83)
at com.example.messagequeueintegration.impl.RabbitMQFacade.sendMessage(RabbitMQFacade.java:68)
at com.example.messagequeueintegration.impl.RabbitMQFacade.sendPaymentMessage(RabbitMQFacade.java:51)
at com.example.messagequeueintegration.server.rest.controllers.SendMessageController.sendPaymentMessage(SendMessageController.java:35)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:116)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
... 29 common frames omitted
Caused by: java.lang.IllegalArgumentException: Listener not registered: org.springframework.amqp.rabbit.core.RabbitTemplate#42802df2 []
at org.springframework.util.Assert.notNull(Assert.java:134)
at org.springframework.amqp.rabbit.support.PublisherCallbackChannelImpl.addPendingConfirm(PublisherCallbackChannelImpl.java:937)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.amqp.rabbit.connection.CachingConnectionFactory$CachedChannelInvocationHandler.invoke(CachingConnectionFactory.java:981)
at com.sun.proxy.$Proxy47.addPendingConfirm(Unknown Source)
at org.springframework.amqp.rabbit.core.RabbitTemplate.setupConfirm(RabbitTemplate.java:2007)
at org.springframework.amqp.rabbit.core.RabbitTemplate.doSend(RabbitTemplate.java:1979)
at org.springframework.amqp.rabbit.core.RabbitTemplate.exchangeMessages(RabbitTemplate.java:1732)
at org.springframework.amqp.rabbit.core.RabbitTemplate.doSendAndReceiveAsListener(RabbitTemplate.java:1683)
at org.springframework.amqp.rabbit.core.RabbitTemplate.doSendAndReceiveWithDirect(RabbitTemplate.java:1645)
... 48 common frames omitted
This is how my configuration looks like
#Configuration
public class RabbitMQConfig {
#Autowired
private Environment env;
#Bean
public ConnectionFactory connectionFactory() {
CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory(
env.getRequiredProperty(QUEUE_HOST),
env.getRequiredProperty(QUEUE_PORT, Integer.class));
cachingConnectionFactory.setPublisherConfirms(true);
cachingConnectionFactory.setPublisherReturns(true);
return cachingConnectionFactory;
}
#Bean
public AmqpAdmin amqpAdmin(ConnectionFactory connectionFactory) {
return new RabbitAdmin(connectionFactory);
}
#Bean
public RabbitTemplate rabbitTemplate(ConnectionFactory connectionFactory) {
RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory);
return rabbitTemplate;
}
#Bean
public RabbitAdmin rabbitAdmin(ConnectionFactory connectionFactory) {
return new RabbitAdmin(connectionFactory);
}
#Bean
public MessageUtil messageUtil(
#Qualifier("messagequeueintegration") ObjectMapper objectMapper) {
return new MessageUtil(objectMapper);
}
#Bean
public BrokerFacade brokerFacade(
#Qualifier("messagequeueintegration") ObjectMapper objectMapper,
Environment environment,
MessageUtil messageUtil) {
return new RabbitMQFacade(objectMapper, environment, messageUtil);
}
#Bean
public TopicExchange topicExchange() {
return new TopicExchange(TOPIC_EXCHANGE_KEY);
}
#Bean
Binding queue2Binding(#Qualifier("queue2") Queue queue2, TopicExchange topicExchange) {
return BindingBuilder.bind(queue2).to(topicExchange)
.with(env.getRequiredProperty("queue2name"));
}
#Bean
Binding queue1Binding(#Qualifier("queue1") Queue queue1, TopicExchange topicExchange) {
return BindingBuilder.bind(queueq).to(topicExchange)
.with(env.getRequiredProperty("queue1name"));
}
#Bean
public Queue queue1() {
return new Queue(
env.getRequiredProperty("queue1name"),
true,
false,
true;
}
#Bean
public Queue queue2() {
return new Queue(
env.getRequiredProperty("queue2name"),
true,
false,
true);
}
i autowire the rabbittemplate and call it with publisher confirm call backs like given below
Message amqpMessage = new Message(message.getBytes(), new MessageProperties());
rabbitTemplate.setConfirmCallback((cdata, ack, cause) -> {
System.out.println("Confirm callback"+ ack +" for "+cdata.toString());
});
rabbitTemplate.setReturnCallback((msg,replyCode,replyText,
exchange, routingKey)->{
System.out.println("call back returned for "+ routingKey);
});
rabbitTemplate.setMandatory(true);
rabbitTemplate
.sendAndReceive(TOPIC_EXCHANGE_KEY,environment.getProperty(correlationData.getMessageType().getQueueName()),
amqpMessage, createCorrelationData(correlationData));
After a lot of debugging i found out that it is failing because the template is not getting registered as a listener in the new instances of PublisherCallbackChannelImpl which are created by the subsequent calls after the first one . I am kind of lost as to whether this is a configuration issue or an issue with publisher confirm logic . Any insights to this will be really helpful. Thanks
Edit
I am using spring-amqp version 2.0.3-RELEASE and spring-messaging version 5.0.6-RELEASE
Edit2 : Debug logs for first and second calls
https://gist.github.com/jissjanardhanan/cbad51ba77fad3eda484d7c33c0b1517
rabbitTemplate.setUseDirectReplyToContainer(false);
#see https://github.com/spring-projects/spring-amqp/issues/846#issuecomment-439072434
I am using JGit to connect to a remote Git repository. I tried below to perform same.
public class Main{
public static void main(String args[]) throws Exception{
JschConfigSessionFactory sshSessionFactory = new JschConfigSessionFactory() {
#Override
protected void configure( Host host, Session session ) {
session.setPassword( "XXXX" );
}
};
String REMOTE_URL="ssh://git#url/test.git";
CloneCommand cloneCommand = Git.cloneRepository();
cloneCommand.setURI( "ssh://git#url/test.git" );
cloneCommand.setTransportConfigCallback( new TransportConfigCallback() {
#Override
public void configure( Transport transport ) {
SshTransport sshTransport = ( SshTransport )transport;
sshTransport.setSshSessionFactory( sshSessionFactory );
}
} );
System.out.println("Listing remote repository " + REMOTE_URL);
Collection<Ref> refs = Git.lsRemoteRepository()
.setHeads(true)
.setTags(true)
.setRemote(REMOTE_URL)
.call();
for (Ref ref : refs) {
System.out.println("Ref: " + ref);
}
}
}
ERROR:
Listing remote repository ssh://git#url/test.git
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" org.eclipse.jgit.api.errors.TransportException: ssh://git#url/test.git: UnknownHostKey: url. RSA key fingerprint is XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX
at org.eclipse.jgit.api.LsRemoteCommand.execute(LsRemoteCommand.java:223)
at org.eclipse.jgit.api.LsRemoteCommand.call(LsRemoteCommand.java:159)
at Jgit.Jgit.Main.main(Main.java:94)
Caused by: org.eclipse.jgit.errors.TransportException: ssh://git#url/test.git: UnknownHostKey: url. RSA key fingerprint is XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX
at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:159)
at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:136)
at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:262)
at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:161)
at org.eclipse.jgit.api.LsRemoteCommand.execute(LsRemoteCommand.java:202)
... 2 more
Caused by: com.jcraft.jsch.JSchException: UnknownHostKey: ssh://git#url/test.git: UnknownHostKey: url. RSA key fingerprint is XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX
at com.jcraft.jsch.Session.checkHost(Session.java:797)
at com.jcraft.jsch.Session.connect(Session.java:342)
at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:116)
... 6 more
I looked over internet; and found that, below needs to be added:
com.jcraft.jsch.JSch.setConfig ( "StrictHostKeyChecking", "no" );
But, where to fit it in above code snippet. Is there any sample working code snippet available.
You can call setConfig("","") method using Session object as shown below:-
JSch jsch = new JSch();
Session session = jsch.getSession(username, hostname, 22);
session.setConfig("StrictHostKeyChecking", "no");
session.setPassword(password);
session.connect();
Hope that helps.
I a'm using CDH 4.7. I am trying to create a folder in HDFS in /user/cloudera. But the UserPrivilegedException is thrown. Below is my code (#copied)
public static void main(String args[]) {
try {
UserGroupInformation ugi =
UserGroupInformation.createProxyUser("cloudera", UserGroupInformation.getLoginUser());
System.out.println(ugi.getUserName());
ugi.doAs(new PrivilegedExceptionAction<Void>() {
public Void run() throws Exception {
System.out.println("aaa");
Configuration conf = new Configuration();
conf.set("fs.defaultFS", "hdfs://localhost.localdomain:8020/user/cloudera");
conf.set("hadoop.job.ugi", "cloudera");
FileSystem fs = FileSystem.get(conf);
fs.createNewFile(new Path("/user/cloudera/test"));
Path path = new Path("/user/cloudera/Hbasesyntax.txt");
FileStatus[] status = fs.listStatus(path);
for(int i=0;i<status.length;i++){
System.out.println(status[i].getPath());
}
return null;
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
Then, I even tried accessing the file (Hbasesyntax.txt) which I -put through the terminal. But, not able to get the file information from that too. Am I missing anything.
Below is the exception thrown:
Feb 23, 2015 1:18:27 AM org.apache.hadoop.security.UserGroupInformation doAs
SEVERE: **PriviledgedActionException as:cloudera via cloudera cause:java.io.IOException: Mkdirs failed to create /user/cloudera
java.io.IOException: Mkdirs failed to create /user/cloudera
at** org.apache.hadoop.fs.ChecksumFileSystem.create(ChecksumFileSystem.java:378)
at org.apache.hadoop.fs.ChecksumFileSystem.create(ChecksumFileSystem.java:364)
at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:564)
at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:545)
at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:507)
at org.apache.hadoop.fs.FileSystem.createNewFile(FileSystem.java:647)
at HDFSFileOperations.GetIntoFS$1.run(GetIntoFS.java:32)
at HDFSFileOperations.GetIntoFS$1.run(GetIntoFS.java:1)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:396)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1 190)
at HDFSFileOperations.GetIntoFS.main(GetIntoFS.java:21)
I am using the code below to connect to a SQL Server 2005 database from a servlet. But it is throwing the following exception:
java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
Code Snippet:
import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class InsertServlet extends HttpServlet
{
public void doPost(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException
{
doGet(request,response);
}
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException
{
response.setContentType("text/html");
PrintWriter pw=response.getWriter();
EmpDetailBean empdetailbean=new EmpDetailBean();
Connection con=null;
PreparedStatement pstmt2=null;
//ResultSet rs=null;
String employeecode=request.getParameter("employeecode");
pw.println(employeecode);
empdetailbean.setEmployeecode(employeecode);
try
{ //String emp_code=(String)session.getAttribute("empcode");
//Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
//String url = "jdbc:sqlserver://localhost;" +
// "databaseName=test;user=sa;password= ;";
//con=DriverManager.getConnection("Jdbc:Odbc:leave1");
con=DriverManager.getConnection("jdbc:sqlserver://10.217.7.3;databaseName=test;user=sa;password=123;");
String query1="insert into leavetype(dbo.empcode) values(?)";
pstmt2=con.prepareStatement(query1);
pstmt2.setString(1,empdetailbean.getEmployeecode());
int k=pstmt2.executeUpdate();
System.out.println(k);
pstmt2.close();
}
catch(Exception e)
{ pw.println("exception"+ e);
}
}
}
the log file shows
May 2, 2012 11:34:19 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
May 2, 2012 11:34:19 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
If you want to use com.microsoft.sqlserver.jdbc.SQLServerDriver as Driver then sqljdbc.jar is required to be
present in your classpath which is WEB-INF\lib.
If you want to user Jtds Driver Check this link for Driver and databse URL
Seems that the Jar file for the JDBC Connectivity is missing from the war file that you have deployed. could you please ensure that the lib files are getting packaged with war file properly