Monday, July 31, 2017

spring security fails checking password



>PROBLEM

The security layer fails to authenticate an user without any apparent reason.


>SOLUTION
There are many possible reasons.
Among other possibilities, check:

1. Fields' length checking.
Check the fields' lengths against the model class.
They must match.

2. Check the password's field configuration.
Usually, encryptors generates encrypted strings with length=64, so the database shall provide compatible value.


>ENV
spring boot 1.5.4.RELEASE
java 8
maven
eclipse

Sunday, July 30, 2017

spring boot: required a bean of type ... that could not be found , Consider defining a bean of type


PROCEDURE TO GUIDE YOU THROUGH HARD ISSUES ... MYSTERIOUS ONES
IN THE CONTEXT DESCRIBED HERE, AND POSSIBLY EXTENSIBLE TO OTHERS


>PROBLEM

Attempt of injecting a bean using Spring Boot and Maven fails with the following message:

Parameter 0 of method setStrongEncryptor in br.com.adr.thylab2.service.security.EncryptionSvcImpl required a bean of type 'org.jasypt.util.password.StrongPasswordEncryptor' that could not be found.
Action:
Consider defining a bean of type 'org.jasypt.util.password.StrongPasswordEncryptor' in your configuration.


>SOLUTION

1. First check your scan configuration.

Go to the class that it is used to start the app.
At @SpringBootApplication annotation check value offered to "scanBasePackages" if it contains a parent path for the class where the problem happens. Sometimes, a class becomes out of the subdirectory tree referenced by the scan value. If there isn't a parent path to the complaining class, add it.
@SpringBootApplication(scanBasePackages={"br.com.adr.thylab2", "my another package here"})

Example:

@SpringBootApplication(scanBasePackages={"br.com.adr.thylab2"})
public class Thylab2App extends SpringBootServletInitializer {
public static final String VERSION = "2.0.0-RELEASE";

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Thylab2App.class);
}
        public static void main(String[] args) {
             SpringApplication.run(Thylab2App.class, args);
        }    
}

2. Check your @Service or @Component annotations in the related classes, those with relationships concerned to the issue.
Is it missing an annotation?
Is it annotated as it should be?


3. Is the missing bean defined?
An alternative is to supply the missing bean using a common class.
For instance:

@Configuration
public class CommonBeans {

    @Bean
    public StrongPasswordEncryptor strongEncryptor(){
        StrongPasswordEncryptor encryptor = new StrongPasswordEncryptor();
        return encryptor;
    }
}


4. Check the library versions.
For instance, if using Maven, go to pom.xml and try to update the version of the related packages, or yet, try to downgrade.
Sometimes, one library causes issues with certain versions of another ones.


5. Eventually, rollback and proceed a step-by-step checking.
If the problem still persists, the issue may be caused by more than one issue, which exception thrown on the stack may interfere with the final results to help finding the solution.
This approach is radical but very effective.

First, you make the famous "backup" of the current project. Just do it, please!
A simple copy of it is enough.
If using versioning, for instance Git or SVN, you may get a previous point prior to the introduction of the new stuff related to the issue. This is the whole point, no matter which version control system you are working with!

5a. Check if your classpath contains the necessary references.
A simple way of doing this is including some testing code that references it.
For instance, if using Spring Boot, you could simply do, like below, in a straight manner in order to skip another possible setbacks to check if your classpath is properly configured.

@SpringBootApplication(scanBasePackages={"br.com.adr.thylab2"})
public class Thylab2App extends SpringBootServletInitializer {
public static final String VERSION = "2.0.0-RELEASE";

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Thylab2App.class);
}

  public static void main(String[] args) {

StrongPasswordEncryptor passwordEncryptor = new StrongPasswordEncryptor();
String encryptedPassword = passwordEncryptor.encryptPassword("");

             SpringApplication.run(Thylab2App.class,  args);
        }    
}

5b. Bring to the code one interface/class set at a time.
Begin with the simplest classes, bringing just one interface/class set, and testing.
Test one after the other, never more than one by its turn.
You'll probably note that this procedure will show more than one issue, but working one by one, helps the compiler to guide you to the solution.

