Thursday, October 8, 2015

org/apache/commons/dbcp2/BasicDataSource : Unsupported major.minor version 51.0


org/apache/commons/dbcp2/BasicDataSource : Unsupported major.minor version 51.0

Problem :


I came across this common exception when i was setting up datasource for spring application.

Exception I Encountered Was :


###################################################################################################################

org/apache/commons/dbcp2/BasicDataSource : Unsupported major.minor version 51.0

###################################################################################################################

Solution :


When I was setting up the datasource for Spring Application and had to use BasicDataSource jar file. The jar which i was using was not compatible with the java / jvm version i was using.


run mvn dependency:tree then you will know the exact jar which is compatible with the java version you have to use then change the version in dependency and again run the maven command to resolve the exception. Hope this helps resolve your exception, Happy Coding.

Similar Exception :


- org/apache/commons/dbcp2/BasicDataSource : Unsupported major.minor version 51.0
- UnsupportedClassVersionError unsupported major.minor version 51.0
- unsupported major.minor version 51.0 unable to load class


Friday, July 31, 2015

The method print() is undefined for the type Controller


The method print() is undefined for the type Controller

Problem :


I came across this common exception when i was using mocks for unit testing spring application.

Exception I Encountered Was :


###################################################################################################################

The method print() is undefined for the type Controller

###################################################################################################################

Solution :


When unit testing your spring application with mocks you need to make sure that you are using the neccessary static imports in your code.
See below for the list of static imports to use.
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; 

Once i had the static import in place it resolved the exception. Hope this helps resolve your exception, Happy Coding.

Similar Exception :


- How to test a spring controller method by using MockMvc?
- My test helper methods get() status() are undefined
- the method post(string) is undefined for controller test
- Integration testing of spring MVC applicaitons


Tuesday, June 30, 2015

The method post(string) is undefined for controller test


The method post(string) is undefined for controller test

Problem :


I came across this common exception when i was using mocks for unit testing spring application.

Exception I Encountered Was :


################################################################################################### ################

the method post(string) is undefined for controller test

################################################################################################### ################

Solution :


When unit testing your spring application with mocks you need to make sure that you are using the necessary static imports in your code.
See below for the list of static imports to use.
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;

Once i had the static imports in place it resolved the exception. Hope this helps resolve your exception, Happy Coding.

Similar Exception :


- How to test a spring controller method by using MockMvc?
- My test helper methods get() status() are undefined
- the method post(string) is undefined for controller test
- Integration testing of spring MVC applicaitons
- the method print() is undefined for the type Controller


Tuesday, June 23, 2015

project build error: 'dependencies.dependency.groupid' for null:spring-test.jar


project build error: 'dependencies.dependency.groupid' for null:spring-test.jar

Problem :


I came across this common exception when i was manually updating maven dependencies in eclipse.

Exception I Encountered Was :


###################################################################################################################

project build error: 'dependencies.dependency.groupid' for null:spring-test.jar

###################################################################################################################

Solution :


I was manullay updating maven dependencies and gave artifact groupid instead of groupId (I is caps), be specific when you type the artifacts. Do cross check your artifacts if you have manually updated your artifacts.

Similar Exception :

     

- 'dependencies.dependency.version' is missing error, but version is managed in parent
- 'dependencies.dependency.groupid' for null:spring-test.jar
- Missing artifact but jars are in place
- org.springframework.security:spring-security-parent:jar:3.0.7.RELEASE:compile
- Could not resolve dependencies, artifacts could not be resolved



Wednesday, June 10, 2015

The type password is not accessible due to restriction on required library


The type password is not accessible due to restriction on required library

Problem :


We come across this common exception when i was using com.sun.* pacakge in our java code.

Exception I Encountered Was :


###################################################################################################################

the type password is not accessible due to restriction on required library

###################################################################################################################

Solution :


I was using com/sun/xml/internal.* package in my code. I had to update Access rules in eclipse to overcome this exception.
Please refer below to see how it was fixed.

It can be fixed in the follows two ways :


First method :

1) Go to Eclipse 2) Click on Project -> Properties 3) Select Java Build Path in left hand navigation 4) Select Libraries tab. 5) Then Expand JRE System Library entry and Select "Access rules" and hit the Edit button. 6) A new dialog windows opens 7) Click the add button and click ok. 8) Select Accessible in resolution and in Rule pattern add "com/sun/xml/internal/**". Second Method : 1) Go to Eclipse 2) Click on Project -> Properties 3) Select Java Build Path in left hand navigation 4) Select Libraries tab. 5) Select JRE System Library and click remove. 6) Click on Add Library and select JRE System Library 7) Select workspace default library or the one you want to select and click Finish. 8) For me the default worked. I hope this resolves your above exception / error, happy coding.


Similar Exception :

     

- the type password is not accessible due to restriction on required library
- Project won't compile when using com.sun.xml.internal.ws.server.UnsupportedMediaException
- How to overcome “package com.sun.xml.internal.xxx does not exist”


Wednesday, June 3, 2015

No naming context bound to this class loader


No naming context bound to this class loader

Problem :


We come across this common exception when i removed the project and re-imported it again in eclipse.

Exception I Encountered Was :


###################################################################################################################

No naming context bound to this class loader

###################################################################################################################

Solution :


I was using existing maven project in Eclipse. So i had to run a maven command to add the porject and then referesh the project to resolve it.
Please refer below to see how it was fixed.

Example :


- Follow these steps to resolve the exception :

1) Open DOS command prompt and navigate to your project folder where you have your pom.xml file. 2) Run the following command :
mvn eclipse:eclipse -Dwtpversion=2.0
3) Refresh the project in eclipse. 4) Now right click on server and select "add and remove" option, you should see your applicaion in the list to add. I hope this resolves your above exception / error, happy coding.


Similar Exception :

     

- No naming context bound to this class loader
- There are No resources that can be added or removed from the server
- How can I add my application to Tomcat in Eclipse?
- What needs to be done to add a project to a Server in Eclipse ?
- There are no projects that can be added or removed from the server


Wednesday, April 22, 2015

There are No resources that can be added or removed from the server


There are No resources that can be added or removed from the server

Problem :


We come across this common exception when we are not able to add application to tomcat server thru add and remove option in eclipse.

Exception I Encountered Was :


###################################################################################################################

There are No resources that can be added or removed from the server

###################################################################################################################

Solution :


I was using existing maven project in Eclipse. So i had to run a maven command to add the project and then refresh the project to resolve it.
Please refer below to see how it was fixed.

Example :


- Follow these steps to resolve the exception :

1) Open DOS command prompt and navigate to your project folder where you have your pom.xml file. 2) Run the following command :
mvn eclipse:eclipse -Dwtpversion=2.0
3) Refresh the project in eclipse. 4) Now right click on server and select "add and remove" option, you should see your applicaion in the list to add. I hope this resolves your above exception / error, happy coding.


Similar Exception :

     

- There are No resources that can be added or removed from the server
- How can I add my application to Tomcat in Eclipse?
- What needs to be done to add a project to a Server in Eclipse ?
- There are no projects that can be added or removed from the server