Darvesh Niz

Ranch Hand
+ Follow
since May 12, 2008
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Darvesh Niz

any idea

was my question clear
7 years ago
I have a scenario where we have two dispatcher servlet in our web.xml file.
One of the dispatcher servlet mentioned below have very minimal beans and starts quickly and pass health check and notifies the load balancer thats its ready to serve traffic.

The other dispatcher servlet is heavyweight and has lots of beans and takes almost 1~2 min to initialize.
we want to make sure the first dispatcher only sends a request to load balancer thats its ready to serve traffic once all the spring beans are initialized in the second dispatcher.

some solution which i have on top of my head is
Let the content controller implements InitializingBean and in the afterPropertiesSet() method is fired set a flag as true and expose that as a JMX property.
The healthcheck controller will first check the property exposed as a jmx bean and only send signal to load balancer that its ready to server traffic only if the flag is true.

Is there a way i can defer loading of bean in healthcheck controller by like 2 min or so.

any advice ideas

7 years ago
Hello all.
i have a requirement where i have an image which is off specific size.

i have to superimpose some data points on it for example

i have a front facade of a house. i want to have dots on the front window, front door if someone clicks on it or hovers over it should display some info

can you please suggest some technology how to do it


8 years ago

We are trying to see why would a HttpURLConnection.getResponseCode() will throw a FileNotFound exception rather than checking it. We are calling a third party api url "https://somedomainhere/api/v1/discussion.json?Discussion.ForeignID=9f0fd31d92e5a8e0b279380578dcd188" and there are certain cases when the third party server will send us back a 404 response. But we are getting an exception right when check the getResponseCode(), why would it throw an exception. i have wrote a small program and debugged it and when i gave a bad url it worked fine and there was no error, but the error keeps on happening on our server and fill up the logs. Also whats more frustating is we are trying to suppress the log and i have put sufficient Exception block to catch the exception yet somehow the error gets printed in the logs. Below is my

any advice the error right when the check condition happens below is the stack trace
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1624)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:338)
at com.xxx.editorial.util.ConsumerCommentUtil.getVanillaUrl(ConsumerCommentUtil.java:120)
at com.xxx.editorial.util.ConsumerCommentUtil.getConsumerComments(ConsumerCommentUtil.java:60)
at com.xxx.editorial.tags.ConsumerCommentsTag.getBean(ConsumerCommentsTag.java:41)
at com.xxx.common.web.tags.ScopedBeanTag.setAttributeInScope(ScopedBeanTag.java:80)
at com.xxx.common.web.tags.ScopedBeanTag.doEndTag(ScopedBeanTag.java:44)
at freemarker.ext.jsp.TagTransformModel$TagWriter.endEvaluation(TagTransformModel.java:430)
at freemarker.ext.jsp.TagTransformModel$TagWriter.afterBody(TagTransformModel.java:406)
at freemarker.core.Environment.visit(Environment.java:312)
at freemarker.core.UnifiedCall.accept(UnifiedCall.java:130)
at freemarker.core.Environment.visit(Environment.java:221)
at freemarker.core.MixedContent.accept(MixedContent.java:92)
at freemarker.core.Environment.visit(Environment.java:221)
at freemarker.core.Environment.visit(Environment.java:310)
at freemarker.core.UnifiedCall.accept(UnifiedCall.java:130)
at freemarker.core.Environment.visit(Environment.java:221)
at freemarker.core.MixedContent.accept(MixedContent.java:92)
at freemarker.core.Environment.visit(Environment.java:221)
9 years ago
i have an application which we migrated to postgres and after certain login attempts the application hangs. In the resource definition we have maxWait defined as 5 sec hence we get an exception stating
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot get a connection, pool error Timeout waiting for idle object

Going over some thread it seems we have to add @Transactional annotation to define transaction boundaries so that spring releases the connection.

The question is what kind of transaction Manager should i use.

We get our connection from the jndi object factory bean

and the resource is defined in tomcat as

Going by spring doc should i be using

and put @Transactional annotation on my methods.

if i use that then i get an error when i start my container

Which transaction manager should i use.

Please advice

10 years ago
Spot on Jayesh

Thanks, spring-ldap-1.2.1.jar was causing the issue.

I actually removed it from my pom but it again showed up because spring-ldap-tiger 1.2. was bringing that dependency again.

