Friday, July 28, 2017

Windows - Unable to delete file with name too long

Problem :

In Eclipse while moving some packages to another it accidently got copied several times. Not sure how. It created a folder under folders like infinite times.

Apparently Windows has a length limit on file names and doesnt let you delete it if the file name and path is way too long. Although it doesn't prevent us from creating these files.

If I try to delete them from Explorer I get following error:
Cannot delete [file name]: The file name you specified is not valid or too long.  
Specify a different file name

I even tried to delete it from DOS but it dint help. I tried rmdir /S /Q <<folder name>> and also robocopy option to purge the folder and files but it did not help.

Some posts suggested to use a third party tools like 7zip etc, which din't seem a good idea.

As a final resort I wrote a small Java Program to fix this issue. Following is my program to delete the files and directories recursively for long file path problem:

Please note that will work in Java 8. You will have to make small modifications to make it work in lower versions.

package com.ingole.bot.demo.function;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.stream.Stream;

public class DeleteLongPath {

public static void main(String[] args) throws IOException {

try {
//paths.forEach(System.out::println);

DeleteLongPath deleteLongPath = new DeleteLongPath();
while(true) {

Stream<Path> paths = Files.walk(Paths.get("C:\\research\\vclone-parent\\"
+ "vclone-client\\src\\main\\java\\com\\vclone\\claims"));

paths.forEach(deleteLongPath::removeFile);
}

} catch (Exception e) {
//e.printStackTrace();
}

}

private void removeFile(Path path) {

try {
if(Files.deleteIfExists(path)){
System.out.println("Deleted path " + path.toString());
}
} catch (Exception e) {
//e.printStackTrace();
}
}

}

Friday, July 7, 2017

Weblogic 11G Destination unreachable;

I have a local clustered environment with an Admin server and two nodes node1, and node2.
I am getting following while starting the node1 and node2. The error is basically complaining about the destination not reachable when it tries to connect the Admin server.

It shows the destination as follows:

[fd56:801a:cd17:0:39c0:fd3e:4d90:1ce]:7001

Here is the full stacktrace:

<Jul 7, 2017 10:57:08 AM CDT> <Warning> <JMX> <BEA-149509> <Unable to establish JMX Connectivity with the Adminstration Server AdminServer at service:jmx:t3://[fd56:801a:cd17:0:39c0:fd3e:4d90:1ce]:7001/jndi/weblogic.management.mbeanservers.domainruntime.
java.io.IOException
        at weblogic.management.remote.common.ClientProviderBase.makeConnection(ClientProviderBase.java:196)
        at weblogic.management.remote.common.ClientProviderBase.newJMXConnector(ClientProviderBase.java:84)
        at javax.management.remote.JMXConnectorFactory.newJMXConnector(JMXConnectorFactory.java:369)
        at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:267)
        at weblogic.management.mbeanservers.runtime.internal.RegisterWithDomainRuntimeService.getDomainMBeanServerConnection(RegisterWithDomainRuntimeService.java:222)
        Truncated. see log file for complete stacktrace
Caused By: javax.naming.CommunicationException [Root exception is java.net.ConnectException: t3://[fd56:801a:cd17:0:39c0:fd3e:4d90:1ce]:7001: Destination unreachable; nested exception is:

Fix in my case : 

For me setting the Listen address localhost resolved the issue.
Go to weblogic console and check the AdminServer Listen Address. I set it to localhost since I am working on my local but this can be an IP if you are working on remote environment.


BadSqlGrammarException : java.sql.SQLException: Invalid column name

I am using jdbcTemplate in my Dao. Getting following error while running a simple query.:

SELECT E.EMPID, E.EMPNAME FROM EMPLOYEE E WHERE E.SALARY > ?

java.lang.reflect.InvocationTargetException
        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 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 org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
        at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144)
        at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161)
        at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160)
        at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99)
        at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389)
        at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347)
        at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102)
        at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326)
        at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
        at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
        at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
        at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305)
        at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154)
        at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:473)
        at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427)
        at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388)
        at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341)
        at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228)
        at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
        at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)
        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:184)
        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3732)
        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3696)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
        at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2273)
        at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
        at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1490)
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
Caused by: org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [
SELECT E.EMPID, E.EMPNAME FROM EMPLOYEE E WHERE E.SALARY > ?];
nested exception is java.sql.SQLException: Invalid column name
        at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:231)
        at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)
        at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:660)
        at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:695)
        at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:727)
        at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:737)
        at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:792)



Thursday, July 6, 2017

Circular placeholder reference 'ACCOUNT_SID' in property defini ions

Jul 6, 2017 9:14:45 PM GMT> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment
equest with ID '1499375648175' for task '3'. Error is: 'weblogic.application.ModuleException: '
eblogic.application.ModuleException:
       at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1520)
       at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:484)
       at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
       at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
       at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
       Truncated. see log file for complete stacktrace
aused By: java.lang.IllegalArgumentException: Circular placeholder reference 'ACCOUNT_SID' in property definiions
       at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:
41)


Caused by: org.springframework.dao.EmptyResultDataAccessException: Incorrect result size: expected 1, actual 0

