File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Security and the fly likes Hello-world applet crashes for a basic-authenticated user Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » Security
Bookmark "Hello-world applet crashes for a basic-authenticated user" Watch "Hello-world applet crashes for a basic-authenticated user" New topic
Author

Hello-world applet crashes for a basic-authenticated user

Johnny Maine
Greenhorn

Joined: Nov 21, 2011
Posts: 1
Hi everybody,

I already posted this question in the Spring forum.
I am stuck with a problem.
A simple Hello-world applet crashes for a basic-authenticated user, but it works fine without authentication.
Please help, where is the error and what are the easiest corrections to make it working?
Thanks a lot in advance.

Johnny Maine.

Here is a detailed description.

Environment:
64-bit Windows 7;
Java - 1.6.0_29;
Eclipse - Indigo Release, Build id: 20110615-0604;
Tomcat - v7.0.20;
Spring - 3.1.0;
Firefox - 10.0a1 (or 3.6.3);
User authentication - basic.


Code:

-------------
home.jsp

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page session="true" %>
<html>
<head>
<title>Home</title>
</head>
<body>
<h1>
Hello world!
</h1>
<P> The time on the server is ${serverTime}. </P>
<a href="<c:out value="resources/tst-appl.jsp"/>">appl-test</a>
</body>
</html>

------------
HomeController.java

package com.myfirm.mysystem;
import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
public class HomeController {
private static final Logger logger = LoggerFactory.getLogger(HomeController.class);
@RequestMapping(value = "/", method = RequestMethod.GET)
public String home(Locale locale, Model model) {
logger.info("Welcome home! the client locale is "+ locale.toString());
Date date = new Date();
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
String formattedDate = dateFormat.format(date);
model.addAttribute("serverTime", formattedDate );
return "home";
}
}

------------
tst-appl.jsp

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page session="true" %>
<html>
<head>
<title>TST--APPLET !!!</title>
</head>
<body>
<h1>
<jsp:plugin type="applet" code="com.myfirm.mysystem.MyAppl.class" codebase="." width="800" height="500" archive="MyAppl.jar">
<jsp:fallback>
<p>Unable to load bean</p>
</jsp:fallback>
</jsp:plugin>
</h1>
</body>
</html>

------------
MyAppl.java

package com.myfirm.mysystem;
import java.awt.*;
import java.applet.*;
public class MyAppl extends Applet {
@Override
public void init() {
setBackground(Color.WHITE);
}
public void paint(Graphics g) {
g.drawString("Hello World!!!", 10, 10);
}
}

------------
security-context.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<security:http auto-config='true' use-expressions="true">
<security:intercept-url pattern="/**" access="hasRole('ROLE_USER')"/>
</security:http>
<security:authentication-manager>
<security:authentication-provider>
<security:user-service>
<security:user name="jimi" password="jimispassword" authorities="ROLE_USER, ROLE_ADMIN" />
<security:user name="bob" password="bobspassword" authorities="ROLE_USER" />
</security:user-service>
</security:authentication-provider>
</security:authentication-manager>
</beans>

----------------
Project structure:

<src>
____<main>
________<java>
____________<com>
________________<myfirm>
____________________<mysystem>
________________________HomeController.java
________<resources>
____________<META-INF>
____________log4j.dtd
____________log4j.xml
________<webapp>
____________<resources>
________________MyAppl.jar
________________tst-appl.jsp
____________<WEB-INF>
________________<classes>
________________<lib>
________________<spring>
____________________<appServlet>
________________________servlet-context.xml
____________________security-context.xml
________________<views>
____________________home.jsp


-----------------------
Error:

Java Plug-in 1.6.0_29
Using JRE version 1.6.0_29-b11 Java HotSpot(TM) 64-Bit Server VM
User home directory = C:\Users\me
----------------------------------------------------
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
o: trigger logging
q: hide console
r: reload policy configuration
s: dump system and deployment properties
t: dump thread list
v: dump thread stack
x: clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------
security: Accessing keys and certificate in Mozilla user profile: null
basic: Added progress listener: sun.plugin.util.GrayBoxPainter$GrayBoxProgressListener@606f8b2b
basic: Plugin2ClassLoader.addURL parent called for http://localhost:8080/spring-mvc/resources/MyAppl.jar
network: Cache entry not found [url: http://localhost:8080/spring-mvc/resources/com/myfirm/mysystem/MyAppl.class, version: null]
network: Connecting http://localhost:8080/spring-mvc/resources/com/myfirm/mysystem/MyAppl.class with proxy=DIRECT
network: Connecting http://localhost:8080/ with proxy=DIRECT
network: Server http://localhost:8080/spring-mvc/resources/com/myfirm/mysystem/MyAppl.class requesting to set-cookie with "JSESSIONID=99A8F94DB72AA4C1F49EF71070468B58; Path=/spring-mvc/; HttpOnly"
network: Cache entry not found [url: http://localhost:8080/spring-mvc/spring_security_login;jsessionid=99A8F94DB72AA4C1F49EF71070468B58, version: null]
network: Connecting http://localhost:8080/spring-mvc/spring_security_login;jsessionid=99A8F94DB72AA4C1F49EF71070468B58 with proxy=DIRECT
network: Connecting http://localhost:8080/ with proxy=DIRECT
basic: error: Incompatible magic value 1013478509 in class file com/myfirm/mysystem/MyAppl.
java.lang.ClassFormatError: Incompatible magic value 1013478509 in class file com/myfirm/mysystem/MyAppl
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception: java.lang.ClassFormatError: Incompatible magic value 1013478509 in class file com/myfirm/mysystem/MyAppl
Ignored exception: java.lang.ClassFormatError: Incompatible magic value 1013478509 in class file com/myfirm/mysystem/MyAppl


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hello-world applet crashes for a basic-authenticated user
 
Similar Threads
No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional
Error starting spring application
[Spring Security] No bean named 'springSecurityFilterChain' is defined
nullpointer with @Autowired AuthenticationManager
spring security 3.1 login not working.