Basic usage not working.

75 views
Skip to first unread message

Ajinkya Gaikwad

unread,
Nov 17, 2016, 2:16:44 AM11/17/16
to simple-spring-memecached
Hi,

I'm trying to configure Memcache in my REST application.
I already have the Memcached server instance up and running. 
I added the SSM configuration in my root application context.

The following import line is causing a problem-
 <import resource="simplesm-context.xml" />
Error after deploying on Tomcat- 
Configuration problem: Failed to import bean definitions from relative location [simplesm-context.xml]
nested exception is java.io.FileNotFoundException

I tried to search for the xml file in the 'spymemcached-provider' jar file but could not find it.

I then modified the import line to -
 
  <import resource="classpath:simplesm-context.xml" />

Now while deploying, tomcat does not throw an error.
I also can see the following line in the server log while deploying-
INFO: Loading XML bean definitions from class path resource [simplesm-context.xml]

But the problem is , nothing is getting added in my cache after using annotations correctly.

I have attached all the relevant files.
Any help will be appreciated.
Thanks.



pom.xml
rootApplicationContext.xml
CourseDAO.java

Jakub Białek

unread,
Nov 17, 2016, 4:36:39 AM11/17/16
to simple-spring-memecached
Hi,

Try to create an interface for CourseDAO and invoke all methods (getAllCourses, getCourse) using the interface instead of implementation. Without the interface the call is not intercepted and a cache related code is not triggered.

-- Ragnor

--
You received this message because you are subscribed to the Google Groups "simple-spring-memecached" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsub...@googlegroups.com.
To post to this group, send email to simple-spring-memecached@googlegroups.com.
Visit this group at https://groups.google.com/group/simple-spring-memecached.
For more options, visit https://groups.google.com/d/optout.

Ajinkya Gaikwad

unread,
Nov 17, 2016, 7:58:10 PM11/17/16
to simple-spring-memecached
Hi,

Thanks for your prompt reply. As suggested, I created a DAO interface and triggered the DAO method through the interface reference. Still I'm not able to cache my object. I also tested my Memcached server through a simple Java application using spymemcached and I could insert objects in my cache. I'm attaching the updated files as well as my root application context. Can you please take a look at them ?

Thanks.
Ajinkya
To post to this group, send email to simple-sprin...@googlegroups.com.
CustomerDAO.java
CourseDAOImpl.java
CourseService.java
rootApplicationContext.xml

Jakub Białek

unread,
Nov 18, 2016, 12:52:50 AM11/18/16
to simple-spring-memecached
Hi,

Please enable debug logging for SSM (com.google.code.ssm), execute your tests and provide me the output. Is there any exception in logs? 
Could you try to debug you app to verify if ReadThroughSingleCacheAdvice is called?

-- Ragnor

To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsubscr...@googlegroups.com.
To post to this group, send email to simple-sprin...@googlegroups.com.
Visit this group at https://groups.google.com/group/simple-spring-memecached.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "simple-spring-memecached" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsub...@googlegroups.com.
To post to this group, send email to simple-spring-memecached@googlegroups.com.

Ajinkya Gaikwad

unread,
Nov 18, 2016, 3:00:23 AM11/18/16
to simple-spring-memecached
Hi,

I have attached the following log files 
Logs after deployment
Logs after I hit the annotated method.

And no I did not find any debug logs for ReadThroughSingleCacheAdvice.

What do you suggest I can do?

Thanks.

To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsub...@googlegroups.com.
To post to this group, send email to simple-sprin...@googlegroups.com.
Visit this group at https://groups.google.com/group/simple-spring-memecached.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "simple-spring-memecached" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsub...@googlegroups.com.
LogOnDeploying.txt
RequestHitLog.txt

Jakub Białek

unread,
Nov 18, 2016, 6:21:14 AM11/18/16
to simple-spring-memecached
Let's check the invocation chain. Change the getCourse method to throw an exception. There should be a Spring interceptor.

