I am new to Spring portlet i am unable to run a sample spring portlet project.. I am trying to run the project from eclipse as run on server on jboss server. My questions are 1. How can we run a portlet project. Do i need some kind of portlet container(I have no idea of this container i just know few names like liferay etc)?? I cant find a full documented example any where.. In Spring mvc based on the request mapping i can call that purticular Controller class but in Spring mvc portlet how can we call this controllers( or Portlets). Is it possible to call a portlet directly by an url?? The sample project is deployed without any error but i cant find a way by which i can call or trigger a portlet. Any help would be much appriciated.
thx
nkovi
Yes, you will need to deploy to a portlet container like Liferay etc, or uPortal. Once you have the portlet container up and running, things should hopefully become more obvious.
Regarding your other questions, I strongly suggest you read some documentation - the Spring portlet docs are not too bad although they are a little behind on annotations.
Related
Can anyone please help me on how to integrate Olingo (Odata) in a Springboot Java Appln.
I'm pretty new to Spring boot and have implemented one project and wanted it to convert to Oling (Odata).
I have gone through various resources but with a bunch of different approaches not sure how to do it the correct way.
Please let me know if some has worked on it and can guide me.
link to the project on which I applied spring-boot.
If you are trying to integrate OlingoJPA there are a couple of things you will have to do
Implement JPAServiceFactory and initializeODataJPAContext, basically this is about defining the persistence unit and entity manager
Then you can create a Spring Boot Configuration to mount your OData endpoint and initialize the EntityManagerFactory
Then you can point to your database here
An finally you can define the JPA entities you want your service to expose
The full Spring Boot + JPA project sample is located Github. Feel free to go though it, raise an issue or submit a Pull request for impalements
Need to create a webapp in java using spring boot which has UI and also it functions as a webservice. (web-app + webservice using spring boot). How to do the configurations ?
I think that this question is a bit wide. You should start by reading some tutorial like :
http://projects.spring.io/spring-boot/
I don't really know a good option to do UI with spring boot, but maybe look at :
https://spring.io/guides/gs/crud-with-vaadin/
You will need to learn and read a bit but I hope it helped you :)
EmCode
Select the SpringBoot example that is most close to your problem space and extend. You can find the samples Here.
Alternatively you can use the Spring Initializr
This is an example of Web app from the original spring page:
https://spring.io/guides/gs/spring-boot/
And this for webservices
https://spring.io/guides/gs/actuator-service/
You only need to start from the first example and add configuration in the 2nd
I am trying exception handling in spring portlet based UI application,
I have used spring globalexception handling using #ControllerAdvice.
It works fine in servlet based application but its not working in portlet application.I have noticed that spring container has not processed #ControllerAdvice in portlet. I tried searching in internet on the same issue but no luck.
Is there any other way to handle exceptions in portlet applications?
Thanks in advance.
The Portlet support in Spring is rapidly declining, with very little code or documentation of such. You'll notice that the DispatcherPortlet auto-registers an instance of AnnotationMethodHandlerExceptionResolver, not the newer ExceptionHandlerExceptionResolver.
Even if you manually define an instance of the latter in your portlet.xml file, it won't get picked up by the DispatcherPortlet because it specifically looks for implementers of the org.springframework.web.portlet.HandlerExceptionResolver, which is a different hierarchy than the org.springframework.web.servlet.HandlerExceptionResolver (of which ExceptionHandlerExceptionResolver is a descendent).
I have embedded Jetty container inside my main server and I also use Jersey 2.5 for handling REST resources.
everything seems to work well and now I would like to pass my server's context class into each of my REST resources.
I'm having hard time understanding how to do that...
If someone can provide full code example - it could be awesome!
Many thanks
What exactly do you mean when you say you have a Jetty container inside your "main server"? Are you programmatically executing Jetty within the application? Also, when you say "context" are you referring to the ServletContext?
I'm trying to build a portlet within a grails application, and I've created a simple controller extending AbstractController which returns
new ModelAndView('myportlet') from handleRequestInternal. I also have a standard Jstl view resolver setup for /WEB-INF/jsp but no matter what I try, when I try to view the portlet within liferay I get the following stacktrace:
13:19:39,723 ERROR [DispatcherPortlet:559] Could not complete request
java.lang.ClassCastException: org.springframework.web.portlet.context.PortletRequestAttributes cannot be cast to org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequest
at org.codehaus.groovy.grails.web.util.WebUtils.retrieveGrailsWebRequest(WebUtils.java:497)
at org.codehaus.groovy.grails.web.servlet.view.GrailsViewResolver.loadView(GrailsViewResolver.java:87)
at org.codehaus.groovy.grails.scaffolding.view.ScaffoldingViewResolver.loadView(ScaffoldingViewResolver.java:61)
at org.springframework.web.servlet.view.AbstractCachingViewResolver.createView(AbstractCachingViewResolver.java:158)
at org.springframework.web.servlet.view.UrlBasedViewResolver.createView(UrlBasedViewResolver.java:384)
at org.springframework.web.servlet.view.AbstractCachingViewResolver.resolveViewName(AbstractCachingViewResolver.java:77)
at org.springframework.web.portlet.DispatcherPortlet.resolveViewName(DispatcherPortlet.java:1110)
It seems that if I could get around the GrailsViewResolver, I should be able to get my portlet up and running as I would in a normal spring application.
I'm using liferay 6, so the grails liferay plugin isn't an option. Is there anything I can do to make sure GrailsViewResolver doesn't try to resolve my view in /WEB-INF/jsp?
If you're using Grails, use it 100% and don't try to mix wildly different technologies. It'll save you pain in the long run.