I do sincerely hope that this "laborious and boring" procedure may help you, but surely helped me when I was desperately lost, more than once, trying to find out a mysterious issue.  :-)


>ENV
spring boot 1.5.4.RELEASE
java 8
maven
eclipse

Wednesday, July 19, 2017

MySQL 5.5 ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails


>PROBLEM

Running the script like this:
  \. myScript.sql
fails and returns the message:
  ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails

Nevertheless, if running the command straight on the console, it may work.



>SOLUTION

This issue was solved checking the file's encoding versus the database encoding and matching them.
So, the database was UTF-8, and the script was using the same encoding.



>ENV
Windows
MySQL 5.5

Sunday, July 9, 2017

spring: thymeleaf: There was an unexpected error (type=Not Found, status=404)



>PROBLEM

Pointing to URL returns 404.


Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Sun Jul 09 11:37:35 BRT 2017



There was an unexpected error (type=Not Found, status=404).
No message available





>SOLUTION

The web site server will typically generate a "404 Not Found" message when the resource is not found, like a broken or dead link.

So, go to the Controller class and check the right link to be used.




Attention to the detail that sometimes, the application is not configured to use an extra identification in the URL. This is the case in this example.

Usually, the app's access is done using its name, like this:
  
   http://localhost:8080/appName/index

If the configuration does not use it, then we go straight to the controller's reference, like this:

  http://localhost:8080/index




















Friday, July 7, 2017

spring: thymeleaf: Neither BindingResult nor plain target object for bean name



>PROBLEM

The request returns the following error message:

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.
Fri Jul 07 17:02:46 BRT 2017
There was an unexpected error (type=Internal Server Error, status=500).
Error during execution of processor 'org.thymeleaf.spring4.processor.attr.SpringInputGeneralFieldAttrProcessor' (login)




>SOLUTION

In this example, it missing the object requested by the html template at:



Check your parameters on the respective method in the controller's class.



Fixing the bug, including the missing parameter:




Problem solved.


>ENV
Java
Spring boot
Thymeleaf
Eclipse

Thursday, July 6, 2017

spring: thymeleaf: SpringInputGeneralFieldAttrProcessor Error



>PROBLEM

Running spring and thymeleaf, returns the following error page:


Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Thu Jul 06 17:16:04 BRT 2017
There was an unexpected error (type=Internal Server Error, status=500).
Error during execution of processor 'org.thymeleaf.spring4.processor.attr.SpringInputGeneralFieldAttrProcessor' (login)




>SOLUTION

Since the log is pointing to login, open the class which should have the respective attribute.
To find out, go to the page which is returning the error. The page may be found in the controller.
In this example we get:

@RequestMapping(value = "/", method = RequestMethod.GET)
public String addNewLogin(Login login) {
return "login";
}

Opening the page, check the object pointed by thymeleaf's "th:object" property in form tag.
In this example is "th:object="${login}".
The error message means that the parser is complaining that it was not found the attribute login for Login class.








Opening the respective Login class, you get instead of "login" the "signin" attribute.


]


Switch the wrong attribute by the correct one, as below:









 Now refresh page, and that's it!  :-)


>ENV
Java
Spring boot
Thymeleaf
Eclipse

Friday, June 23, 2017

eclipse warning: An internal error occurred during: "Computing Git status for repository MiniTools". Unexpected internal error near index ...



>PROBLEM

Any change in the project caused the following message:
  An internal error occurred during: "Computing Git status for repository MiniTools".
  Unexpected internal error near index 8
  \target\

>SOLUTION
The error comes from the backslashed used in .ignore file.
Switch the backslashes to slashes.
WRONG: \target\
RIGHT: /target/

>ENV
Git
Eclipse Mars
Windows




Sunday, June 11, 2017

How to fix WordPress when it stops working after plugins' updates





>PROBLEM
The scenary: the WordPress dashboard alarms that it is required to update some plugins.
Then you update the first plugin, the second, the third and suddenly the site stops working, returning code HTTP 500 or another message, and you loose access to it.
If there is no access, there is no dashboard to handle the situation.

