0
votes

[2/24/20 12:20:41:747 EAT] 00000075 SystemErr R Caused by: com.ibm.ws.webcontainer.exception.WebAppNotLoadedException: Failed to load webapp: Failed to load webapp: Unable to start web server&#59; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webSecurityConfig': Unsatisfied dependency expressed through field 'userDetailsService'&#59; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userDetailsServiceImpl': Unsatisfied dependency expressed through field 'userRepo'&#59; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepo': Post-processing of merged bean definition failed&#59; nested exception is java.lang.NoSuchMethodError: javax/persistence/PersistenceContext.synchronization()Ljavax/persistence/SynchronizationType&#59; (loaded from file:/C:/Program Files (x86)/IBM/WebSphere/AppServer/plugins/javax.j2ee.persistence.jar by org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@cdc1acc9) called from class org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement (loaded from file:/C:/Program%20Files%20(x86)/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/myserverNode01Cell/mcomm-0_0_1-SNAPSHOT_war.ear/mcomm-0.0.1-SNAPSHOT.war/WEB-INF/lib/spring-orm-5.2.1.RELEASE.jar by com.ibm.ws.classloader.CompoundClassLoader@e9512a60[war:mcomm-0_0_1-SNAPSHOT_war/mcomm-0.0.1-SNAPSHOT.war]

My Repository

public interface UserRepo extends JpaRepository{

User findByUsername(String username);

List<User> findByApprovedAndDeletedAndDeleteApproved(Boolean approved,Boolean deleted,Boolean deleteapproved);

List<User> findByDeletedAndDeleteApproved(Boolean deleted,Boolean deleteapproved);

@Procedure
public void ADD_PASSWORD_HISTORY(Long id, String passwd);
@Procedure
public int SP_CHECK_PASS_REUSE(Long usrid, String passwd);
@Procedure
public void UN_EDIT_PASSWORD(Long id);

}

My Service

@Service public class UserDetailsServiceImpl implements UserDetailsService {

@Autowired
private UserRepo userRepo=null;

public UserDetails loadUserByUsername(String username){     
    User user = userRepo.findByUsername(username);
    if(user==null){
        throw new UsernameNotFoundException("Username not found");
    }

    return new org.springframework.security.core.userdetails.User(user.getUsername(),user.getPassword(),
            true,true,true,true,getGrantedAuthorities(user));
}

private List<GrantedAuthority> getGrantedAuthorities(User user){
    List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
    for(GrantedAuthority roles : user.getAuthorities()){    
        authorities.add(new SimpleGrantedAuthority(((Role) roles).getName()));
    }
    return authorities;
}

}

1
Hi, welcome to SO. Please read: stackoverflow.com/help/how-to-ask. You should add some of your code that causes this error to happen so that others could review it and help you.Juho Rutila

1 Answers

0
votes

It looks like the version of spring-orm you're deploying is dependent on a different JPA spec level than what is included in WebSphere - the NoSuchMethodError is a bit difficult to read with the encoding issues, but I am pretty sure it says this:

javax/persistence/PersistenceContext loaded from C:/Program Files (x86)/IBM/WebSphere/AppServer/plugins/javax.j2ee.persistence.jar

called from

org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement loaded from C:/Program Files (x86)/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/myserverNode01Cell/mcomm-0_0_1-SNAPSHOT_war.ear/mcomm-0.0.1-SNAPSHOT.war/WEB-INF/lib/spring-orm-5.2.1.RELEASE.jar

The version of PersistenceContext included in WebSphere does not contain the synchronization() method, or at least not with the same arguments and/or return type. That likely means that you'll need to bring your own JPA API (and, then, your own compatible implementation) and make it visible to the applications in preference to the server's implementation. The safest way to do that is to package the JPA jars in a shared library, select the "use an isolated class loader" setting on the library, and associate the library with your WAR module. Note that isolated shared libraries can't "see" stuff in the application they're associated with, so you'll need to make sure the classes in the library have all their immediate dependents.