Infact i removed both of them since i dont need them anymore and now my app works fine.

10 years ago

i did that

i had intellij and digging doing Ctl+click
DefaultSpringSecurityContextSource extends org.springframework.ldap.core.support.LdapContextSource

LdapContextSource extends org.springframework.ldap.core.support.AbstractContextSource

and AbstractContextSource has this method
public void setAuthenticationStrategy(org.springframework.ldap.core.support.DirContextAuthenticationStrategy authenticationStrategy) { /* compiled code */ }

Just cudn't figure out whats the issue
10 years ago
here it is

10 years ago
Hello anyone
any advice.

10 years ago
i have upgraded my spring LDAP app security from security 2.x to 3.0.x

PROBLEM : the issue is the app comes up fine on my local when i do mvn jetty:run and the ldap security works fine, but when i deployed it on hosted tomcat server i see this error.

SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'contextSource' defined in class path resource [moderator-authentication.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.security.ldap.DefaultSpringSecurityContextSource]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.springframework.security.ldap.DefaultSpringSecurityContextSource.setAuthenticationStrategy(Lorg/springframework/ldap/core/support/DirContextAuthenticationStrategy;)V
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:288)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1045)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:949)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:487)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:656)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1635)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
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)
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.security.ldap.DefaultSpringSecurityContextSource]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.springframework.security.ldap.DefaultSpringSecurityContextSource.setAuthenticationStrategy(Lorg/springframework/ldap/core/support/DirContextAuthenticationStrategy;)V
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:163)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:121)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:280)
... 28 more

I have made sure all the lib in the exploded war are spring security 3.0.x but still dont know whats the prob.

i have pasted all spring security related jar package in my app by maven.

and the following are ldap jars

Below is my pom declaration of all libraries

The below is my spring authentication file

Please let me know whats wrong here.

10 years ago
Just to add in order to fix this i implemented my own DefaultRedirectStrategy, but still no luck
The below is my code where i redirect the request, so i assume when the contorl goes to myaccount action class the cookie should be present but still not the case, any advice.

10 years ago

i am faced with some new issue where i am not able to see the cookie created in the same request.
when i hit this url the first time

As is said before it routes me to login page i enter my login info and in the successfulAuthentication method we create some cookie.

After login, spring now directs the request comes to MyAccount.load.action i am trying to get that cookie but its not available, since its the same request. Hence Myaccount.load.action class does not find the cookie and we have written some code to redirect back to login screen. once the request gets complete i see the cookie now.

How is it possible to make the Myaccount.load.action class to see the cookie in the same request flow after user is logged in.

any advice.
10 years ago
i figured out that i accidently deleted this line in my
protected void successfulAuthentication(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException,ServletException {

super.successfulAuthentication(request, response, authentication);

after putting it its fine now.
10 years ago
i tried printing out log4j debug messaging and looks like spring is not spitting out any message
my log4j.properties file looks like but i am not seeing any messages in the output

log4j.rootCategory=DEBUG, stdout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %t %c{2}:%L - %m%n

Thats one problem
The other problem i have is for example the first time when i go to secure page for example
the request gets intercepted and i see login page, i enter my username and password and the request comes to attemptAuthentication and i see we create the correct user object with granted authority as ROLE_USER
return new org.springframework.security.core.userdetails.User(user.getEmail(),
user.getNewPassword(), notPending, true, true, notDisabled, grantedAuthcollection)
and i also see the jSESSION cookie created.

so i assume the next time when i hit the same url again

it should let me go that url but its again redirecting it to login page.

i am really doubting could there be some issue with jetty working with spring security.

any advice?
10 years ago

i am working on Spring security and i have an issue where after successfulAuthentication the request is not being passed to the sucesshandler url
i have my own CustomAuthenticationProcessingFilter which extends UsernamePasswordAuthenticationFilter and added two overridden methods as seen below
Below is my spring security configuration

When the user submits the login form the request comes to these overridden methods and we create all necessary cookies but the request is not delegated to the url mentioned in successHandler
in the browser window the request comes back to
http://myhost:8080/j_security_check with a blank screen

just to add my login form submit action url is
<s:form action="/j_spring_security_check" method="post" id="form1" name="form1">

Any advice.

10 years ago