-- Ragnor 

To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsubscr...@googlegroups.com.
To post to this group, send email to simple-sprin...@googlegroups.com.
Visit this group at https://groups.google.com/group/simple-spring-memecached.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "simple-spring-memecached" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsubscr...@googlegroups.com.

To post to this group, send email to simple-sprin...@googlegroups.com.
Visit this group at https://groups.google.com/group/simple-spring-memecached.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "simple-spring-memecached" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsub...@googlegroups.com.
To post to this group, send email to simple-spring-memecached@googlegroups.com.

Ajinkya Gaikwad

unread,
Nov 18, 2016, 1:12:27 PM11/18/16
to simple-spring-memecached
Hi,

As suggested, I threw an Exception in the Service method. Attached is the log file.Can you please take a look.



On Friday, November 18, 2016 at 6:21:14 AM UTC-5, ragnor84 wrote:
Let's check the invocation chain. Change the getCourse method to throw an exception. There should be a Spring interceptor.

I suspect I haven't turned on logging for SSM correctly because I only added Logging using SL4j in my project. Is there any SSM specific configuration for turning its logging on ?

-- Ragnor 

To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsub...@googlegroups.com.
To post to this group, send email to simple-sprin...@googlegroups.com.
Visit this group at https://groups.google.com/group/simple-spring-memecached.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "simple-spring-memecached" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsub...@googlegroups.com.
To post to this group, send email to simple-sprin...@googlegroups.com.
Visit this group at https://groups.google.com/group/simple-spring-memecached.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "simple-spring-memecached" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsub...@googlegroups.com.
ExceptionLogs.txt

Ajinkya Gaikwad

unread,
Nov 18, 2016, 4:19:52 PM11/18/16
to simple-spring-memecached
Hi,

I have an update. I manually put the simplesm-context,xml file under my src/main/resources.
Now I'm getting an error related to SSM while the root context is created.
I'm attaching the relevant log snippet.

Thanks,
Ajinkya
ContextError.txt

Ajinkya Gaikwad

unread,
Nov 18, 2016, 10:59:35 PM11/18/16
to simple-spring-memecached
Hi,

Couple of important updates,

1. I was using an older version of simplesm-context,xml. Hence I was getting the error. (Ignore my earlier message)
2. I was using Spring 4.3.1 and then I just read that SSM does not work with it. So I changed my Spring version to 4.0.0.RELEASE

The  simplesm-context,xml file is loaded correctly. But still no luck in caching through annotations.

Thanks,
Ajinkya.

Jakub Białek

unread,
Nov 19, 2016, 4:38:57 AM11/19/16
to simple-spring-memecached
Thanks for the logs and investigation, can you also throw an error from DAOImpl?
SSM supports Spring 4.3.x, there was a problem in previous SSM version with Spring Cache annotations but you uses SSM annotations.

I think that I know why it doesn't work. You use an old version of simplesm-context.xml (beofre version 3.0), try to use a new one: https://github.com/ragnor/simple-spring-memcached/blob/master/simple-spring-memcached/src/main/resources/simplesm-context.xml 

If it doesn't help could you send me your project? Even simplified version? I'd like to reproduce the issue on my environment.

-- Ragnor


-- Ragnor 

To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsubscr...@googlegroups.com.
To post to this group, send email to simple-sprin...@googlegroups.com.
Visit this group at https://groups.google.com/group/simple-spring-memecached.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "simple-spring-memecached" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsubscr...@googlegroups.com.

To post to this group, send email to simple-sprin...@googlegroups.com.
Visit this group at https://groups.google.com/group/simple-spring-memecached.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "simple-spring-memecached" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsubscr...@googlegroups.com.

To post to this group, send email to simple-sprin...@googlegroups.com.
Visit this group at https://groups.google.com/group/simple-spring-memecached.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "simple-spring-memecached" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsub...@googlegroups.com.
To post to this group, send email to simple-spring-memecached@googlegroups.com.