>SOLUTION
Sometimes happens that a plugin's update conflicts with others or your site's environment, like php's version, etc.
A solution consists moving all plugins to another folder out your WordPress's folder on the server.
After that, try to access your site and in case of success you may be sure that it was a plugin conflict.
Now, we need a method to restore the plugins at the same time we discover which of them is responsible for the site's crash.

>FIXING
The idea is to move all the plugins to a temporary folder, and then, after you've gained access again to your site, you may point to the dashboard.
At the dashboard, go to plugins and installed plugins.
You'll get a page with many warnings since the plugins directory is empty.
Refresh the page, getting a blank page like that when you started your site from scratch.
Don't panic.

Now, let's discover which plugin is responsible for the issue.
Pick one plugin's folder at once and copy it back from the temporary folder to the original source's folder, for instance:

from
  /temp/akismet
to
  /public_html/yourSite//wp-content/plugins/akismet

After that, go back to your dashboard and refresh the "installed plugins" page.
The plugin is gonna appear there as usual. Activate it.
If plugin activates succesfully, go to the next.
Repeat the same procedure for each plugin until you get the one that crashes your site.
When this happens, usually you'll have to repeat the whole process again, moving out all the plugins and reintroducing one by one and testing.

The one which crashed your site will be skipped, including the future installations, until you discover the reason of the issue.
Sometimes it is due an old environment requiring update or upgrade, a more "drastic update", like php version.

In order to make the things easier when using ftp connections, you may use command line which helps to make things faster.
Here is some code snippet suggestion:

- moving all at once:
rnfr /public_html/pomar/wp-content/plugins
rnto /temp/plugins

- moving from original source place to a temporary folder:
rnfr /public_html/pomar/wp-content/plugins/akismet
rnto /temp/akismet

- moving back from the temporary folder to the original folder:
rnfr /temp/akismet
rnto /public_html/pomar/wp-content/plugins/akismet

- to create a temporary folder, do:
mkd /temp

- for more information check:
https://en.wikipedia.org/wiki/List_of_FTP_commands
https://www.cs.colostate.edu/helpdocs/ftp.html
http://ftpguide.com/

>ftp command summary
@FROM: https://en.wikipedia.org/wiki/List_of_FTP_commands

abor # abort a file transfer
abor # abort an active file transfer.
acct* # send account information
appe # append to a remote file
appe # append.
cdup # change remote working directory to parent directory
cdup # change to parent directory.
cdup # cwd to the parent of the current directory
cwd # change working directory
cwd # rfc 697: change working directory.
dele # delete a remote file
dele # delete file.
eprt # rfc 2428: specifies an extended address and port to which the server should connect.
epsv # rfc 2428: enter extended passive mode.
feat # rfc 2389: get the feature list implemented by the server.
help # return help on using the server
help # returns usage documentation on a command if specified, else a general help document is returned.
list # list remote files
list # returns information of a file or directory if specified, else information of the current working directory is returned.
mdtm # return the modification time of a file
mdtm # rfc 3659: return the last-modified time of a specified file.
mkd # make a remote directory
mkd # make directory.
mlsd # rfc 3659: lists the contents of a directory if a directory is named.
mlst # rfc 3659: provides data about exactly the object named on its command line, and no others.
mode # set file transfer mode
mode # set transfer mode
mode # sets the transfer mode (stream, block, or compressed).
nlst # name list of remote directory
nlst # returns a list of file names in a specified directory.
noop # do nothing
noop # no operation (dummy packet, used mostly on keepalives).
opts # rfc 2389: select options for a feature (for example opts utf8 on).
pass # authentication password.
pass # send password
pasv # enter passive mode.
port # open a data port
port # specifies an address and port to which the server should connect.
pwd # print working directory on remote machine
pwd # print working directory. returns the current directory of the host.
quit # disconnect.
quit # terminate ftp session and exit
rein* # reinitialize the connection
rest # rfc 3659: restart transfer from the specified point.
retr # retrieve a copy of the file
retr # retrieve a remote file
rmd # remove a directory.
rmd # remove a remote directory
rnfr # rename from
rnfr # rename from.
rnto # rename to
rnto # rename to.
site # send site specific command to remote server
site # sends site specific commands to remote server (like site idle 60 or site umask 002). inspect site help output for complete list of supported commands.
size # rfc 3659: return the size of a file.
size # show size of remote file
stat # return server status
stat # returns the current status.
stor # accept the data and to store the data as a file at the server site
stor # store a file on the remote host
stou # store a file uniquely
stou # store file uniquely.
stru # set file transfer structure
stru # set file transfer structure.
syst # return system type
syst # return system type.
type # set file transfer type
type # sets the transfer mode (ascii/binary).
user # authentication username.
user # send new user information
xcup # rfc 775: change to the parent of the current working directory
xmkd # rfc 775: make a directory
xpwd # rfc 775: print the current working directory
xrmd # rfc 775: remove the directory