java.lang.reflect.InvocationTargetException
        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 com.test.mobile.webapp.rest.resources.WebappResource.processWebapp(WebappResource.java:80)
        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 org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
        at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144)
        at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161)
        at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160)
        at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99)
        at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389)
        at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347)
        at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102)
        at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326)
        at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
        at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
        at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
        at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305)
        at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154)
        at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:473)
        at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427)
        at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388)
        at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341)
        at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228)
        at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
        at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)
        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:184)
        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3732)
        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3696)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
        at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2273)
        at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
        at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1490)
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
Caused by: org.springframework.dao.EmptyResultDataAccessException: Incorrect result size: expected 1, actual 0
        at org.springframework.dao.support.DataAccessUtils.requiredSingleResult(DataAccessUtils.java:71)
        at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:812)
        at com.test.mobile.webapp.dao.AbstractJdbcDAO.queryForObject(AbstractJdbcDAO.java:72)
        at com.test.mobile.webapp.dao.WebappCheckDAOImpl.checkForEmployee(WebappCheckDAOImpl.java:165)
        at com.test.mobile.webapp.services.WebappServiceImpl.checkForEmployee(WebappServiceImpl.java:98)
        at com.test.mobile.webapp.services.WebappServiceImpl$$FastClassBySpringCGLIB$$887208f9.invoke(<generated>)
        at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
        at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:649)
        at com.test.mobile.webapp.services.WebappServiceImpl$$EnhancerBySpringCGLIB$$36454699.checkForEmployee(<generated>)
        at com.test.mobile.webapp.services.WebappRuleExecutor.checkForEmployee(webappRuleExecutor.java:44)
        ... 44 more


Wednesday, July 5, 2017

Celebs Leaving Twitter

Celebs Leaving Twitter




Leslie Jones from SNL quit Twitter last year due to many trolls posting racist and sexist tweets. There was even a fake profile in her name which posted obscene tweets. 

"I leave Twitter tonight with tears and a very sad heart," Jones tweeted. "All this cause I did a movie. You can hate the movie but the [s---] I got today. Wrong."

"I'm not stupid to not know racism exists," Jones wrote. "And I know it will probably live on way after me. But we have to make people take responsibility for the hate they spew. We have to stand up to it."




She also called on Twitter to do something, to which the social media site responded, "This type of abusive behavior is not permitted on Twitter, and we've taken action on many of the accounts reported to us by both Leslie and others." 

Ed Shereen is one of the celebs who recently quit twitter as he seemed to be upset about the mean things people wrote. According to The Sun he said, "I can't read it. I go on it and there's nothing but people saying mean things."




It seems like Twitter has been serving as a platform to publicly abuse and bash celebrities who create an account there hoping to connect with the fans. But in some cases the negative comments takes a toll on these poors famous people. Although Twitter strongly condemns these racist and sexist comments and even has taken action in some cases to deactivate fishy and abusive users, there are still large number of users who enjoy bullying and bashing not only celebs but anyone they dislike for that matter.

Monday, July 3, 2017

A relief for Facebook. Judge rules in favor of Facebook against accusations for privacy violations

A relief for Facebook. Judge rules in favor of Facebook against accusations for privacy violations

Sanjay Ingole - Jul 3, 2017



There is a major setback for Facebook users who have always been concerned about their privacy and usage of personal information. US District judge Edward Davila, recently ruled in favor of the social media giant, in an old lawsuit filed in Sept 2011 for violating privacy and wiretapping. 
Facebook was accused of tracking its user's internet usage even after they had logged out of their accounts. Facebook had assured that logging out would delete the cookies but it continued to receive the user information until disclosed by an independent researcher.
However the judge stated that plaintiffs in the lawsuit have not established that they have a reasonable expectation of privacy in the electronic addresses of the internet pages they visit. Judge also ruled that Facebook can not be accused of wiretapping as it did not "intercepted" the electronic communication and was itself a party in those communications. 
Going forward those plaintiffs can not use the same arguments against Facebook, for wiretapping and privacy violation, however they can file another suite for breach of contract for continuing to track the user's internet activities after logging out.
Facebook does provide Privacy options
Facebook provides privacy features that can be used to restrict access to your contents and personal information. You can block/unfriend users, make posts and pictures private or accessible to a limited audience. The important thing is, if you feel something should not be shared with others do not put it out there, or at least set the required privacy settings. Also be careful with applications that ask you to login through Facebook and access your personal information. Facebook does not share anything with anyone that you don't want it to. 
Facebook is a business after all
Facebook provides a platform for millions of users to connect, share memories, pictures, videos, and all of that is for free. To generate revenue Facebook shares its users information with third party companies who are looking to monetize this information. It uses cookies to show targeted ads to the customers to sell services and virtual goods. For example, if you searched for hotels in LA on hotels.com and after 3 hours you opened Facebook. Then it might be possible that you might see an ad on Facebook from Hotels.com with some promotion or an ongoing deal. If you clicked this ad and booked a hotel, then it will generate revenue for both Facebook an Hotels.com.
Facebooks has been under lot of scrutiny due to its privacy policies and the way it encourages people to share information in different ways, but it has also evolved its privacy and security policies over time to define a fine line between monetizing and sharing personal information.