Ajinkya Gaikwad

unread,
Nov 19, 2016, 12:05:33 PM11/19/16
to simple-spring-memecached
Hi,

Yes. I was using an older version of simplesm-context.xml. But I deleted the old xml and I realized that the latest xml you shared is found in simple-spring-memcached-3.6.1 jar.
So the file was found in classpath.

As suggested, I tried to throw an error in DAOimpl. I'm attaching the relevant logs.

I'm also sharing the WAR file of my project for your investigation. There is a 'sources' folder in the WAR which contains all the source files.

Do let me know in case you need anything else. 

Thanks a ton,
Ajinkya.

-- Ragnor 

To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsub...@googlegroups.com.
To post to this group, send email to simple-sprin...@googlegroups.com.
Visit this group at https://groups.google.com/group/simple-spring-memecached.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "simple-spring-memecached" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsub...@googlegroups.com.
To post to this group, send email to simple-sprin...@googlegroups.com.
Visit this group at https://groups.google.com/group/simple-spring-memecached.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "simple-spring-memecached" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsub...@googlegroups.com.
To post to this group, send email to simple-sprin...@googlegroups.com.
Visit this group at https://groups.google.com/group/simple-spring-memecached.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "simple-spring-memecached" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsub...@googlegroups.com.
DAOExceptionLog.txt

Jakub Białek

unread,
Nov 20, 2016, 4:00:08 PM11/20/16
to simple-spring-memecached
Hi,

In the stacktrace I don't see any interceptors between service a dao. I see that in web.xml there are 2 spring related parts: contextLoadListener and dispatcherServlet. 
Can you move content of rootApplicationContext to springrest-servlet and also leave in web.ml only servlet* entries?

-- Ragnor


-- Ragnor 

To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsubscr...@googlegroups.com.
To post to this group, send email to simple-sprin...@googlegroups.com.
Visit this group at https://groups.google.com/group/simple-spring-memecached.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "simple-spring-memecached" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsubscr...@googlegroups.com.

To post to this group, send email to simple-sprin...@googlegroups.com.
Visit this group at https://groups.google.com/group/simple-spring-memecached.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "simple-spring-memecached" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsubscr...@googlegroups.com.

To post to this group, send email to simple-sprin...@googlegroups.com.
Visit this group at https://groups.google.com/group/simple-spring-memecached.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "simple-spring-memecached" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsubscr...@googlegroups.com.

To post to this group, send email to simple-sprin...@googlegroups.com.
Visit this group at https://groups.google.com/group/simple-spring-memecached.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "simple-spring-memecached" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsub...@googlegroups.com.
To post to this group, send email to simple-spring-memecached@googlegroups.com.

Ajinkya Gaikwad

unread,
Nov 20, 2016, 7:27:17 PM11/20/16
to simple-spring-memecached
Hi,

It worked . Hurray!!!
Thanks for your help. Looking forward to dig in the docs and use SSM in my project.

I think SSM is really cool. Would love to be a part of future development of SSM. However, I'm a very less experienced coder.
But will contribute, if you could guide a little.

Thanks again,
Ajinkya.

-- Ragnor 

Jakub Białek

unread,
Nov 21, 2016, 6:38:02 AM11/21/16
to simple-spring-memecached
Great to here that it works for you.

I'm happy to hear the you find SSM useful. 
The project is open for contribution. If you see any things to improve or missing features don't hesitate to contact me. Any pull request will be commented and in the end merged to master.

Here you can find SSM code formatter for eclipse: https://github.com/ragnor/simple-spring-memcached/blob/master/formatter.xml.

-- Ragnor 



-- Ragnor 

To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsubscr...@googlegroups.com.
To post to this group, send email to simple-sprin...@googlegroups.com.
Visit this group at https://groups.google.com/group/simple-spring-memecached.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "simple-spring-memecached" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsubscr...@googlegroups.com.