Sunday, January 29, 2017

Cygwin - Unrecognized TERM type


>PROBLEM

Type a command, for instance man or vi, the command fails with the following message:

  Unrecognized TERM type




>SOLUTION


The issue came from an attempt to switch the initial folder using "--dir" mintty's flag in the "Cygwin64 Terminal.lnk".
It was done something like this:

D:\cygwin64\bin\mintty.exe -i /Cygwin-Terminal.ico --dir  /cygdrive/D/work/devmob2_/cygwin/home/train -w max

The command above was replaced by its default (except -w flag):

D:\cygwin64\bin\mintty.exe -i /Cygwin-Terminal.ico -w max -

Instead, the initial folder was set using windows' HOME envvar.

To set windows HOME envvar:
  sysdm.cpl
Add:
  HOME=/cygdrive/l/work/devmob2_/cygwin/home

Sunday, July 24, 2016

WildFly fails to start a service due to bind error - Switching port



>PROBLEM

WildFly fails to start a service throwing the following message:
  Caused by: java.net.BindException: Address already in use: bind




>SOLUTION

Edit the following file:

  $WILDFLY_ROOTDIR\standalone\configuration\standalone.xml
  $WILDFLY_ROOTDIR\standalone\configuration\standalone-full.xml

and switch the ports:

- original value:

    <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
        <socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/>

- new configuration using an available port:

    <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
        <socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9991}"/>


To check if a port is currently unavailable, use netstat command.
Example:
  netstat -nao | grep 9991
If the command returns empty, the port is available (not used).

NOTE:
If using windows, you may use cygwin to make available the grep command.

Monday, November 2, 2015

svn: warning: W155010: '/cygdrive ...


>PROBLEM

svn fails throwing the folling message:
  svn: warning: W155010: '/cygdrive ...




>SOLUTION

The cygwin's svn command is called instead a windows command, like Tortoise, etc.
Correct the Path envvar.
Set the windows' cmd path (i.e. Tortoise) before cygwin's path.

>ENV

windows7

Sunday, August 30, 2015

Arquillian exceptions: Caused by: java.lang.IllegalArgumentException: DeployableContainer must be specified


>PROBLEM

  Caused by: java.lang.IllegalArgumentException: DeployableContainer must be specified
 
  or
 
  org.jboss.arquillian.container.test.impl.client.deployment.ValidationException: DeploymentScenario contains a target (_DEFAULT_) not matching any defined Container in the registry.
  Please include at least 1 Deployable Container on your Classpath.
  add a container adapter to the classpath.


>SOLUTION

Go to http://arquillian.org/guides/getting_started/ at "Add a Container Adapter" topic.


Friday, August 21, 2015

"couldn't make stderr distinct from stdout" when running Cygwin commands


>SOLUTION

Check you envvars.

Originally the Path had Git's bin before cygwin64.
  Path=..;C:\Git\bin;C:\cygwin64\bin

Switching places:
  Path=..;C:\cygwin64\bin;C:\Git\bin
in order to read cygwin's library first.

In such case, you may get issues with git. So test it after your have changed the Path.

If it happens to get problems with Git, it's necessary to point git's executables manually or using a script to set the local envvar during git's execution context.

Another solution could be adopting one or another.

>ENV

Windows 7-10

Saturday, August 8, 2015

