java.lang.NoSuchMethodError: org.apache.commons.codec.binary.Base64.encodeBase64String() in Java EE application

That method was introduced in Commons Codec 1.4. This exception indicates that you’ve an older version of Commons Codec somewhere else in the webapp’s runtime classpath which got precedence in classloading. Check all paths covered by the webapp’s runtime classpath. This includes among others the Webapp/WEB-INF/lib, YourAppServer/lib, JRE/lib and JRE/lib/ext. Finally remove or upgrade the … Read more

Maven: Including a META-INF folder in the classes folder

In general, for a Java-based Maven project, non-source files should go in the src/main/resources sub-directory of the project. The contents of that resources directory are copied to the output directory (by default, target/classes) during the process-resources phase of the build. For Maven WAR projects, it is slightly more complicated: there is also the src/main/webapp directory, … Read more

log4j 2 adding multiple colors to console appender

I think I found the solution. I downloaded log4j2-core-sources.jar and traced the source. You can write it as below; <Console name=”SlowConsole” target=”SYSTEM_OUT”> <PatternLayout disableAnsi=”false” pattern=”%highlight{%d{HH:mm:ss.SSS} %-5level %logger{36}.%M() @%L – %msg%n}{FATAL=red blink, ERROR=red, WARN=yellow bold, INFO=black, DEBUG=green bold, TRACE=blue}”/> </Console> I think log4j2 documentation and its examples may need to be updated.

Servlet Filter: How to get all the headers from servletRequest?

Typecast ServletRequest into HttpServletRequest (only if ServletRequest request is an instanceof HttpServletRequest). Then you can use HttpServletRequest.getHeader() and HttpServletRequest.getHeaderNames() method. Something like this: @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest httpRequest = (HttpServletRequest) request; Enumeration<String> headerNames = httpRequest.getHeaderNames(); if (headerNames != null) { while (headerNames.hasMoreElements()) { System.out.println(“Header: ” … Read more

UnsupportedClassVersionError: JVMCFRE003 bad major version in WebSphere AS 7

WebSphere Application Server V7 does support Java Platform, Standard Edition (Java SE) 6 (see Specifications and API documentation in the Network Deployment (All operating systems), Version 7.0 Information Center) and it’s since the release V8.5 when Java 7 has been supported. I couldn’t find the Java 6 SDK documentation, and could only consult IBM JVM … Read more

Java how to instantiate a class from string [duplicate]

“Using java.lang.reflect” will answer all your questions. First fetch the Class object using Class.forName(), and then: If I want to instantiate a class that I retrieved with forName(), I have to first ask it for a java.lang.reflect.Constructor object representing the constructor I want, and then ask that Constructor to make a new object. The method … Read more

Why is the ‘anonymousUser’ authenticated in Spring Security?

This is how spring-security works by default. From the docs: Note that there is no real conceptual difference between a user who is “anonymously authenticated” and an unauthenticated user. Spring Security’s anonymous authentication just gives you a more convenient way to configure your access-control attributes. Calls to servlet API calls such as getCallerPrincipal, for example, … Read more

The type java.io.ObjectInputStream cannot be resolved. It is indirectly referenced from required .class files

Something happened in Java 8 Update 91 that broke existing JSP code. That seems pretty clear. Here is a sample of similar questions and bug reports: Unable to compile JSP file with JDK1.8.0_92 Spring MVC – Unable to compile class for JSP Unable to access CloudPlatform Client https://bugs.openjdk.java.net/browse/JDK-8155588 (closed as “not an issue”) https://bugs.openjdk.java.net/browse/JDK-8155223 (closed … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)