2016年1月20日 星期三

Sony Vaio Windows 10 Upgrade Dim Screen Problem

From
http://superuser.com/questions/951531/windows-10-upgrade-lost-brightness-sony-vaio-laptop

Do this:
I had to edit the registry key FeatureTestControl in
HKEY LOCAL MACHINE\SYSTEM\ControlSet001\Control\Class{4d36e968-e325-11ce-bfc1-08002be10318}\0000 (or 0001)
I set the value to 0x0000fb20 (64288). Screen brightness works fine now.

2015年10月18日 星期日

Remove Spring Framework and Dynamic Dependency Injection

It's hard to remove the Spring framework especially it is the foundation of other software modules such as Hibernate, Spring Security, and Struts2.

HibernateTemplate was removed and replaced by straight forward Hibernate 4.3 calls.

Removed Spring Security and replaced it by Apache Shiro (not sure how to use it yet).

Later to investigate of using Google Dagger 2 for compile time Dependency Injection.

Move the class OnShelfValidateAction from
package com.tencircles.app.webapp.action.media;
to
package com.tencircles.app.webapp.action.advertisement;

IF the servlet and servlet mapping are not matched, then you get the following error:

18-Oct-2015 19:36:29.857 SEVERE [http-apr-8080-exec-19] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start:
 org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/TenCircles]]


Struts2 Filter Upgrade

2015年9月8日 星期二

Hibernate 2 to Hibernate 4

Transition from Hibernate 2 to Hibernate 4


Tried to go through the intermediate step from H2 to H3 but encountered some problems.   So might as well go to H4.


  1. Use org.springframework.orm.hibernate4.LocalSessionFactoryBean instead oforg.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean.
It is similar in role to the same-named class in the orm.hibernate3 package. However, in                      practice, it is closer to AnnotationSessionFactoryBean since its core purpose is to bootstrap a            SessionFactory from annotation scanning. It  will do for both mapping files as well as                    annotated entities.

           Hibernate configuration file - 
           <bean id="sessionFactory"

         class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
      </bean>

      <bean id="transactionManager"
         class="org.springframework.orm.hibernate4.HibernateTransactionManager">
         <property name="sessionFactory" ref="sessionFactory" />
      </bean>
   2. Services provide various types of functionality, in a pluggable manner. Specifically they are interfaces defining certain functionality and then implementations of those service contract interfaces. The interface is known as the service role; the implementation class is known as the service implementation. The pluggability comes from the fact that the service implementation adheres to contract defined by the interface of the service role and that consumers of the service program to the service role, not the implementation.
3. <bean id="hibernateCacheProvider" class="com.funtoro.app.hibernate.ExternalEhCacheProvider" depends-on="cacheManager"/>

The 'depends-on' attribute and property is used not only to specify an initialization time dependency, but also to specify the corresponding destroy time dependency (in the case of singleton beans only). Dependent beans that are defined in the 'depends-on' attribute will be destroyed first prior to the relevant bean itself being destroyed. This thus allows you to control shutdown order too.

2015年7月30日 星期四

Spring MVC2 and Apache Struts2

Spring and Apache MVC2

Spring
1. In application web.xml, define a 'servlet name' with a spring class and the URL pattern.  In the below example, the 'servlet name' is 'home'.    This is VERY important as spring looks for a ${servlet name}-servlet.xml in the same directory to set up the transfers between controller, modeler, and viewer.

<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
<web-app>
<display-name>Spring MVC</display-name>
<servlet>
<servlet-name>home</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>home</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
2. in home-servlet.xml, it tells spring that the MVC is annotation driven and the package name to scan for those MVC components.
<!-- the following two lines tell Spring what to do with the Application code -->
<mvc:annotation-driven />
<context:component-scan base-package="com.urpattern.circleme.springmvc" />
<!-- tells Spring what's the Viewer's URL pattern such as .jsp suffix -->
<!-- <mvc:resources mapping="/resources/**" location="/resources/" /> -->
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix">
<value>/views/</value>
</property>
<property name="suffix" value=".jsp" />
</bean>
</beans>
 Note the 'property' names and values given to the Spring '