apache2 vs. php5 (lump) - install failure on debian 7 (wheezy)


If you get one of the messages below, probably you need to upgrade your installation.
Check the commands at the end.

-------------------------------------------------------------------------------------------------------
>failure messages

apache2: Syntax error on line 140 of /etc/apache2/apache2.conf: 
Syntax error on line 1 of /etc/apache2/mods-enabled/php5.load: Cannot load /usr/lib/apache2/modules/libphp5.so into server: /usr/lib/x86_64-linux-gnu/libk5crypto.so.3: symbol krb5int_buf_len, version krb5support_0_MIT not defined in file libkrb5support.so.0 with link time reference

--- --
[FAIL] Starting web server: apache2 failed!
[warn] The apache2 configtest failed. ... (warning).
Output of config test was:
apache2: Syntax error on line 140 of /etc/apache2/apache2.conf: Could not open configuration file /etc/apache2/mods-enabled/php5.load: No such file or directory

-- --
Action 'configtest' failed.
The Apache error log may have more information.


-------------------------------------------------------------------------------------------------------
>commands

If you have MySQL already installed, you just need to install apache, php and phpmydmin.
If not, install MySQL first.

To install apache and php5, run the following commands as root (su or sudo).

apt-get ugrade
apt-get update
apt-get install apache2
apt-get install php5
apt-get install libapache-mod-php5


Sunday, May 24, 2015

maven version conflict


>PROBLEM
[WARNING] Rule 0: org.apache.maven.plugins.enforcer.RequireMavenVersion failed with message:
Detected Maven Version: 3.0.4 is not in the allowed range 3.1.1.


>SOLUTION
Using an old version incompatible with the version required.
  M2_HOME=D:\portables_d\apache-maven-3.0.4

Switch the M2_HOME envvar to the new maven version:
  M2_HOME=D:\portables_d\apache-maven-3.1.1





Sunday, March 15, 2015

Apache or Node? Which one is best?


My Thoughts and Conclusions About Two Different Ways of Doing Something Concerning Server's Approaches Using Node.js vs. Apache Comparison Example

When the major problem is the number of persons to travel, matter less if the car has front-wheel drive or rear-wheel drive.
Number of seats care most.

Being straight, more requests demand more resources and increase possible concurrencies issues.
It matters less how the process requests are handled, but how the project's resources in general may scale with high availability.

Putting aside that, if you have light CPU processing per request, Node.js will be lighter approach, otherwise, if it is not possible to guarantee that, threads will fit better, so Apache is a better choice.

See more at:

http://www.quora.com/What-are-the-pros-and-cons-of-Node-js-versus-Apache-web-server

http://voidcanvas.com/describing-node-js/

http://www.toptal.com/nodejs/why-the-hell-would-i-use-node-js

https://thomashunter.name/blog/php-vs-nodejs/

Sunday, December 28, 2014

git svn clone command fails on windows


>PROBLEM

The following command is executed:

    git svn clone file://D:/work/dev/java/lab/junit

It returns:   

    C:\Program Files (x86)\Git\bin\perl.exe: *** unable to remap C:\Program Files (x86)\Git\bin\libsvn_wc-1-0.dll to same address as parent -- 0x6F1C0000






 The same problem happened on Git's bash and Cygwin console.



>SOLUTION

I updated the cygwin´s perl and git libraries to the last one by this time, since It was not possible to update Git, because the last version was already installed (Git-1.9.5-preview20141217.exe),
After the update, a new attempt using Cygwin succeeded.




The clue came from:

https://code.google.com/p/conemu-maximus5/wiki/AppHelp


Sunday, September 14, 2014

Windows Update failure: WindowsUpdate_000000FF WindowsUpdate_dt000

Update failure returning message:
   
    "WindowsUpdate_000000FF" "WindowsUpdate_dt000"
   
I got this message during of of the procedures of windows update when trying to install Microsoft.NET Framework 4.5.1 and 4.

>SOLUTION

Manual installation of each update that failed.
First, to download, identify the hotfix number shown on "windows update".
Usually it is a number like this: KB2894854.
Find and download by this number. Ex.:
search for:
  download KB2894854
