Skip to main content

simple embedded security fails: Login failed: Unable to locate a login configuration

Please note these forums are being decommissioned and use the new and improved forums at
No replies
Joined: 2012-02-02

Hi Folks. I hope you can help. I'm creating unit tests for our application, and I'm stuck. For testing I have a simple HelloWebServlet that I'm protecting via annotations:

@WebServlet(urlPatterns = {"/hello"})
@ServletSecurity(@HttpConstraint(rolesAllowed = {"user"}))

I'm starting the server the way that's always worked OK (see [1]) and creating users (see [2]) seems to be OK because output from CommandRunner calls to list-file-users and list-file-groups are correct, but I'm getting this error when I try to connect using the username and password:

WARNING: WEB9102: Web Login Failed: Login failed: Unable to locate a login configuration

The calling code uses the Jersey client API:

public void testPingServletLoggedIn() {
Client client = Client.create();
client.addFilter(new HTTPBasicAuthFilter(GlassFishServerHelper.USERNAME, "xx"));
WebResource webResource = client.resource(GlassFishServerHelper.getBaseUri() + "/hello");
ClientResponse clientResponse = webResource
.get(ClientResponse.class); // @GET
assertEquals(ClientResponse.Status.OK, clientResponse.getClientResponseStatus());

(Note: I tried to set but that call failed with: PlainTextActionReporterFAILURENo configuration found for . Drat!)

I've tried this against both glassfish-embedded-all-3.1.2.jar (our production version) and glassfish-embedded-all-3.2-b06.jar with the same results. What do you think would solve this? I'd be really grateful for your help! I've struggled and succeeded way too many times with GFE to stop now.

Thanks in advance,


==== [1] server startup (excerpt) ====

public static void startServer() {
GlassFishProperties gfProps = new GlassFishProperties();
gfProps.setPort("http-listener", PORT);
GLASSFISH = GlassFishRuntime.bootstrap().newGlassFish(gfProps);


ScatteredArchive archive = new ScatteredArchive(WEB_APP_NAME, ScatteredArchive.Type.WAR);
File classesDir = new File("out/production/simple-security-servlet-test");
APP_NAME = DEPLOYER.deploy(archive.toURI());

private static void enableDefaultPrincipleToRoleMapping() throws GlassFishException {
CommandRunner cr = GLASSFISH.getCommandRunner();
CommandResult result ="set",

==== [2] user creation (excerpt) ====

private static void createUsersAndGroups() throws GlassFishException {
CommandRunner commandRunner = GLASSFISH.getCommandRunner();
File passwordFile = new File("password-file.txt");
CommandResult result ="create-file-user",
"--passwordfile", passwordFile.getAbsolutePath(),
"--groups", "user",

The password file contains:


==== EOF ====

gfe-servlet-security-test-src-0529.zip4.93 KB