InternalResourceViewResolver'
3. Component Annotation Scanning by Spring
The annotation tag @Controller tells Spring this is the application controller class. 
The annotation tag, @RequestMapping(/allhomes), tells Spring which URL, here '/allhomes', will be directed to this method of the controller, e.g. showAllHomes(Map<String, Object> model).  When transferring execution to this method, Spring also passes in a 'model'.  So the Controller prepares/calculates data and sets the return values in this 'model', then transfer execution to the Viewer (e.g. "home_list").   The viewer, home_list.jsp, will render the view of this 'model'.

The @autowire tells Spring to inject the instance of the class 'HomeService' into setHomeService() method.

@Controller
public class HomeController {
 ...
private HomeService homeService;
public HomeService getHomeService() {
return homeService;
}
@Autowired
public void setHomeService(HomeService homeService) {
this.homeService = homeService;
}
@RequestMapping("/allhomes")
public String showAllHomes(Map<String, Object> model) {
model.put("homes", getHomeService().fetchAllHomes());
return "home_list";
}

Deprecated Servlet in Struts2
org.springframework.web.servlet.DispatcherServlet

Missing Struts 1 Filter
java.lang.RuntimeException: java.lang.RuntimeException: com.opensymphony.xwork2.inject.DependencyException: com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyException: No mapping found for dependency [type=java.lang.String, name='actionPackages'] in public void org.apache.struts2.config.ClasspathPackageProvider.setActionPackages(java.lang.String).

at com.opensymphony.xwork2.inject.ContainerBuilder$4.create(ContainerBuilder.java:132)





From Codebehind to Convention Plugin

Changes required

  • Replace org.apache.struts2.config.Namespace with org.apache.struts2.convention.annotation.Namespace
  • Replace org.apache.struts2.config.Results with org.apache.struts2.convention.annotation.Results
  • Replace org.apache.struts2.config.Result with org.apache.struts2.convention.annotation.Result
  • Update @Result uses to use result name instead of Class<Result>
  • Update @Result uses to use location instead of value attribute
  • Update web.xml and remove Codebehind params from filter
  • Update CamelCase action results and references to match Convention. For example:
    Previously in Codebehind:
    Given an action named AnExampleAction, a request to /anExample -> AnExampleAction.execute() -> > anExample-index.ftl
    Now in Convention:
    Given an action named AnExampleAction, a request to /an-example -> AnExampleAction.execute() -> an-example-index.ftl

    The pathname is relative to the application context path if it starts with "/" otherwise it is relative to the default results directory.  e.g. if the request is http://localhost:8080/FindMe/userinfo/getname and the result is directed to "fail.jsp", then the 'fail.jsp' should be at http://localhost:8080/FindMe/WEB-INF/pages/userinfo/fail.jsp. Here, the application context is 'http://localhost:8080/FindMe' and the results directory is http://localhost:8080/FindMe/WEB-INF/pages as defined in the struts.xml properties
        <constant name="struts.convention.result.path" value="/WEB-INF/pages"/>

    All action, namespace, interceptor, and XWork package can be changed by annotations.

From import org.apache.struts2.config.ParentPackage; to import org.apache.struts2.convention.annotation.ParentPackage;


2015年7月26日 星期日

Tomcat 8 and Spring Framework

Tomcat 8 and Spring Framework

TOMCAT Manager WAR File Limitation
Edit the file D:\Program Files\apache-tomcat-8.0.24\webapps\manager\WEB-INF\web.xml and update the section with the following:

    <multipart-config>
      <!-- 50MB max, 52428800. 7/26/2015 Changed to 1024,000,000 -->
      <max-file-size>1024000000</max-file-size>
      <max-request-size>1024000000</max-request-size>
      <file-size-threshold>0</file-size-threshold>
    </multipart-config>



Servlet Filter
Servlet Filter is attached before or after Servlet container.  A web application may have multiple servlets. 
A common scenario for a filter is one in which you want to apply preprocessing or postprocessing to requests or responses for a group of servlets, not just a single servlet. If you need to modify the request or response for just one servlet, there is no need to create a filter—just do what is required directly in the servlet itself.
Note that filters are not servlets. They do not implement and override HttpServlet methods such as doGet() or doPost(). Rather, a filter implements the methods of the javax.servlet.Filter interface. The methods are:
  • init()
  • destroy()
  • doFilter()
Any java class that implements these three methods can be configured as a filter.  The servlet container dispatches client HTTP request based on the filter mapping (URL patterns) that are registered in the web.xml by individual filters.   The filter uses the co-routine pattern where all lines of code before
    chain.doFilter(request,response);
are executed.  Here the content of HTTP request can be examined and actions taken.   Then the 'chain.doFilter' calls next filter and eventually the servlet (i.e. application code), which returns HTTP Response.

The execution path then returns to the filter and continues after 'chain.doFilter(request, response)'.   Here, the filters can examine the content of Http Response.   The actions taken can be logging, auditing, security checking, and monitoring.

The order the filters are invoked depends on the order in which they are configured in the web.xml file. The first filter in web.xml is the first one invoked during the request, and the last filter in web.xml is the first one invoked during the response. Note the reverse order during the response.

See Oracle document - http://docs.oracle.com/cd/B14099_19/web.1012/b14017/filters.htm

Spring Security, Servlet, and Web.xml
The architecture of Spring Security is based entirely on Servlet Filters and, as such, comes before Spring MVC in regards to the processing of HTTP requests.

Declare filters in the web.xml of the application:








<filter>
   <filter-name>springSecurityFilterChain</filter-name>
   <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
   <filter-name>springSecurityFilterChain</filter-name>
   <url-pattern>/*</url-pattern>
</filter-mapping>
The filter must be named ‘springSecurityFilterChain’  to match the default bean created by Spring Security in the container.

Event Listeners
The servlet specification includes the capability to track key events in your Web applications through event listeners. This functionality allows more efficient resource management and automated processing based on event status.
There are two levels of servlet events:
  • Servlet context-level (application-level) event
    This event involves resources or state held at the level of the application servlet context object.
  • Session-level event
    This event involves resources or state associated with the series of requests from a single user session; that is, associated with the HTTP session object.
Each of these two levels has two event categories:
  • Lifecycle changes
  • Attribute changes
You can create one or more event listener classes for each of the four event categories. A single listener class can monitor multiple event categories.
Create an event listener class by implementing the appropriate interface or interfaces of the javax.servlet package or javax.servlet.http package.

Event Listener Declaration and Invocation
Event listeners are declared in the application web.xml deployment descriptor through <listener> elements under the top-level <web-app> element. Each listener has its own <listener> element, with a <listener-class> subelement specifying the class name. Within each event category, event listeners should be specified in the order in which you would like them to be invoked when the application runs.
After the application starts up and before it services the first request, the servlet container creates and registers an instance of each listener class that you have declared. For each event category, listeners are registered in the order in which they are declared. Then, as the application runs, event listeners for each category are invoked in the order of their registration. All listeners remain active until after the last request is serviced for the application.
Upon application shutdown, session event listeners are notified first, in reverse order of their declarations, then application event listeners are notified, in reverse order of their declarations.


The execution of a listener is like a interrupt call or aspect concern call.    This call could happen anywhere in the application serving some other requests.   This is not thread safe so shared objects must be protected with 'sync' operation.

Thread Safety
In fact, you can bypass injecting EntityManagerFactory and instead inject the EntityManager directly into BookDBAO. This is because thread safety is not an issue with request-scoped beans. Conversely, developers need to be concerned with thread safety when working with servlets and listeners. Therefore, a servlet or listener needs to inject an EntityManagerFactory instance, which is thread-safe, whereas a persistence context is not thread-safe.

Spring org.springframework.web.filter.DelegatingFilterProxy Class
Proxy for a standard Servlet Filter, delegating to a Spring-managed bean that implements the Filter interface. Supports a "targetBeanName" filter init-param in web.xml, specifying the name of the target bean in the Spring application context.
web.xml will usually contain a DelegatingFilterProxy definition, with the specified filter-name corresponding to a bean name in Spring's root application context. All calls to the filter proxy will then be delegated to that bean in the Spring context, which is required to implement the standard Servlet Filter interface.

NOTE: The lifecycle methods defined by the Servlet Filter interface will by default not be delegated to the target bean, relying on the Spring application context to manage the lifecycle of that bean. Specifying the "targetFilterLifecycle" filter init-param as "true" will enforce invocation of the Filter.init and Filter.destroy lifecycle methods on the target bean, letting the servlet container manage the filter lifecycle.

Spring org.springframework.web.SpringServletContainerInitializer  Class
The jar, spring-web.jar, is part of the application. The following file is the name of the Interface which will be implemented by the class in the content of this file.   This service will be started by Catalina automatically.

C:\Users\shendlz\.m2\repository\org\springframework\spring-web\3.2.4.RELEASE\spring-web-3.2.4.RELEASE.jar\META-INF\services\javax.servlet.ServletContainerInitializer

The content of this file is org.springframework.web.SpringServletContainerInitializer.

Run Web Application in Tomcat from Eclipse
The steps are:
1. Run As - Maven 'clean'
2. Maven 'Update project'
3.Run As -  Maven 'Build'
4. Tomcat Server - Clean (this will do publish after clean)
5. Run As - Run on Server

Before this, one should create a 'Server' in Eclipse by using the installed Tomcat server (assign the Tomcat installed directory).

In 'Server configuration page' (right click on the server) and under 'Server Locations' section, select the 2nd radio button 'Use Tomcat Instalation (takes control of Tomcat instalation)'.

Tomcat Slow Start-up Problem
Refer to this link.  Mostly due to Tomcat's scanning of Servlet 3.0 annotation tags through every jar during start-up time.
http://iswwwup.com/t/9ba94e27ea0a/java-tomcat-7-slow-start-metadata-complete-true-web-xml.html

At least one JAR was scanned for TLDs yet contained no TLDs

To make the warning go away add in catalina.properties :
# Additional JARs (over and above the default JARs listed above) to skip when
# scanning for TLDs. The list must be a comma separated list of JAR file names.
org.apache.catalina.startup.TldConfig.jarsToSkip=logback-classic-1.0.7.jar,\
joda-time-2.1.jar,joda-time-2.1-javadoc.jar,mysql-connector-java-5.1.24-bin.jar,\
logback-core-1.0.7.jar,javax.servlet.jsp.jstl-api-1.2.1.jar

Build a Web Application on Context Path "/"

1. In Eclipse, double click the 'Servers' tab and 'Modules' tab inside server view.  Click on the web app and change the 'Path' to '/'.
2. In maven pom, change the <finalName>/</finalName> to '/' instead of the web app name.

Then, do 'maven update project', clear server working directory, Run as Maven clean, then Run as Maven install, 'clean...' server.   Finally Run as 'Run on Server'.

There are two important points in the the documentation of the Context Container:
  • In individual files (with a ".xml" extension) in the $CATALINA_BASE/conf/[enginename]/[hostname]/ directory. The name of the file (less the .xml extension) will be used as the context path. Multi-level context paths may be defined using #, e.g. foo#bar.xml for a context path of /foo/bar. The default web application may be defined by using a file called ROOT.xml.
  • Only if a context file does not exist for the application in the $CATALINA_BASE/conf/[enginename]/[hostname]/, in an individual file at /META-INF/context.xml inside the application files. If the web application is packaged as a WAR then /META-INF/context.xml will be copied to $CATALINA_BASE/conf/[enginename]/[hostname]/ and renamed to match the application's context path. Once this file exists, it will not be replaced if a new WAR with a newer /META-INF/context.xml is placed in the host's appBase.
So, when you bundle a META-INF/context.xml, the file gets renamed to the name of the WAR and this name becomes the context path, regardless of any path defined in the Context element.
I see thus two options here:
  1. Either set the name of the generated war to a shorter name (I suggest using <finalName> over<warName> which is deprecated AFAIK):
    <project>
      ...
      <build>
        <finalName>mycontext</finalName>
        ...
      </build>
      ...
    </project>
  2. Or use the maven-tomcat-plugin for the deployment and set the context path in the plugin configuration:
    <project>
      ...
      <build>
        ...
        <plugins>
          ...
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>tomcat-maven-plugin</artifactId>
            <version>1.0-SNAPSHOT</version>
            <configuration>
              <path>/mycontext</path>
            </configuration>
          </plugin>
          ...
        </plugins>
        ...

2015年7月13日 星期一

Eclipse JRE Setup


ECLIPSE JAVA JRE
When using Eclipse, in the Java Build environment, the JRE runtime should use JAVA_HOME, not JRE_HOME.

CAN'T START TOMCAT7 as Windows Service
If Tomcat7 service can not be started and got an error message about "%1 is not a valid Win32 application.", it is caused by running a 32-bit version of T Tomcat7 in a 64-bit OS.

To correct the problem, download the 64-bit version of Tomcat7 and it should be started as a Windows service.

Prepare TOMCAT8 as Windows Service
1. Define CATALINA_HOME=$tomcat_installation_directory$
2. Start a new Windows command window
3. cd  "%CATALINE_HOME%\bin"
4. type in "service.bat install".   A new service "Apache Tomcat8" is created.
5. Start Windows Services program and start Tomcat8.
6. Open a browser and type in "http://localhost:8080".  Tomcat8 home page shows up.  One needs to add a privileged user to manager and deploy WAR files.
7. Any time you change Tomcat's configuration file, you need to stop and start Tomcat.

Add TOMCAT8 Privilege User
1. Open and edit Tomcat user definition file - %CATALINA_HOME%\conf\tomcat-users.xml
2. Add the following lines in the <tomcat-users> section for a user/pswd 'tomcat/tomcat'.  Change this to whatever you like.
      <role rolename="manager-gui"/>
      <role rolename="admin-gui"/>
      <user username="tomcat" password="tomcat" roles="manager-gui, admin-gui"/>
3. Stop and start Tomcat8.  You will be prompted to enter id/pswd for management tasks.


JDK 1,8 NOT COMPATIBLE with OLDER Spring Framework
Error message ----   [org.springframework.context.annotation.ComponentScanBeanDefinitionParser] are only available on JDK 1.5 and higher

Downloaded JDK 1,7 version and undeployed from Tomcat7.    Brought up Eclipse and did a 'mvn clean' , then 'mvn build.'

 REPLACE JDK1.5 with JDK1.7
Error Message -----  A resource exists with a different case: '/funtoro-core/src/test/Java'.

This is due to name conflict between this package and another package, probably the 'main' package.

Either remove or do a search on the package name conflict (is there an easy way to do this?)

TEST Directory
The 'test' directory should be under 'src' and not at the same level as 'src.'

API Update - 
OLD :  import org.springframework.security.userdetails.UsernameNotFoundException;
NEW:  import org.springframework.security.core.userdetails.UsernameNotFoundException;

OLD:  import org.springframework.security.providers.encoding.PasswordEncoder;
NEW: import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
OLD: protected PasswordEncoder passwordEncoder;
NEW : protected BCryptPasswordEncoder passwordEncoder;
OLD : String eventId = passwordEncoder.encodePassword(time + "", "eventId");
NEW : String eventId = passwordEncoder.encodePassword(time + "");

JRE VERSION
See this URL: http://stackoverflow.com/questions/3539139/what-causes-a-new-maven-project-in-eclipse-to-use-java-1-5-instead-of-java-1-6-b

The m2eclipse plugin doesn't use Eclipse defaults, the m2eclipse plugin derives the settings from the POM. So if you want a Maven project to be configured to use Java 1.6 settings when imported under Eclipse, configure the maven-compiler-plugin appropriately, as I already suggested:
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <version>2.1</version>
  <configuration>
    <source>1.6</source>
    <target>1.6</target>
  </configuration>
</plugin>
If your project is already imported, update the project configuration (right-click on the project then Maven V Update Project Configuration).



Unable to locate Spring NamespaceHandler for XML schema namespace



Read this page - http://www.baeldung.com/unable-to-locate-spring-namespacehandler-for-xml-schema-namespace.

Add the following to the webapp .pom file -

            <dependency>
                <groupId>org.springframework.security</groupId>
                <artifactId>spring-security-config</artifactId>
                <version>${spring.security.version}</version>
             </dependency>

 

M2Eclipse Plugin Site URL

Basically, I needed to add the m2eclipse plugin to Eclipse. You can find instructions at http://m2eclipse.sonatype.org/installing-m2eclipse.html

MAVEN pom.xml Error 

    - web.xml is missing and <failOnMissingWebXml> is set to true

Solved - just deleted folders within my project .metada .project .settings .classpath

Check WAR after Build
Make sure the correct libraries are included.  POM can be confusing.

Eclipse warning for web.xml: 

“No grammar constraints (DTD or XML schema) detected for the document.”

Add second line so the first two lines of pom.xml are:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>

"Welcome Files cannot begin or end with a /."
- solution : remove the "/"

"An error occurred while filtering resources"

solution - Right click project -> maven -> update project. 

 "Spring-context has a <test> scope, so org.springframework.stereotype was not found."

The class org.springframework.stereotype.Service is contained in the spring-context dependency,  So remove the <scope>test<scope> from spring-context dependency section.

"org.springframework.cache.ehcache is missing"


According to Appendix C. Migrating to Spring Framework 3.2,

"the EHCache support classes in the org.springframework.cache.ehcache package moved from the spring-context module to spring-context-support".

 "IOException is not compatible" in later versions of org.springframework.cache.ehcache.EhCacheManagerFactoryBean

//    public void afterPropertiesSet() throws CacheException, IOException {
    public void afterPropertiesSet() throws CacheException {

"CronTriggerBean is missing"

From Spring 3.1+, Change the Class names for the CronTriggerFactoryBean & JobDetailFactoryBean as like below
   org.springframework.scheduling.quartz.CronTriggerBean 
                               org.springframework.scheduling.quartz.CronTriggerFactoryBean
   org.springframework.scheduling.quartz.JobDetailBean
                               org.springframework.scheduling.quartz.JobDetailFactoryBean
So your steps are:
Change
CronTriggerBean to CronTriggerFactoryBean
JobDetailBean to JobDetailFactoryBean

See this link http://stackoverflow.com/questions/30520265/migrating-from-spring-3-to-spring-4-org-springframework-scheduling-quartz-cron

Eclipse Maven Local Repository

1. define the M2_REPO linked resource in project properties 'Resource->Linked Resources->Path Variables'
2. select the 'local' repository in project properties 'task repository'
3. Window > Preferences > Maven > User Settings as shown below:
4. check the repository is used and rebuild indexWindows->Show View->Other
In the pop-up: Maven->Maven Repositories
Once the view is displayed, right click on the appropriate repo, and select "Rebuild Index"

"Missing artifact javax.jms:jms:jar:1.1" 
This needs jboss repository even though it is our local repository.
See URL - http://stackoverflow.com/questions/3622773/java-net-maven-repo-jms-artifact-missing

"Maven Dependency Library is not including the desired version."
Need to use 'exclusions' in POM to stop the transitive dependencies.  See below.

<dependency>
    <groupId>${project.groupId}</groupId>
    <artifactId>app</artifactId>
    <version>${project.version}</version>
    <exclusions>
        <exclusion>
            <groupId>*</groupId>
            <artifactId>*</artifactId>
        </exclusion>
    </exclusions>
</dependency>
The wildcard on both groupId and artifactId exclude all dependencies that normally would propagate through to the module using this dependency.

This wildcard expression only works for Maven 3.3 and later.



"Jersey-spring 1.19 dependency problem."
The Jersy-spring POM had dependencies on spring-core, spring-context, etc., which have version limitation up to 3.0.0.  So Jersey-spring  always includes those 3.0.0.RC3 version.   Need to exclude those inside this dependency block.

"Spring framework 3.2.4 can work with Hibernate 3 or Hibernate 4"
Watch out the diferent path names form 3 or 4 in the POM of bean spec.

"In hibernate.xml file"
"Referenced file contains errors (http://www.springframework.org/schema/beans/spring-beans-3.2.xsd). For more information, right click on the
 message in the Problems View and select "Show Details..."
If use

"In applicationContext-services.xml"
Change all http://www.springframework.org/schema/*3.2.xsd to 3.1.xsd to remove beans-3.2.xml error.

"No Spring WebApplicationInitializer types detected on classpath"

Two sets of solutions -
1.
That has nothing to do with spring . It is something specified in the servlet 3.0 spec. As I stated it tells the container (in this case Tomcat 7) to not scan for classes implementing ServletContainerInitializer (which is something new in the servlet 3.0 spec it allows you to write a web app without providing a web.xml and use a class implementing that interface to register your servlets etc. Spring provides a wrapper with the SpringServletContainerInitializer which in turn scans for the WebApplicationInitializer interface. So basically your full class path is now scanned twice which in case of a large class path can be killing for your startup time).

2. Two  slf4j.jar (log4j jars) are included in the project POM.  Commented out one of them and problem solved.
If not, do the following:


There are couple of solutions to this:
  • Make sure that you include only one slf4j jar(probably with the higher version) if you have couple of them with different versions on your class path.
  • Sometimes it may not be possible to exclude multiple slf4j jars, as they may be used by other jars internally, which are on your class path. These dependent jar may refer to different versions of slf4j jars which causes your application to fail. In such cases, make sure that you have the jar with higher version of SLF4j added before other jar using SLF4J jars. This will make sure that your java program will pick up the latest version of the SLF4J which obviously is backward compatible.


  
Thank you! The second solution worked for me. –  Biffy Oct 29 '13 at 12:21
  
@Ankur And how do I ensure in eclipse that it will pick up latest one? –  Dangling Piyush Nov 12 '14 at 13:18
2
Specify the latest one first in your project build path. To verify the order check .classpath file of your project. It will show the order in which jar files are added. –  Ankur Shanbhag Nov 13 '14 at 6:06 


"IncompatibleClassChangeError: class ClassMetadataReadingVisitor has interface ClassVisitor as super class"

This error happens when the loaded class i.e. ClassMetadataReadingVisitor does not respect the contract of inherited abstract class or interface i.e. ClassVisitor.
Looks like at load time different versions of the above classes are getting loaded in your case.
Seems you have new spring-core jar and old spring-asm jar in your application. ClassMetadataReadingVisitor class is getting loaded from spring-core and ClassVisitor from spring-asm.
Please check using maven dependency:tree command to see the dependent jars.

Cannot change version of project facet Dynamic Web Module to 3.0.

Another way is to edit the project facet configuration file itself: org.eclipse.wst.common.project.facet.core.xml
Change the dynamic web module version in this line to 3.0 - <installed facet="jst.web" version="2.5"/>
And then:
  1. Right-click on the project (in the Project Explorer panel).
  2. Select Maven » Update Project (or press Alt+F5)
You'll find this file in the .settings directory within the Eclipse project.


Eclipse won't respond to Restful URL with glassfish.jersey jax-rs 2.0  


The problem came from the project properties settings - namely the "Java EE Integration" under Maven.
Solution - Open up this property page, uncheck the "Enable Project Specific Settings."
- Click on the "Configure Workspace Settings"
- Check four items "Enable Java EE Integration", "Maven Archiver gen...", "JAX-RS Configurator", and "JPA Configurator".

This turns on the web services URL processing.