or
  download microsoft KB2894854

After download, run the executables to install the hotfix.


>INSTALLED PACKAGES

For example, in my case I had to download and install each hotfix that windows' update refused to.
This is the hotfix list and the respectives URLs:
- Microsoft .NET Framework 4.5.1 = http://www.microsoft.com/pt-br/download/details.aspx?id=40779
http://www.microsoft.com/pt-br/download/details.aspx?id=41378
- KB970892 = http://www.microsoft.com/en-us/download/confirmation.aspx?id=42779
- KB2894854 = http://www.microsoft.com/pt-br/download/details.aspx?id=41378
- KB2898869 = http://www.microsoft.com/pt-br/download/details.aspx?id=41903
- KB2901126 = http://www.google.com.br/url?url=http://www.microsoft.com/pt-br/download/details.aspx%3Fid%3D41918&rct=j&q=&esrc=s&sa=U&ei=utYVVPnoMeOmigLK-4HoCw&ved=0CBQQFjAA&usg=AFQjCNFX685_-qZvmx3_HKq84SxCb_SaWA
- KB2972216 = http://www.microsoft.com/en-ie/download/details.aspx?id=44181





Sunday, June 8, 2014

'Maven Dependencies' references non existing library ... com\sun\tools\1.6\tools-1.6.jar'


>PROBLEM

  'Maven Dependencies' references non existing library ... com\sun\tools\1.6\tools-1.6.jar'    auth        Build path    Build Path Problem
Full Compilation Error Message:

  The container 'Maven Dependencies' references non existing library
    'D:\work\repolib\java\mvn_repo\com\sun\tools\1.6\tools-1.6.jar'    auth        Build path    Build Path Problem


>SOLUTION

This error is caused by this dependency:

        <dependency>
            <groupId>org.jboss.as</groupId>
            <artifactId>jboss-as-jpa-hibernate3</artifactId>
            <version>7.2.0.Final</version>
        </dependency>

It was substituted by another.

>ENV
eclipse, maven, java, hibernate


>DETAILED APPROACH

A build path problem usually indicates that a dependency is missing.
So, this kind of problem may have many reasons.
First check your development tool configuration.
If Eclipse, go to preferences, Build Path. Check also Project Facets.
Go to the pom.xml and check the compilation configuration version.
It must be the same of Eclipse's configuration.

Example:

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
        </plugins>
    </build>

If Eclipse configuration is using version java 7, switch to 1.7 where it is 1.6.


After all this check up, if the problem remains, do the following:

1. Remove all dependencies from your pom.xml file and let it as follow:

    <dependencies>
    </dependencies>

2. Then insert the dependencies again using small groups (for instance 3 dependencies) until one of them triggers the target error.
Then isolate the dependency that causes the problem removing and test one by one in that group until the error disappears.


Saturday, May 31, 2014

Eclipse java project and the "The selection did not contain any resources that can run on a server" warn.



>PROBLEM

When you try to run the project on the server using "Run on Server" (SA+X+R) option, eclipse returns the following message:
  The selection did not contain any resources that can run on a server.


>SOLUTION

On the navigation panel, click over the project for pop-up menu, properties, Project Facets, check:
- Dynamic Web Module
- Java




>ENV
eclipse, maven java project.


Wednesday, May 28, 2014

Spring-MVC - WARN [CglibAopProxy] Unable to proxy method


ENVIRONMENT

Spring-MVC using Spring Security.


PROBLEM

Suddenlly, the compiler begins warning:

WARN [CglibAopProxy] (CglibAopProxy.java:...) - Unable to proxy method [public final void org.springframework.web.servlet.mvc.AbstractController.setSynchronizeOnSession(boolean)] because it is final: All calls to this method via a proxy will be routed directly to the proxy.

SOLUTION

First it was commented the annotation:
  @PreAuthorize("permitAll")
on the Controller class.

Recompiled and the warns disappeared.
So, the problem comes from the procedure triggered by this annotation.

To fix, it was taken off the following attribute from "security:global-method-security" element:
  proxy-target-class="true"
on the spring-security.xml configuration.



- spring-security.xml configuration setup:

