I am working on a web application for Apache Tomcat. I use a class called "Location" in which I defined a field called ipAddresses. Here he is:
package com.maxmind.geoip; import java.util.HashSet; import java.util.Set; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; public class Location { private final static double EARTH_DIAMETER = 2 * 6378.2; private final static double PI = 3.14159265; private final static double RAD_CONVERT = PI / 180; public Set<String> ipAddresses; public String countryCode; public String countryName; public String region; public String city; public String postalCode; public float latitude; public float longitude; public int dma_code; public int area_code; public int metro_code; public Location() { ipAddresses = new HashSet<String>(); } ... }
However, after deploying webapp on the server (war file) and trying to run a servlet that uses this class in it, I get a java.lang.NoSuchFieldError exception for IPaddresses .
Also, when trying to debug (Eclipse), when I reach the place where Location loc = new Location () is called, two strange things happen:
- The encoded constructor is not called, the debugger will not enter it, instead the program counter arrow is displayed at the input in the Location.java file.
- After “returning” from a call to Location loc = new Location () , when I look at the contents of the object, this field does not actually exist.
- The source file that was deployed with the jar file includes this field.
I have tried many things:
- cleaning and building the project and its redeployment.
- cleaning the server’s working directory, either manually or using Eclipse.
- Changing the server’s working directory in Eclipse.
- Reinstalling the server in Eclipse.
- completely reinstall Tomcat, three times and in different places!
I'm pretty stuck. What could it be?
source share