To post to this group, send email to simple-sprin...@googlegroups.com.
Visit this group at https://groups.google.com/group/simple-spring-memecached.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "simple-spring-memecached" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsubscr...@googlegroups.com.

To post to this group, send email to simple-sprin...@googlegroups.com.
Visit this group at https://groups.google.com/group/simple-spring-memecached.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "simple-spring-memecached" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsubscr...@googlegroups.com.

To post to this group, send email to simple-sprin...@googlegroups.com.
Visit this group at https://groups.google.com/group/simple-spring-memecached.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "simple-spring-memecached" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsubscr...@googlegroups.com.

To post to this group, send email to simple-sprin...@googlegroups.com.
Visit this group at https://groups.google.com/group/simple-spring-memecached.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "simple-spring-memecached" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsub...@googlegroups.com.
To post to this group, send email to simple-spring-memecached@googlegroups.com.

Ajinkya Gaikwad

unread,
Nov 29, 2016, 8:54:57 PM11/29/16
to simple-spring-memecached
Hi,

I am trying to use the ReadThroughSingleCache annotation in my business layer.
Below is my method signature.

@ReadThroughSingleCache(namespace = "CityInfo", expiration = 3600)
public List<BusinessVO> getBusinessesBasedOnCategory(@ParameterValueKeyProvider(order=1) String city,
@ParameterValueKeyProvider(order = 2) String category)

The issue I'm facing is that when my city has a space in it, for example if city is "Las Vegas"
Then I get an illegal argument exception and for the city value.

How do you suggest we can overcome this ?

Thanks,
Ajinkya.

-- Ragnor 

Jakub Białek

unread,
Nov 30, 2016, 12:58:43 AM11/30/16
to simple-spring-memecached
Hi,

Could you please provide a full stack trace? It seams like a bug that should be fixed.

As a workaround you may try to add third parameter to you method that will contain city name without spaces:
@ReadThroughSingleCache(namespace = "CityInfo", expiration = 3600)
public List<BusinessVO> getBusinessesBasedOnCategory(String city, @ParameterValueKeyProvider(order=1) String cityWithoutSpaces,
@ParameterValueKeyProvider(order = 2) String category)

and invoke it like this: getBusinessesBasedOnCategory(city, city.replaceAll(" ","_"), category)

-- Ragnor




-- Ragnor 

To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsubscr...@googlegroups.com.
To post to this group, send email to simple-sprin...@googlegroups.com.
Visit this group at https://groups.google.com/group/simple-spring-memecached.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "simple-spring-memecached" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsubscr...@googlegroups.com.

To post to this group, send email to simple-sprin...@googlegroups.com.
Visit this group at https://groups.google.com/group/simple-spring-memecached.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "simple-spring-memecached" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsubscr...@googlegroups.com.

To post to this group, send email to simple-sprin...@googlegroups.com.
Visit this group at https://groups.google.com/group/simple-spring-memecached.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "simple-spring-memecached" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsubscr...@googlegroups.com.

To post to this group, send email to simple-sprin...@googlegroups.com.
Visit this group at https://groups.google.com/group/simple-spring-memecached.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "simple-spring-memecached" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsubscr...@googlegroups.com.

To post to this group, send email to simple-sprin...@googlegroups.com.
Visit this group at https://groups.google.com/group/simple-spring-memecached.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "simple-spring-memecached" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsubscr...@googlegroups.com.

To post to this group, send email to simple-sprin...@googlegroups.com.
Visit this group at https://groups.google.com/group/simple-spring-memecached.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "simple-spring-memecached" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsub...@googlegroups.com.
To post to this group, send email to simple-spring-memecached@googlegroups.com.

Ajinkya Gaikwad

unread,
Nov 30, 2016, 1:10:11 AM11/30/16
to simple-spring-memecached
Hi,

Thanks for the workaround. I have attached the relevant log files.

Thanks and Regards,
Ajinkya.

-- Ragnor 

StackTrace.txt
Reply all
Reply to author
Forward
0 new messages