BEFORE:
    <security:global-method-security pre-post-annotations="enabled" secured-annotations="enabled"
        jsr250-annotations="enabled" proxy-target-class="true">
    </security:global-method-security>
AFTER:
    <security:global-method-security pre-post-annotations="enabled" secured-annotations="enabled"
        jsr250-annotations="enabled" >
    </security:global-method-security>

COMMENT

The proxy-target-class attribute enabled (proxy-target-class="true") forces the use of CGLIB proxying (for example, to proxy every method defined for the target object, not just those implemented by its interfaces).
However, there are some issues to consider, like the final methods that cannot be advised, as they cannot be overriden.
See more at Spring AOP documentation .



FULL WARN MESSAGES:
  2014-05-28 14:18:26,148  WARN [CglibAopProxy] (CglibAopProxy.java:263) - Unable to proxy method [public final void org.springframework.web.servlet.mvc.AbstractController.setSynchronizeOnSession(boolean)] because it is final: All calls to this method via a proxy will be routed directly to the proxy.
  2014-05-28 14:18:26,150  WARN [CglibAopProxy] (CglibAopProxy.java:263) - Unable to proxy method [public final boolean org.springframework.web.servlet.mvc.AbstractController.isSynchronizeOnSession()] because it is final: All calls to this method via a proxy will be routed directly to the proxy.
  2014-05-28 14:18:26,150  WARN [CglibAopProxy] (CglibAopProxy.java:263) - Unable to proxy method [public final void org.springframework.web.servlet.support.WebContentGenerator.setSupportedMethods(java.lang.String[])] because it is final: All calls to this method via a proxy will be routed directly to the proxy.
  2014-05-28 14:18:26,151  WARN [CglibAopProxy] (CglibAopProxy.java:263) - Unable to proxy method [public final java.lang.String[] org.springframework.web.servlet.support.WebContentGenerator.getSupportedMethods()] because it is final: All calls to this method via a proxy will be routed directly to the proxy.
  2014-05-28 14:18:26,151  WARN [CglibAopProxy] (CglibAopProxy.java:263) - Unable to proxy method [public final void org.springframework.web.servlet.support.WebContentGenerator.setRequireSession(boolean)] because it is final: All calls to this method via a proxy will be routed directly to the proxy.
  2014-05-28 14:18:26,152  WARN [CglibAopProxy] (CglibAopProxy.java:263) - Unable to proxy method [public final boolean org.springframework.web.servlet.support.WebContentGenerator.isRequireSession()] because it is final: All calls to this method via a proxy will be routed directly to the proxy.
  2014-05-28 14:18:26,152  WARN [CglibAopProxy] (CglibAopProxy.java:263) - Unable to proxy method [public final void org.springframework.web.servlet.support.WebContentGenerator.setUseExpiresHeader(boolean)] because it is final: All calls to this method via a proxy will be routed directly to the proxy.
  2014-05-28 14:18:26,152  WARN [CglibAopProxy] (CglibAopProxy.java:263) - Unable to proxy method [public final boolean org.springframework.web.servlet.support.WebContentGenerator.isUseExpiresHeader()] because it is final: All calls to this method via a proxy will be routed directly to the proxy.
  2014-05-28 14:18:26,153  WARN [CglibAopProxy] (CglibAopProxy.java:263) - Unable to proxy method [public final void org.springframework.web.servlet.support.WebContentGenerator.setUseCacheControlHeader(boolean)] because it is final: All calls to this method via a proxy will be routed directly to the proxy.
  2014-05-28 14:18:26,153  WARN [CglibAopProxy] (CglibAopProxy.java:263) - Unable to proxy method [public final boolean org.springframework.web.servlet.support.WebContentGenerator.isUseCacheControlHeader()] because it is final: All calls to this method via a proxy will be routed directly to the proxy.
  2014-05-28 14:18:26,153  WARN [CglibAopProxy] (CglibAopProxy.java:263) - Unable to proxy method [public final void org.springframework.web.servlet.support.WebContentGenerator.setUseCacheControlNoStore(boolean)] because it is final: All calls to this method via a proxy will be routed directly to the proxy.
  2014-05-28 14:18:26,154  WARN [CglibAopProxy] (CglibAopProxy.java:263) - Unable to proxy method [public final boolean org.springframework.web.servlet.support.WebContentGenerator.isUseCacheControlNoStore()] because it is final: All calls to this method via a proxy will be routed directly to the proxy.
  2014-05-28 14:18:26,154  WARN [CglibAopProxy] (CglibAopProxy.java:263) - Unable to proxy method [public final void org.springframework.web.servlet.support.WebContentGenerator.setCacheSeconds(int)] because it is final: All calls to this method via a proxy will be routed directly to the proxy.
  2014-05-28 14:18:26,154  WARN [CglibAopProxy] (CglibAopProxy.java:263) - Unable to proxy method [public final int org.springframework.web.servlet.support.WebContentGenerator.getCacheSeconds()] because it is final: All calls to this method via a proxy will be routed directly to the proxy.
  2014-05-28 14:18:26,155  WARN [CglibAopProxy] (CglibAopProxy.java:263) - Unable to proxy method [public final void org.springframework.web.context.support.WebApplicationObjectSupport.setServletContext(javax.servlet.ServletContext)] because it is final: All calls to this method via a proxy will be routed directly to the proxy.
  2014-05-28 14:18:26,155  WARN [CglibAopProxy] (CglibAopProxy.java:263) - Unable to proxy method [public final void org.springframework.context.support.ApplicationObjectSupport.setApplicationContext(org.springframework.context.ApplicationContext) throws org.springframework.beans.BeansException] because it is final: All calls to this method via a proxy will be routed directly to the proxy.
  2014-05-28 14:18:26,155  WARN [CglibAopProxy] (CglibAopProxy.java:263) - Unable to proxy method [public final org.springframework.context.ApplicationContext org.springframework.context.support.ApplicationObjectSupport.getApplicationContext() throws java.lang.IllegalStateException] because it is final: All calls to this method via a proxy will be routed directly to the proxy.



