Question: I am having trouble to set both my www.domain.org and domain.org to point to Heroku rails app.

I did a CNAME from www to www.example.org.herokudns.com.
it works fine and my www.example.org point to my example.herokuapp.com

Concerning <https://example.org>

Should I do a 
CNAME from @ to example.herokudns.com ? 
ALIAS is only accepted for IPs with my domain provider..

I having trouble finding an answer in stackoverflow.

Should I use <http://wwwizer.com/naked-domain-redirect> ?
Do I have a solution without using a third party free service ?

Answer: 
You could introduce a helper method that retrieves the method and the class names from the current thread : 

```
private static MethodAndClassName retrieveMethodAndClassName() {
       StackTraceElement[] allStackTraces = Thread.currentThread().getStackTrace();
       StackTraceElement currentMethod = allStackTraces[2]; 
       return new MethodAndClassName(currentMethod.getMethodName(), currentMethod.getClassName());      
}

```

Note that the method invocations are stacked. I get the third last nested call (`allStackTraces[2]`) because the last call (`allStackTraces[0]`) is `Thread.getStackTrace()`, the before last call (`allStackTraces[1]`) is `retrieveMethodAndClassName()` and the before before last call (`allStackTraces[2]`) is what you look for : the method that invoked `retrieveMethodAndClassName()`. 

`MethodAndClassName` is a custom class that defines needed information to trace : 

```
public class MethodAndClassName {

    private String method;
    private String clazz;

    public MethodAndClassName(String method, String clazz) {
        this.method = method;
        this.clazz = clazz;
    }

    public String getMethodName() {
        return method;
    }

    public String getClassName() {
        return clazz;
    }
}

```

And in your client code use it such as : 

```
 public User findUser(Long id){

      if(id == null || id < 1){             
           throw new BadRequestException(ReflectionHelper.retrieveMethodAndClassName(), String.format(
                                         "Invalid Id: %d", id));
      }

      User user = userRepository.findOne(id);

      if(user == null){
           throw new DataNotFoundException(ReflectionHelper.retrieveMethodAndClassName(), String.format(
                                           "Can't Find User for Id: %d", id));
      }
      return user;
 }

```
Use Throwable.getStackTrace(). This will return an array of StackTraceElement, and the first entry will point to where the the Throwable was instantiated.