I got some error as below in eclipse complaining about a compiler error:
The method ..... of type ..... must override a superclass method.
Where as as you can clearly that I am overriding the method using the @Override annotation
Reason:
Check if your eclipse/myeclipse is using a compiler version lesser than java 1.6.
Solution:
Change the compiler to jdk 1.6 or above in your IDE as shown in below picture:
That should do.
References:
http://stackoverflow.com/questions/1678122/must-override-a-superclass-method-errors-after-importing-a-project-into-eclips
GoogleSearchBox
Custom Search
Tuesday, December 10, 2013
Wednesday, August 28, 2013
format java date from string MM/dd/yyyy HH:mm:ss a
String datetimeString = "6/7/2013 2:55:44 PM"; // A String representing your date java.util.Date result = new Date(); DateFormat formatter = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a"); // Below Will Throw Exception in thread "main" java.text.ParseException: Unparseable date: // SimpleDateFormat formatter = new SimpleDateFormat("MM-dd-yyyy"); result = formatter.parse(datetimeString); // Throws ParseException System.out.println("Parse Java Util Date = "+result); System.out.println("formatted: " + formatter.format(result));
Output is:
Parse Java Util Date = Fri Jun 07 14:55:44 GMT+05:30 2013 formatted: 06/07/2013 02:55:44 PM
Refer below posts for more examples:
http://viralpatel.net/blogs/check-string-is-valid-date-java/
http://docs.oracle.com/javase/1.5.0/docs/api/java/text/SimpleDateFormat.html
Tuesday, August 20, 2013
How to pass multiple property (option) values as an argument to a method in JQuery
For an jQuery API we have multiples of options to use from for a method.
For example, for the jQuery UI Dialog widget we have a lot of options to choose from like we have maxHeight, minWidth, modal, resizable, draggable to achieve different functionalyties with the widget.
So how to use all or some of these options with the dialog method ?
Here is how we can do it:
We can create a variable containing all the options (name:value) with comma(,) in between multiple values (basically json notation) and then pass the variable to the dialog() method.
where "dialog" is the div name inside your html's body as follows :
Tags:
jquery option chain
jquery ui option chaining
jquery method option chaining
How to use multiple options to pass to a method in JQuery
How to use multiple options using options for jQuery method
How to use multiple options to pass to a method in JQuery
For example, for the jQuery UI Dialog widget we have a lot of options to choose from like we have maxHeight, minWidth, modal, resizable, draggable to achieve different functionalyties with the widget.
So how to use all or some of these options with the dialog method ?
Here is how we can do it:
We can create a variable containing all the options (name:value) with comma(,) in between multiple values (basically json notation) and then pass the variable to the dialog() method.
$(function(){ var dialogOpts = { show: true, hide: true, maxHeight: 400, minWidth: 850 }; $("#dialog").dialog(dialogOpts); });
where "dialog" is the div name inside your html's body as follows :
<div id="dialog" title="Basic dialog"> <p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p> <p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p> <p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p> <p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p> <p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p> <p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p> <p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p> </div>
Tags:
jquery option chain
jquery ui option chaining
jquery method option chaining
How to use multiple options to pass to a method in JQuery
How to use multiple options using options for jQuery method
How to use multiple options to pass to a method in JQuery
What is the dollar Sign ($) means in JQuery Or how to avoid $ collision from jquery with other languages or technologies
$ (dollar) sign in Jquery is just a method name or identifier name.
As javascript allows the $ sign as a special character including some other special characters to be used as a valid variable name (identifier) or a valid method name.
To make it simple, jQuery and some other languages (scripting or coding) has choosen this $ to use their api (methods) easily.
In jQuery, we can replace the $ sign with the word "jQuery" whenever we encounter $ collision issues with some other coding languages like JSTL (JSP, EL) or prototype etc. and it will do the trick.
Infact we can say, $ is a shortcut symbol for the "jQuery" word.
So in jQuery below code :
is Same as below code:
Tags:
What is the dollar Sign ($) means in JQuery ?
How to avoid $ collision from jquery with other languages or technologies ?
As javascript allows the $ sign as a special character including some other special characters to be used as a valid variable name (identifier) or a valid method name.
To make it simple, jQuery and some other languages (scripting or coding) has choosen this $ to use their api (methods) easily.
In jQuery, we can replace the $ sign with the word "jQuery" whenever we encounter $ collision issues with some other coding languages like JSTL (JSP, EL) or prototype etc. and it will do the trick.
Infact we can say, $ is a shortcut symbol for the "jQuery" word.
So in jQuery below code :
<script> $(function() { $( "#dialog" ).dialog(); }); </script>
is Same as below code:
<script> jQuery(function() { jQuery( "#dialog" ).dialog(); }); </script>
Tags:
What is the dollar Sign ($) means in JQuery ?
How to avoid $ collision from jquery with other languages or technologies ?
Friday, July 12, 2013
How to know whether a WebService WSDL file is of SOAP version 1.1 or 1.2 compliant
If your WSDL file has a namespace named "soap12" inside the <wsdl:definitions tag, as shown below:
<wsdl:definitions xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
Then the wsdl is SOAP 1.2 version compliant /compatible.
References:
http://schemas.xmlsoap.org/wsdl/soap12/soap12WSDL.htm
<wsdl:definitions xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
Then the wsdl is SOAP 1.2 version compliant /compatible.
References:
http://schemas.xmlsoap.org/wsdl/soap12/soap12WSDL.htm
validate a webservice wsdl file online
Below are some sites to validate the WSDL file hosted some where in the internet.
1. http://www.validwsdl.com/
2. http://xmethods.net/ve2/Tools.po
1. http://www.validwsdl.com/
2. http://xmethods.net/ve2/Tools.po
Thursday, July 4, 2013
Content is not allowed in prolog. org.xml.sax.SAXParseException: Content is not allowed in prolog.
SEVERE: Parse Fatal Error at line 2 column 1: Content is not allowed in prolog. org.xml.sax.SAXParseException: Content is not allowed in prolog. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source) at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1642) at org.apache.catalina.startup.Catalina.load(Catalina.java:524) at org.apache.catalina.startup.Catalina.load(Catalina.java:562) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:261) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) Jul 4, 2013 3:43:44 PM org.apache.catalina.startup.Catalina load WARNING: Catalina.start using conf/server.xml: org.xml.sax.SAXParseException: Content is not allowed in prolog. at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
We get this error, due to some characters in the xml file (in my case it was server.xml file) are not liked by the Parser. Even when you open the same file in IE browser, it will not open up. Also IDE like MyEclipse also shows same error "Content is not allowed in prolog."
I could not find out, which character or line are not liked by the parser.
So the solution for me : I took another same xml file (which was working) and replaced it and made changes as per my requirement.
That's it !!
Wednesday, July 3, 2013
java.lang.NullPointerException at org.apache.jsp.index_jsp._jspInit(index_jsp.java:22) and javax.servlet.ServletException: java.lang.LinkageError
SEVERE: Servlet.service() for servlet jsp threw exception java.lang.NullPointerException at org.apache.jsp.index_jsp._jspInit(index_jsp.java:22) at org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:52) at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:164) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:340) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260) at javax.servlet.http.HttpServlet.service(HttpServlet.java:723) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at java.lang.Thread.run(Thread.java:619) Jul 3, 2013 5:27:29 PM org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet jsp threw exception
I googled it, found some suggestions like,
we have jsp-api.jar and servlet-api.jar placed inside the project’s WEB-INF/lib
directory and That’s causing the issue. Because it should not be there as Tomcat
has it already these jars in its lib.
But removing that jar from the
projects gives me this below error:
And Sometimes, when you delete some conflicting jars (but still some conflicts remains there), then you may get below exception :
javax.servlet.ServletException: java.lang.LinkageError: loader constraint violation: when resolving interface method "javax.servlet.jsp.JspApplicationContext.getExpressionFactory()Ljavax/el/ExpressionFactory; " the class loader (instance of org/apache/jasper/servlet/JasperLoader) of the current class, org/apache/jsp/index_jsp, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, javax/servlet/jsp/JspApplicationContext, have different Class objects for the type javax/el/ExpressionFactory used in the signature org.apache.jasper.servlet.JspServlet.service(JspServlet.java:343) javax.servlet.http.HttpServlet.service(HttpServlet.java:722) root cause java.lang.LinkageError: loader constraint violation: when resolving interface method "javax.servlet.jsp.JspApplicationContext.getExpressionFactory()Ljavax/el/ExpressionFactory;" the class loader (instance of org/apache/jasper/servlet/JasperLoader) of the current class, org/apache/jsp/index_jsp, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, javax/servlet/jsp/JspApplicationContext, have different Class objects for the type javax/el/ExpressionFactory used in the signature
Now the root cause of this issue is jar files conflict.
Basically identical jar's located inside server's (like Tomcat's) lib directory conflict with same jars found in your deployed application's WEB-INF/lib/ directory.
Below jars in my case above were causing the issue.
1. servlet-api.jar
2. jsp-api.jar
3. el-api.jar
I had these in the BuildPath of my MyEclipse, because of class files had dependency on these.. so could not delete from there. But when I deploy the application, these jars get copied into the TOMCAT_HOME/webapps/myproject/WEB-INF/lib/
And by default my TOMCAT_HOME/lib/ directory had these jars.
Now, I can not delete the servlet-api and jsp-api jars from my MyEclipse build path, otherwise my code will have so many compile errors due to classNotFound.
So the solution I used is:
1. I deleted servlet-api and jsp-api jars from my MyEclipse build path, and in place of these, I used javaee.jar (which had all the required class files for my project to compile).
2. Also completely deleted the el-api.jar file too from the build path
Hope that helps for you too!!
References:
http://stackoverflow.com/questions/8487048/java-lang-linkageerror-javax-servlet-jsp-jspapplicationcontext-getexpressionfac
spring / JSTL $ variable does not display the value Or Spring $ variable not carrying into view / JSP
The expression language (EL, $ syntax) like ${message} doesn't work in my JSP / JSTL tags while working with Spring!
I noticed this issue while working with Spring demo.
Lets discuss first what was my settings and what I tried to make it work, then will take about the solution.
I was setting the variable in the spring Controller like below:
And I was trying to use the "msg" variable in the JSP (abcd.jsp) as below:
Tried every possible combination of displaying the variable in the jsp.
But I was not getting any value corresponding to the variable when used along with the EL $, I used to get below response through JSP page when run under tomcat 5.5.x:
So, after googling out, I found that, its the Servlet and JSP versions not compatible with the server.
Basically in my web.xml I had declared the version of Servlet I am using is 2.5 as below:
But, I was deploying above application on a Tomcat server of version 5.5.x (which supports Servlets version 2.4). And that was the main root cause.
So, When I deployed the application to Tomcat 6.x (supporting Servlets 2.5 and a higher version of JSP and EL), It worked fine.
Now I am getting the expected result of the above JSP (abcd.jsp) page, the output is shown below:
Hope this helps you too!!
References I followed:
http://stackoverflow.com/tags/jstl/info
I noticed this issue while working with Spring demo.
Lets discuss first what was my settings and what I tried to make it work, then will take about the solution.
I was setting the variable in the spring Controller like below:
@RequestMapping("/hello") public ModelAndView helloWorld() { String message = "HELLO SPRING MVC"; return new ModelAndView("abcd", "msg", message); } /* Even I tried below way of setting the variable msg */ @RequestMapping("/welcome") public String welcomeWorld(Model m) { String s = "HELLO SPRING MVC"; m.addAttribute("msg", s); return "welcome"; }
And I was trying to use the "msg" variable in the JSP (abcd.jsp) as below:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="s" uri="http://www.springframework.org/tags" %> <html> <body> Message is: <%= request.getAttribute("msg") %> <br/> Message is: <c:out value="${msg}" /> <br/> Message is: ${"msg"} <br/> Message is: ${msg} <br/> </body> </html>
Tried every possible combination of displaying the variable in the jsp.
But I was not getting any value corresponding to the variable when used along with the EL $, I used to get below response through JSP page when run under tomcat 5.5.x:
So, after googling out, I found that, its the Servlet and JSP versions not compatible with the server.
Basically in my web.xml I had declared the version of Servlet I am using is 2.5 as below:
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> <servlet> <servlet-name>spring</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>spring</servlet-name> <url-pattern>*.html</url-pattern> </servlet-mapping> </web-app>
But, I was deploying above application on a Tomcat server of version 5.5.x (which supports Servlets version 2.4). And that was the main root cause.
So, When I deployed the application to Tomcat 6.x (supporting Servlets 2.5 and a higher version of JSP and EL), It worked fine.
Now I am getting the expected result of the above JSP (abcd.jsp) page, the output is shown below:
Hope this helps you too!!
References I followed:
http://stackoverflow.com/tags/jstl/info
Friday, June 28, 2013
is invalid; nested exception is org.xml.sax.SAXParseException: Element type "bean" must be followed by either attribute specifications, ">" or "/>".
If you are getting extra special characters (like ascii or hexa or any weird characters) in your script/xml/txt file OR
If you are getting an error like below in your logs:
Though you keep formatting the xml, but still the error remains same as shown below:
Solutions #1:
1. Copy the code showing error into just plain notepad.
2. try deleting all the spaces between words and then manually use spacebar to add spaces between words/attributes.
3. Again copy the code from notepad and then paste into your IDE/Editor.
This should have solved.
But, in some cases, this also does not solve the issue.
Solutions #2:
1. Open the same excel file in an advanced editor like notepad++,
2. Go to the "Encode" menu --> choose "Encode in ANSI"
3. Now you should be able to see all those invisible ansi characters you have derived while copy pasting from internet (shown below):
4. So you got now proof that you have some to give company there in your xml file.
Delete all those, characters manually or by using the editors find/replace (ctrl + h ) option:
5. Now try changing the encoding to the other formats, you will be surprised to see more invisible characters suddenly becomes visible to you :)
6. Play around with encodings, delete those chars and Save.
Rerun the application. You should be fine.
If you are in Unix Environment, and you doubt your script file (.sh) contains any special characters, you can view those special characters using VI editor.
Open the file using VI editor:
$ vi <file_name>
Hit Esc
Then type in the command line of the vi editor as (To be able to see the extra characters)- :set list
To again hide the special characters or make the file to be seen as normal, type in the command line- :set nolist
If you are getting an error like below in your logs:
2013-06-28 08:57:02,295 ERROR [org.springframework.web.context.ContextLoader] - <Context initialization failed> org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 67 in XML document from ServletContext resource [/WEB-INF/spring-configuration/ticketRegistry.xml] is invalid; nested exception is org.xml.sax.SAXParseException: Element type "bean" must be followed by either attribute specifications, ">" or "/>". at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180) at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125) at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94) at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:131) at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:522) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:436) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111) at org.jasig.cas.web.init.SafeContextLoaderListener.contextInitialized_aroundBody0(SafeContextLoaderListener.java:75) at org.jasig.cas.web.init.SafeContextLoaderListener.contextInitialized_aroundBody1$advice(SafeContextLoaderListener.java:57) at org.jasig.cas.web.init.SafeContextLoaderListener.contextInitialized(SafeContextLoaderListener.java:1) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:943) at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:778) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:504) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065) at org.apache.catalina.core.StandardHost.start(StandardHost.java:840) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) at org.apache.catalina.core.StandardService.start(StandardService.java:525) at org.apache.catalina.core.StandardServer.start(StandardServer.java:754) at org.apache.catalina.startup.Catalina.start(Catalina.java:595) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) Caused by: org.xml.sax.SAXParseException: Element type "bean" must be followed by either attribute specifications, ">" or "/>".The reason could be that your xml file contains some invisible characters to your eye (basically some ansi characters), Normally this happens when you copy the code from internet browser or pdf and paste into your editor/IDE.
Though you keep formatting the xml, but still the error remains same as shown below:
Solutions #1:
1. Copy the code showing error into just plain notepad.
2. try deleting all the spaces between words and then manually use spacebar to add spaces between words/attributes.
3. Again copy the code from notepad and then paste into your IDE/Editor.
This should have solved.
But, in some cases, this also does not solve the issue.
Solutions #2:
1. Open the same excel file in an advanced editor like notepad++,
2. Go to the "Encode" menu --> choose "Encode in ANSI"
3. Now you should be able to see all those invisible ansi characters you have derived while copy pasting from internet (shown below):
4. So you got now proof that you have some to give company there in your xml file.
Delete all those, characters manually or by using the editors find/replace (ctrl + h ) option:
5. Now try changing the encoding to the other formats, you will be surprised to see more invisible characters suddenly becomes visible to you :)
6. Play around with encodings, delete those chars and Save.
Rerun the application. You should be fine.
If you are in Unix Environment, and you doubt your script file (.sh) contains any special characters, you can view those special characters using VI editor.
Open the file using VI editor:
$ vi <file_name>
Hit Esc
Then type in the command line of the vi editor as (To be able to see the extra characters)- :set list
To again hide the special characters or make the file to be seen as normal, type in the command line- :set nolist
Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.hibernate.mapping.SimpleValue.(Lorg/hibernate/mapping/Table;)V
2013-06-28 07:17:07,829 ERROR [org.springframework.web.context.ContextLoader] - <Context initialization failed>
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ticketRegistry' defined in ServletContext resource [/WEB-INF/spring-configuration/ticketRegistry.xml]: Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/deployerConfigContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.hibernate.mapping.SimpleValue.<init>(Lorg/hibernate/mapping/Table;)V
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:616)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:148)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1035)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:939)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
at org.jasig.cas.web.init.SafeContextLoaderListener.contextInitialized_aroundBody0(SafeContextLoaderListener.java:75)
at org.jasig.cas.web.init.SafeContextLoaderListener.contextInitialized_aroundBody1$advice(SafeContextLoaderListener.java:57)
at org.jasig.cas.web.init.SafeContextLoaderListener.contextInitialized(SafeContextLoaderListener.java:1)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:943)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:778)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:504)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/deployerConfigContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.hibernate.mapping.SimpleValue.<init>(Lorg/hibernate/mapping/Table;)V
Solution:
If you are using hibernate-core jar version 3.6 and above, then Take out the dependency (related to hibernate-annotations jar) from your maven or remove the hibernate-annotations jar from your applications lib) :
<artifactId>hibernate-annotations</artifactId>
Chcek maven dependyncy or jar conflicts - mvn dependency:tree or mvn dependency:tree -Dverbose : is used to see/verify the dependency between jars in Maven for your project dir
Maven command
mvn dependency:tree is used to see/verify the dependency between jars used in a particular project.
To run above command, navigate to your project directory and where you have the pom.xml file for the project you want to verify the jar dependencies:
For example, like
Thats the location of my workspace, containing my projects pom file.
So, now you can run the mvn dependency:tree command.
or specifically if you know which jar you are getting loaded as extra then you can filter it to look for that particular jar by providing its groupId and artifactId and its version (all are option values):
where the above format is : mvn dependency:tree -Dincludes=[groupId]:[artifactId]:[version]
To look for a particular jar files groupId and its artifact you can search on below sites:
https://www.versioneye.com/java/org.slf4j:slf4j-api/1.4.2
https://search.maven.org/#search%7Cga%7C1%7Cjcl104-over-slf4j
Also you can use:
In verbose mode the dependency tree shows dependencies that were omitted for: being a duplicate of another; conflicting with another's version and/or scope
References:
http://maven.apache.org/plugins/maven-dependency-plugin/usage.html
http://maven.apache.org/plugins/maven-dependency-plugin/examples/filtering-the-dependency-tree.html
http://maven.apache.org/plugins/maven-dependency-plugin/examples/resolving-conflicts-using-the-dependency-tree.html
mvn dependency:tree is used to see/verify the dependency between jars used in a particular project.
To run above command, navigate to your project directory and where you have the pom.xml file for the project you want to verify the jar dependencies:
For example, like
# cd /opt/cas-workspace/local-cas
Thats the location of my workspace, containing my projects pom file.
[root@www local-cas]# ls -l total 20 -rw-r--r-- 1 root root 8795 Jun 25 11:33 pom.xml drwxr-xr-x 3 root root 4096 Jun 5 07:33 src drwxr-xr-x 5 root root 4096 Jun 25 11:57 target
So, now you can run the mvn dependency:tree command.
# mvn dependency:tree
or specifically if you know which jar you are getting loaded as extra then you can filter it to look for that particular jar by providing its groupId and artifactId and its version (all are option values):
> mvn dependency:tree -Dincludes=org.slf4j:slf4j-api:1.4.2
where the above format is : mvn dependency:tree -Dincludes=[groupId]:[artifactId]:[version]
To look for a particular jar files groupId and its artifact you can search on below sites:
https://www.versioneye.com/java/org.slf4j:slf4j-api/1.4.2
https://search.maven.org/#search%7Cga%7C1%7Cjcl104-over-slf4j
Also you can use:
# mvn dependency:tree -Dverbose
In verbose mode the dependency tree shows dependencies that were omitted for: being a duplicate of another; conflicting with another's version and/or scope
References:
http://maven.apache.org/plugins/maven-dependency-plugin/usage.html
http://maven.apache.org/plugins/maven-dependency-plugin/examples/filtering-the-dependency-tree.html
http://maven.apache.org/plugins/maven-dependency-plugin/examples/resolving-conflicts-using-the-dependency-tree.html
Cannot create a session after the response has been committed : CAS application error
Below is an issue related to CAS,
Env is: CAS 3.5.2 deployed on Tomcat 6.
"When I login I get an error. If I refresh/resubmit the information it goes through and operates normally. Any advice would be greatly appreciated."
The error is below:
Solution:
"I assume that happens when there is no 'service' param and CAS tries to render a successful generic login page. Correct? If so, that is a side effect that is caused by 'terminateWebSessionListener' bean defined in cas-servlet.xml. You could a) disable one b) set the 'timeToDieInSeconds' property to a higher value to remedy this annoyance, like so":
https://lists.wisc.edu/read/messages?id=27757318#27757318
Env is: CAS 3.5.2 deployed on Tomcat 6.
"When I login I get an error. If I refresh/resubmit the information it goes through and operates normally. Any advice would be greatly appreciated."
The error is below:
type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request exception org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalStateException: Cannot create a session after the response has been committed
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:894) org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789) javax.servlet.http.HttpServlet.service(HttpServlet.java:637) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.jasig.cas.web.init.SafeDispatcherServlet.service_aroundBody2(SafeDispatcherServlet.java:128) org.jasig.cas.web.init.SafeDispatcherServlet.service_aroundBody3$advice(SafeDispatcherServlet.java:57) org.jasig.cas.web.init.SafeDispatcherServlet.service(SafeDispatcherServlet.java:1) org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259) com.github.inspektr.common.web.ClientInfoThreadLocalFilter.doFilter(ClientInfoThreadLocalFilter.java:63) root cause java.lang.IllegalStateException: Cannot create a session after the response has been committed org.apache.catalina.connector.Request.doGetSession(Request.java:2400) org.apache.catalina.connector.Request.getSession(Request.java:2120) org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:833) org.springframework.webflow.context.servlet.HttpSessionMap.getMutex(HttpSessionMap.java:98) org.springframework.webflow.core.collection.LocalSharedAttributeMap.getMutex(LocalSharedAttributeMap.java:39) org.springframework.webflow.conversation.impl.ContainedConversation.unlock(ContainedConversation.java:108) org.springframework.webflow.execution.repository.support.ConversationBackedFlowExecutionLock.unlock(ConversationBackedFlowExecutionLock.java:55) org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:178) org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:183) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882) org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789) javax.servlet.http.HttpServlet.service(HttpServlet.java:637) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.jasig.cas.web.init.SafeDispatcherServlet.service_aroundBody2(SafeDispatcherServlet.java:128) org.jasig.cas.web.init.SafeDispatcherServlet.service_aroundBody3$advice(SafeDispatcherServlet.java:57) org.jasig.cas.web.init.SafeDispatcherServlet.service(SafeDispatcherServlet.java:1) org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259) com.github.inspektr.common.web.ClientInfoThreadLocalFilter.doFilter(ClientInfoThreadLocalFilter.java:63)
Solution:
"I assume that happens when there is no 'service' param and CAS tries to render a successful generic login page. Correct? If so, that is a side effect that is caused by 'terminateWebSessionListener' bean defined in cas-servlet.xml. You could a) disable one b) set the 'timeToDieInSeconds' property to a higher value to remedy this annoyance, like so":
<bean id="terminateWebSessionListener" class="org.jasig.cas.web.flow.TerminateWebSessionListener" p:serviceManagerUrl="${cas.securityContext.serviceProperties.service}" p:timeToDieInSeconds="5"/>Via Reference:
https://lists.wisc.edu/read/messages?id=27757318#27757318
Wednesday, June 26, 2013
Error creating bean with name 'ticketRegistry' defined in ServletContext resource [/WEB-INF/spring-configuration/ticketRegistry.xml]: Could not resolve matching constructor (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)
If you are working on CAS for SSO functionality and while trying to use CAS server, you got below exceptions in your log:
2013-06-26 06:12:57,764 ERROR [org.springframework.web.context.ContextLoader] - <Context initialization failed>
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ticketRegistry' defined in ServletContext resource [/WEB-INF/spring-configuration/ticketRegistry.xml]: Could not resolve matching constructor (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:250)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1035)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:939)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
at org.jasig.cas.web.init.SafeContextLoaderListener.contextInitialized_aroundBody0(SafeContextLoaderListener.java:75)
at org.jasig.cas.web.init.SafeContextLoaderListener.contextInitialized_aroundBody1$advice(SafeContextLoaderListener.java:57)
at org.jasig.cas.web.init.SafeContextLoaderListener.contextInitialized(SafeContextLoaderListener.java:1)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:943)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:778)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:504)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
2013-06-26 06:12:57,768 ERROR [org.jasig.cas.web.init.SafeContextLoaderListener] - <SafeContextLoaderListener:
The Spring ContextLoaderListener we wrap threw on contextInitialized.
But for our having caught this error, the web application context would not have initialized.>
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ticketRegistry' defined in ServletContext resource [/WEB-INF/spring-configuration/ticketRegistry.xml]: Could not resolve matching constructor (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:250)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1035)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:939)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
at org.jasig.cas.web.init.SafeContextLoaderListener.contextInitialized_aroundBody0(SafeContextLoaderListener.java:75)
at org.jasig.cas.web.init.SafeContextLoaderListener.contextInitialized_aroundBody1$advice(SafeContextLoaderListener.java:57)
at org.jasig.cas.web.init.SafeContextLoaderListener.contextInitialized(SafeContextLoaderListener.java:1)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:943)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:778)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:504)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
SafeContextLoaderListener:
The Spring ContextLoaderListener we wrap threw on contextInitialized.
Solution:
Basically you might get this because of these reasons (I used to get):
1. Jar files not found in applications WEB-INF/lib directory
Or, some jars are conflicting with each other.
Check for same jars in different versions should not exist (at least in some cases).
2. Check you maven's dependencies (for getting these jars).
You can use mvn dependency:tree to find out if there is any jar loaded twice, which might be causing conflict.
3. the pom.xml file should contain proper dependencies.
deployerConfigContext.xml, ticketRegistry.xml should have right beans and configured properly depending on your CAS server (Basically different CAS servers use different configurations in these files).
2013-06-26 06:12:57,764 ERROR [org.springframework.web.context.ContextLoader] - <Context initialization failed>
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ticketRegistry' defined in ServletContext resource [/WEB-INF/spring-configuration/ticketRegistry.xml]: Could not resolve matching constructor (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:250)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1035)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:939)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
at org.jasig.cas.web.init.SafeContextLoaderListener.contextInitialized_aroundBody0(SafeContextLoaderListener.java:75)
at org.jasig.cas.web.init.SafeContextLoaderListener.contextInitialized_aroundBody1$advice(SafeContextLoaderListener.java:57)
at org.jasig.cas.web.init.SafeContextLoaderListener.contextInitialized(SafeContextLoaderListener.java:1)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:943)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:778)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:504)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
2013-06-26 06:12:57,768 ERROR [org.jasig.cas.web.init.SafeContextLoaderListener] - <SafeContextLoaderListener:
The Spring ContextLoaderListener we wrap threw on contextInitialized.
But for our having caught this error, the web application context would not have initialized.>
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ticketRegistry' defined in ServletContext resource [/WEB-INF/spring-configuration/ticketRegistry.xml]: Could not resolve matching constructor (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:250)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1035)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:939)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
at org.jasig.cas.web.init.SafeContextLoaderListener.contextInitialized_aroundBody0(SafeContextLoaderListener.java:75)
at org.jasig.cas.web.init.SafeContextLoaderListener.contextInitialized_aroundBody1$advice(SafeContextLoaderListener.java:57)
at org.jasig.cas.web.init.SafeContextLoaderListener.contextInitialized(SafeContextLoaderListener.java:1)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:943)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:778)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:504)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
SafeContextLoaderListener:
The Spring ContextLoaderListener we wrap threw on contextInitialized.
Solution:
Basically you might get this because of these reasons (I used to get):
1. Jar files not found in applications WEB-INF/lib directory
Or, some jars are conflicting with each other.
Check for same jars in different versions should not exist (at least in some cases).
2. Check you maven's dependencies (for getting these jars).
You can use mvn dependency:tree to find out if there is any jar loaded twice, which might be causing conflict.
3. the pom.xml file should contain proper dependencies.
deployerConfigContext.xml, ticketRegistry.xml should have right beans and configured properly depending on your CAS server (Basically different CAS servers use different configurations in these files).
Cannot execute mojo: tree. It requires a project with an existing pom.xml, but the build is not using one
When
run below command :
Result:
Try with the -e option:
Result:
Normally this error happens, when you try to run the mvn dependency:tree command from a location, where it does not find a POM.
mvn dependency:tree is used to see/verify the dependency between jars used in a particular project.
So, the solution is :
navigate to your project directory and where you have the pom.xml file for the project you want to verify the jar dependencies:
For example, like
Thats the location of my workspace, containing my projects pom file.
[root@www ~]# mvn dependency:tree
Result:
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'dependency'.
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO] task-segment: [dependency:tree]
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Cannot execute mojo: tree. It requires a project with an existing pom.xml, but the build is not using one.
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Wed Jun 26 02:38:40 EDT 2013
[INFO] Final Memory: 3M/61M
[INFO] ------------------------------------------------------------------------
Try with the -e option:
[root@www ~]# mvn -e dependency:tree
Result:
+ Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'dependency'.
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO] task-segment: [dependency:tree]
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Cannot execute mojo: tree. It requires a project with an existing pom.xml, but the build is not using one.
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Cannot execute mojo: tree. It requires a project with an existing pom.xml, but the build is not using one.
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Cannot execute mojo: tree. It requires a project with an existing pom.xml, but the build is not using one.
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:414)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
... 17 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Wed Jun 26 02:38:57 EDT 2013
[INFO] Final Memory: 3M/61M
[INFO] ------------------------------------------------------------------------
Normally this error happens, when you try to run the mvn dependency:tree command from a location, where it does not find a POM.
mvn dependency:tree is used to see/verify the dependency between jars used in a particular project.
So, the solution is :
navigate to your project directory and where you have the pom.xml file for the project you want to verify the jar dependencies:
For example, like
# cd /opt/cas-workspace/local-cas
Thats the location of my workspace, containing my projects pom file.
[root@www local-cas]# ls -l
total 20
-rw-r--r-- 1 root root 8795 Jun 25 11:33 pom.xml
drwxr-xr-x 3 root root 4096 Jun 5 07:33 src
drwxr-xr-x 5 root root 4096 Jun 25 11:57 target
So, now you can run the mvn dependency:tree command.
References:
http://maven.apache.org/plugins/maven-dependency-plugin/usage.html
http://maven.apache.org/plugins/maven-dependency-plugin/examples/resolving-conflicts-using-the-dependency-tree.html
References:
http://maven.apache.org/plugins/maven-dependency-plugin/usage.html
http://maven.apache.org/plugins/maven-dependency-plugin/examples/resolving-conflicts-using-the-dependency-tree.html
Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument
Error:
Also, add the corresponding Database driver jar file. Or add it to your pom's dependency.
e.g.:
For adding MySQL Server driver, the Maven's POM dependency would be:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ticketRegistry' defined in ServletContext resource [/WEB-INF/spring-configuration/ticketRegistry.xml]: Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/deployerConfigContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/util/DTDEntityResolver
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
Solution:
If you are using Hibernate 3.5 or above, You should remove the dependency on hibernate-annotations from your maven pom file.
If you got this while building CAS server using the root pom file.
Try removing any spring related dependencies mentioned in the projects root POM file. Internally the CAS will download all the spring dependencies.
Also, add the corresponding Database driver jar file. Or add it to your pom's dependency.
e.g.:
For adding MySQL Server driver, the Maven's POM dependency would be:
<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.13</version> <scope>runtime</scope> </dependency>
References:
Purging / Delete local maven (mvn) repository
Local mvn repository is nothing but a cache of part of the contents of online repository.
Sometimes it becomes messy with duplicate jars.
So, time to time we should clean the local maven repository (only when you should have internet access and can download again from online repositories):
maven repository is located in your systems, current users home / root path inside a directory named ".m2".
in Unix, navigate to that directory and then delete the "repository" directory. and rebuild the pom.xml
Go to the root:
List out the contents in root, with -a attrribute, to show system, hidden files/directories too (basically files with all attributes will be listed):
Delete the repository dir:
Sometimes it becomes messy with duplicate jars.
So, time to time we should clean the local maven repository (only when you should have internet access and can download again from online repositories):
maven repository is located in your systems, current users home / root path inside a directory named ".m2".
In windows it should be at : C:\Documents and Settings\<username>\ In Linux, it should be at : ~ (root location)
in Unix, navigate to that directory and then delete the "repository" directory. and rebuild the pom.xml
Go to the root:
[root@www ~]# cd
List out the contents in root, with -a attrribute, to show system, hidden files/directories too (basically files with all attributes will be listed):
[root@www ~]# ls -laResult should show something like this below:
Delete the repository dir:
[root@www ~]# rm -rf ~/.m2/repository [root@www ~]# cd .m2 [root@www .m2]# ls -l total 0
Now again do a build of your project's pom file:
Navigate to your projects pom file directory:
# cd <projects workspace location containing pom.xml>
# mvn clean package
It should then download all required jars to the same repository again.
Otherwise you can use the command : mvn dependency:purge-local-repository
The default behaviour of the plugin is to first resolve the entire dependency tree, then delete the contents from the local repository, and then re-resolve the dependencies from the remote repository.
References:
http://maven.apache.org/plugins/maven-dependency-plugin/examples/purging-local-repository.html
Otherwise you can use the command : mvn dependency:purge-local-repository
The default behaviour of the plugin is to first resolve the entire dependency tree, then delete the contents from the local repository, and then re-resolve the dependencies from the remote repository.
References:
http://maven.apache.org/plugins/maven-dependency-plugin/examples/purging-local-repository.html
Tuesday, June 25, 2013
dependencies.dependency.version is missing for org.hibernate hibernate-core jar and other hibernate jars
# mvn clean package
[INFO] Scanning for projects...
[INFO] ------------------------------ ------------------------------ ------------
[ERROR] FATAL ERROR
[INFO] ------------------------------ ------------------------------ ------------
[INFO] Error building POM (may not be this project's POM).
Project ID: rsi.ddms.cas:local-cas
POM Location: /opt/cas-workspace/local-cas/ pom.xml
Validation Messages:
[0] 'dependencies.dependency. version' is missing for org.hibernate:hibernate-core: jar
[1] 'dependencies.dependency. version' is missing for org.hibernate:hibernate- entitymanager:jar
Reason: Failed to validate POM for project rsi.ddms.cas:local-cas at /opt/cas-workspace/local-cas/ pom.xml
[INFO] ------------------------------ ------------------------------ ------------
[INFO] Trace
org.apache.maven.reactor. MavenExecutionException: Failed to validate POM for project rsi.ddms.cas:local-cas at /opt/cas-workspace/local-cas/ pom.xml
at org.apache.maven.DefaultMaven. getProjects(DefaultMaven.java: 404)
at org.apache.maven.DefaultMaven. doExecute(DefaultMaven.java: 272)
at org.apache.maven.DefaultMaven. execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli. main(MavenCli.java:362)
at org.apache.maven.cli.compat. CompatibleMain.main( CompatibleMain.java:60)
at sun.reflect. NativeMethodAccessorImpl. invoke0(Native Method)
at sun.reflect. NativeMethodAccessorImpl. invoke( NativeMethodAccessorImpl.java: 39)
at sun.reflect. DelegatingMethodAccessorImpl. invoke( DelegatingMethodAccessorImpl. java:25)
at java.lang.reflect.Method. invoke(Method.java:597)
at org.codehaus.classworlds. Launcher.launchEnhanced( Launcher.java:315)
at org.codehaus.classworlds. Launcher.launch(Launcher.java: 255)
at org.codehaus.classworlds. Launcher.mainWithExitCode( Launcher.java:430)
at org.codehaus.classworlds. Launcher.main(Launcher.java: 375)
Caused by: org.apache.maven.project. InvalidProjectModelException: Failed to validate POM for project rsi.ddms.cas:local-cas at /opt/cas-workspace/local-cas/ pom.xml
at org.apache.maven.project. DefaultMavenProjectBuilder. processProjectLogic( DefaultMavenProjectBuilder. java:1077)
at org.apache.maven.project. DefaultMavenProjectBuilder. buildInternal( DefaultMavenProjectBuilder. java:880)
at org.apache.maven.project. DefaultMavenProjectBuilder. buildFromSourceFileInternal( DefaultMavenProjectBuilder. java:508)
at org.apache.maven.project. DefaultMavenProjectBuilder. build( DefaultMavenProjectBuilder. java:200)
at org.apache.maven.DefaultMaven. getProject(DefaultMaven.java: 604)
at org.apache.maven.DefaultMaven. collectProjects(DefaultMaven. java:487)
at org.apache.maven.DefaultMaven. getProjects(DefaultMaven.java: 391)
... 12 more
Basically, we get this error while doing maven build.
The reason is that, your pom xml file does not either have the version tag specified for that artifact to be downloaded.
Or the jar is not found in the repositories mentioned there in.
Simple Solution is :
Add the version tag in your pom file as:
<dependency>
<groupId>org.hibernate</ groupId>
<artifactId>hibernate-core</ artifactId>
<version>3.6.10.Final</ version>
</dependency>
Monday, June 24, 2013
How to Set Up Apache Virtual Hosts on CentOS 6
Sometimes when we want to run / host multiple domain (websites) on a single server with a single public IP address, we need to setup Virtual hosts using apache server to achieve the same.
Here is a very nice article on that:
https://www.digitalocean.com/community/articles/how-to-set-up-apache-virtual-hosts-on-centos-6
Here is a very nice article on that:
https://www.digitalocean.com/community/articles/how-to-set-up-apache-virtual-hosts-on-centos-6
Thursday, June 20, 2013
Free Code Syntax Highlighters for your website or blogs
Free Javascript (JS) Code Syntax Highlighters For For your websites or blogs:
Below is a very nice post:
http://www.1stwebdesigner.com/css/16-free-javascript-code-syntax-highlighters-for-better-programming/
http://tools.dottoro.com/services/highlighter/
Below is a very nice post:
http://www.1stwebdesigner.com/css/16-free-javascript-code-syntax-highlighters-for-better-programming/
http://tools.dottoro.com/services/highlighter/
Wednesday, June 19, 2013
sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provid er.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
I got this exception, while my demo java web application tried to communicate CAS application (deployed in tomcat) using SSL.
I have my tomcat server already configured using SSL certificates and using a keystore file to have the security certificate.
I got below stacktrace of the errors in my console:
Jun 19, 2013 4:26:27 PM org.jasig.cas.client.util.CommonUtils getResponseFromServer
SEVERE: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1611)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:187)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:181)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1035)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:124)
at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:516)
at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:454)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:884)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1112)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1139)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1123)
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:418)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:166)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1041)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:234)
at org.jasig.cas.client.util.CommonUtils.getResponseFromServer(CommonUtils.java:326)
at org.jasig.cas.client.util.CommonUtils.getResponseFromServer(CommonUtils.java:305)
at org.jasig.cas.client.validation.AbstractCasProtocolUrlBasedTicketValidator.retrieveResponseFromServer(AbstractCasProtocolUrlBasedTicketValidator.java:50)
at org.jasig.cas.client.validation.AbstractUrlBasedTicketValidator.validate(AbstractUrlBasedTicketValidator.java:207)
at org.jasig.cas.client.validation.AbstractTicketValidationFilter.doFilter(AbstractTicketValidationFilter.java:169)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.jasig.cas.client.authentication.AuthenticationFilter.doFilter(AuthenticationFilter.java:116)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:881)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:674)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:541)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:619)
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:285)
at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:191)
at sun.security.validator.Validator.validate(Validator.java:218)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:126)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:209)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:249)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1014)
... 33 more
Below is my tomcat's "server.xml" section having SSL configuration details:
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
address="216.113.229.31"
maxThreads="150" scheme="https" secure="true"
truststoreFile="/usr/local/apache-tomcat-6.0.37/conf/cacerts.jks" truststorePass="changeit"
keystoreFile="/usr/local/apache-tomcat-6.0.37/conf/myServerKeystore.jks" keystorePass="changeit"
clientAuth="false" sslProtocol="TLS" />
Also, I have imported server Root CA certificate into my browsers.
The reason of the above error, I could figured out is that:
Though I have configured the tomcat to use, "myServerKeystore.jks" java keystore file.
But the Java web applications seems to use by default the security certificates available in the "cacerts" file (located at $JAVA_HOME/jre/lib/security/).
The 1st solutions is:
step 1.
Copy your "cacerts" file (located at $JAVA_HOME/jre/lib/security/ ) to some safe backup location in case to be able to revert back to original.
Using Below command in Linx (Similarly you can achieve it in Windows too) to import ssl certificate from one keystore into another keystore using keytool:
# keytool -importkeystore -destkeystore /usr/java/default/jre/lib/security/cacerts -srckeystore myServerKeystore.jks
For windows above can be some thing like this:
C:\certs> keytool -importkeystore -destkeystore C:\Program Files\Java\jdk1.6.0_24\jre\lib\security\cacerts -srckeystore myServerKeystore.jks
Assuming "myServerKeystore.jks" is at "C:\certs" or accordingly provide the path above for your keystore.
Result will be something like below:
Enter destination keystore password: [enter password here, default is "changeit"]
Enter source keystore password: [enter password here, default is "changeit"]
Entry for alias localhostservcert successfully imported.
Import command completed: 1 entries successfully imported, 0 entries failed or cancelled
Marked in bold above are, meant to be changed if required as per your settings.
Now, restart your server and try again.
Above exception should have been resolved.
If still the issue has not resolved yet, Please consider below importing the root certificate into "cacerts" :
The 2nd solutions is:
step 1.
Copy your "cacerts" file (located at $JAVA_HOME/jre/lib/security/ ) to some safe backup location in case to be able to revert back to original.
References used:
https://wiki.jasig.org/display/CASUM/SSL+Troubleshooting+and+Reference+Guide
http://stackoverflow.com/questions/9619030/resolving-javax-net-ssl-sslhandshakeexception-sun-security-validator-validatore?rq=1
I have my tomcat server already configured using SSL certificates and using a keystore file to have the security certificate.
I got below stacktrace of the errors in my console:
Jun 19, 2013 4:26:27 PM org.jasig.cas.client.util.CommonUtils getResponseFromServer
SEVERE: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1611)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:187)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:181)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1035)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:124)
at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:516)
at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:454)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:884)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1112)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1139)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1123)
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:418)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:166)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1041)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:234)
at org.jasig.cas.client.util.CommonUtils.getResponseFromServer(CommonUtils.java:326)
at org.jasig.cas.client.util.CommonUtils.getResponseFromServer(CommonUtils.java:305)
at org.jasig.cas.client.validation.AbstractCasProtocolUrlBasedTicketValidator.retrieveResponseFromServer(AbstractCasProtocolUrlBasedTicketValidator.java:50)
at org.jasig.cas.client.validation.AbstractUrlBasedTicketValidator.validate(AbstractUrlBasedTicketValidator.java:207)
at org.jasig.cas.client.validation.AbstractTicketValidationFilter.doFilter(AbstractTicketValidationFilter.java:169)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.jasig.cas.client.authentication.AuthenticationFilter.doFilter(AuthenticationFilter.java:116)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:881)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:674)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:541)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:619)
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:285)
at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:191)
at sun.security.validator.Validator.validate(Validator.java:218)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:126)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:209)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:249)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1014)
... 33 more
Below is my tomcat's "server.xml" section having SSL configuration details:
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
address="216.113.229.31"
maxThreads="150" scheme="https" secure="true"
truststoreFile="/usr/local/apache-tomcat-6.0.37/conf/cacerts.jks" truststorePass="changeit"
keystoreFile="/usr/local/apache-tomcat-6.0.37/conf/myServerKeystore.jks" keystorePass="changeit"
clientAuth="false" sslProtocol="TLS" />
Also, I have imported server Root CA certificate into my browsers.
The reason of the above error, I could figured out is that:
Though I have configured the tomcat to use, "myServerKeystore.jks" java keystore file.
But the Java web applications seems to use by default the security certificates available in the "cacerts" file (located at $JAVA_HOME/jre/lib/security/).
The 1st solutions is:
step 1.
Copy your "cacerts" file (located at $JAVA_HOME/jre/lib/security/ ) to some safe backup location in case to be able to revert back to original.
step 2.
Export the security certificates from your keystore file (in my case its "myServerKeystore.jks") into "cacerts" (located at $JAVA_HOME/jre/lib/security/ ) .Using Below command in Linx (Similarly you can achieve it in Windows too) to import ssl certificate from one keystore into another keystore using keytool:
# keytool -importkeystore -destkeystore /usr/java/default/jre/lib/security/cacerts -srckeystore myServerKeystore.jks
For windows above can be some thing like this:
C:\certs> keytool -importkeystore -destkeystore C:\Program Files\Java\jdk1.6.0_24\jre\lib\security\cacerts -srckeystore myServerKeystore.jks
Assuming "myServerKeystore.jks" is at "C:\certs" or accordingly provide the path above for your keystore.
Result will be something like below:
Enter destination keystore password: [enter password here, default is "changeit"]
Enter source keystore password: [enter password here, default is "changeit"]
Entry for alias localhostservcert successfully imported.
Import command completed: 1 entries successfully imported, 0 entries failed or cancelled
Marked in bold above are, meant to be changed if required as per your settings.
Now, restart your server and try again.
Above exception should have been resolved.
If still the issue has not resolved yet, Please consider below importing the root certificate into "cacerts" :
The 2nd solutions is:
step 1.
Copy your "cacerts" file (located at $JAVA_HOME/jre/lib/security/ ) to some safe backup location in case to be able to revert back to original.
step 2.
Sometimes, the certificate to be imported MUST be a DER-encoded file. If the contents of the certificate file are binary, it's likely DER-encoded; if the file begins with the text ---BEGIN CERTIFICATE---, it is PEM-encoded and needs to be converted to DER encoding.
So if your root certificate is a PEM encoded, Convert your to a DER format using below command:
# openssl x509 -in casRootCAcert.crt -out casRootCAcert.der -outform DER
Where "casRootCAcert.crt" is my original root CA certificate (the one you used while creating server certificates). As I created in this tutorial.
And where as "casRootCAcert.der" is the new DER formated root CA.
step 3.
Now Export the DER formatted Root CA certificate into "cacerts" (located at $JAVA_HOME/jre/lib/security/ ).
# keytool -import -keystore $JAVA_HOME/jre/lib/security/cacerts -file casRootCAcert.der -alias myservercert
Now, restart your server and try again.
Above exception should have been resolved.
step 4.
Sometimes, the certificate to be imported MUST be a DER-encoded file. If the contents of the certificate file are binary, it's likely DER-encoded; if the file begins with the text ---BEGIN CERTIFICATE---, it is PEM-encoded and needs to be converted to DER encoding.
So if your root certificate is a PEM encoded, Convert your to a DER format using below command:
# openssl x509 -in casRootCAcert.crt -out casRootCAcert.der -outform DER
Where "casRootCAcert.crt" is my original root CA certificate (the one you used while creating server certificates). As I created in this tutorial.
And where as "casRootCAcert.der" is the new DER formated root CA.
step 3.
Now Export the DER formatted Root CA certificate into "cacerts" (located at $JAVA_HOME/jre/lib/security/ ).
# keytool -import -keystore $JAVA_HOME/jre/lib/security/cacerts -file casRootCAcert.der -alias myservercert
Now, restart your server and try again.
Above exception should have been resolved.
step 4.
List out to see if the $JAVA_HOME/jre/lib/security/cacerts has your trusted certificate alias:
# keytool -list -keystore $JAVA_HOME/jre/lib/security/cacerts
Look for your server certificate alias name, like above, look for "myservercert" or by default it creates an alias named as "mykey".
If it exist, then time to test your ssl connection again.
Now, restart your server and try again.
Above exception should have been resolved.
If you are looking for how to automatically create certificates and import it into keystore, for your development environment, please follow this post.# keytool -list -keystore $JAVA_HOME/jre/lib/security/cacerts
Look for your server certificate alias name, like above, look for "myservercert" or by default it creates an alias named as "mykey".
If it exist, then time to test your ssl connection again.
Now, restart your server and try again.
Above exception should have been resolved.
References used:
https://wiki.jasig.org/display/CASUM/SSL+Troubleshooting+and+Reference+Guide
http://stackoverflow.com/questions/9619030/resolving-javax-net-ssl-sslhandshakeexception-sun-security-validator-validatore?rq=1
Subscribe to:
Posts (Atom)