Showing posts with label eclipse. Show all posts
Showing posts with label eclipse. Show all posts

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 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


Thursday, February 13, 2014

java.lang.OutOfMemoryError: PermGen space

java.lang.OutOfMemoryError: PermGen space

Problem :


We come across this common exception when starting STS Eclipse or trying to compile java classes through maven command.

Exception I Encountered Was :


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

[ERROR] PermGen space -> [Help 1]
java.lang.OutOfMemoryError: PermGen space
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:14
1)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(Cl
assRealm.java:389)
        at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(
SelfFirstStrategy.java:42)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadCl
ass(ClassRealm.java:259)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm
.java:242)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm
.java:227)
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:14
1)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(Cl
assRealm.java:389)
        at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(
SelfFirstStrategy.java:42)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadCl
ass(ClassRealm.java:259)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm
.java:242)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm
.java:227)
        at org.apache.maven.plugin.jar.AbstractJarMojo.createArchive(AbstractJar
Mojo.java:202)
        at org.apache.maven.plugin.jar.AbstractJarMojo.execute(AbstractJarMojo.j
ava:255)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(Default
BuildPluginManager.java:106)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:208)
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/OutOfMemoryErr
or
###################################################################################################################

Solution :


This exception was caused when i was starting the Eclipse for the very first time and also while i was using the mvn compile command to compile the java classes. To resolve this exception i increased the memory size in command prompt before restarting eclipse and increasing the memory in maven options. See below for the examples.

Example :


- Follow the above steps outlined and you should be able to resolve it :

1)Add this to command line JVM before starting tomcat server : -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled 2)For Maven options use this : set MAVEN_OPTS=-Xmx512m -XX:MaxPermSize=128m This should resolve the above exceptions.


Similar Exception :

     

- java.lang.OutOfMemoryError: PermGen space


Tuesday, February 11, 2014

resource is out of sync with the file system


resource is out of sync with the file system

Problem :


We come across this common exception when using eclipse and try to start the tomcat server.

Exception I Encountered Was :


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

resource is out of sync with the file system ... with may file names listed...

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

Solution :


This exception was caused when i switched to a different work space and restarted tomcat server. It started throwing these errors. Please follow any of the solutions to vanish the error.

1) Right click on the file or project and select refresh. This should be enough to clear all the errors related to resource is out of sync with the file system exception.

2) You can set the preferences to automatically refresh your project with the following steps :
  • Select Window in eclipse menu then
  • Select Preferences
  • Select & Expand first tab General and then
  • Select Workspace and then
  • Select the option "Refresh Automatically" or "Refresh using native hooks or polling" then
  • Click apply
  • Click Ok

  • Now you are good to go.....


Example :


- Follow the above steps outlined and you should be able to resolve it.


Similar Exception :

     

- resource is out of sync with the file system


Wednesday, January 22, 2014

Server Tomcat v6.0 Server at localhost was unable to start within 45 seconds

Server Tomcat v6.0 Server at localhost was unable to start within 45 seconds. If the server requires more time, try increasing the timeout in the server editor.

Problem :


We come across this common exception when start / restart tomcat web server and it doesn't start in default 45 seconds.

Exception I Encountered Was :


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

Server Tomcat v6.0 Server at localhost was unable to start within 45 seconds. If the server requires more time, try increasing the timeout in the server editor.

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

Solution :


Generally this exception is caused when Tomcat Server doesnt start within the default server startup time which is 45 second. To resolve this you can increase the server timeout settings as explained below.

Example :


- Double click on the server in eclipse
- In Overview tab select Timeouts
- For Start (in seconds) increase the time in seconds appropriately
- Save and restart the server
- This should resolve the exception.

Similar Exception :

     
- Server Tomcat v6.0 Server at localhost was unable to start within 45 seconds
- If the server requires more time, try increasing the timeout in the server editor


java.lang.ClassFormatError: Duplicate method name signature in class file

java.lang.ClassFormatError: Duplicate method name&signature in class file

Problem :


We come across this common exception when using eclipse.

Exception I Encountered Was :


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

java.lang.ClassFormatError: Duplicate method name signature in class file

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

Solution :


This exception was caused when i was importing maven project in my eclipse. After importing the project and starting the server i came across this common exception. Please see the below explanation to resolve the exception.


Example :


When trying to import a already existing Maven project, select / browse the appropriate folder. Then click on finish rather than clicking the next button.

Clicking the next button created a different package structure which actually caused the exception "java.lang.ClassFormatError".

Similar Exception :

     

- java.lang.ClassFormatError: Duplicate method name signature in class file