Monday, April 14, 2014

spring "java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet"


Problem
Running the application using eclipse's server you get the following exception:

 spring java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet  

Solution

Check if you have the spring-mvc jar in the project's classpath.
If using maven, you must have something like this in your pom.xml:

<!-- Spring 3 MVC depends on spring-core, spring-beans, spring-context, spring-web -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>

</dependency>

If you respective reference is verified and correct, just remove the project from your server.
Perform a project clean, building everything from scratch.
Deploy the project again.

Sometimes, the eclipse's server may fail requiring a new deploy.




Tuesday, March 4, 2014

Jboss-characters' and URLs strange behavior



>PROBLEM

Jboss-characters' and URLs strange behavior, compromising navigation.



>SOLUTION

Set the proper encoding.
Edit the file:
  $JBOSS_INTALL_DIR/standalone/configuration/standalone.xml

If using UTF-8, insert the following after  </extensions> tag:

    <system-properties>
        <property name="org.apache.catalina.connector.URI_ENCODING" value="UTF-8"/>
        <property name="org.apache.catalina.connector.USE_BODY_ENCODING_FOR_QUERY_STRING" value="true"/>
    </system-properties>



>ENV
JBoss server

Eclipse using AspectJ Plugin



If  you are using Eclipse with aspectJ plugin, you may get this exception below, because it is necessary to convert the project before running it.
See details below.


PROBLEM

Exception thrown:


SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'logAspecto' defined in ServletContext resource
[/WEB-INF/applicationContext.xml]: No matching factory method found: factory method 'aspectOf()'. 

Check that a method with the specified name exists and that it is static.
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:528)


SOLUTION


After AspectJ plugin installation it is necessary to convert the project.
Right click the project > configure > convert to aspect project


 
INTALLING AspectJ plugin in Kepler

To install aspectJ plugin in Eclipse Kepler, go to menu, help, Install new software.
Point to http://download.eclipse.org/tools/ajdt/43/update .
Wait a minute to update, check all then install.


eclipse: java: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder" or Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder

  >PROBLEM Using Eclipse, you try to run a simple logging test using "org.slf4j.Logger" like the sample below: package Test; im...