• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

AccessControlException when accessing Bean in JBOSS

 
Ranch Hand
Posts: 247
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have written a ClientServlet prgm which calls the methods of Entity bean...And deployed the WAR file in JBOSS...

When i hit the application, i get the following error,


java.security.AccessControlException: access denied (java.io.FilePermission sqlexception-service.xml)


Please suggest in resolving this issue...
 
Ram Narayan.M
Ranch Hand
Posts: 247
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please reply...
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please try to post more details regarding your exception and the code snippets from your code if possible so that it would be easy to understand the details of the problem and reply.
 
Ram Narayan.M
Ranch Hand
Posts: 247
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have deployed a WAR file which contains Servlet accessing the entity bean....

This is the exception i get...


java.security.AccessControlException: access denied (java.io.FilePermission G:\j
boss-5.1.0.GA\server\default\deploy\sqlexception-service.xml read)
at java.security.AccessControlContext.checkPermission(AccessControlConte
xt.java:323)
at java.security.AccessController.checkPermission(AccessController.java:
546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.SecurityManager.checkRead(SecurityManager.java:871)
at java.io.File.exists(File.java:731)
at org.jboss.virtual.plugins.context.file.FileHandler.exists(FileHandler
.java:140)
at org.jboss.virtual.VirtualFile.exists(VirtualFile.java:182)
at org.jboss.system.server.profileservice.repository.HotDeploymentReposi
tory.getModifiedDeployments(HotDeploymentRepository.java:108)
at org.jboss.system.server.profile.repository.AbstractProfile.getModifie
dDeployments(AbstractProfile.java:128)
at org.jboss.system.server.profileservice.hotdeploy.HDScanner.scan(HDSca
nner.java:336)
at org.jboss.system.server.profileservice.hotdeploy.HDScanner.run(HDScan
ner.java:255)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:44
1)
at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java
:317)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.
access$101(ScheduledThreadPoolExecutor.java:98)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.
runPeriodic(ScheduledThreadPoolExecutor.java:181)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.
run(ScheduledThreadPoolExecutor.java:205)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
utor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:908)
at java.lang.Thread.run(Thread.java:619)
 
Ram Narayan.M
Ranch Hand
Posts: 247
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
import javax.naming.InitialContext;
import javax.naming.Context;
import javax.naming.NamingException;
import java.util.Properties;
import ejb.entity.*;
import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
import java.rmi.RMISecurityManager;

public class Client extends HttpServlet {
public void doGet( HttpServletRequest request, HttpServletResponse response )
{
PrintWriter out = null;
try
{
if (System.getSecurityManager() == null) {
System.setSecurityManager(new RMISecurityManager());
}

out = response.getWriter();
Context jndiContext = getInitialContext();
Object obj=jndiContext.lookup("userHome");
UserHome userObj= (UserHome)
javax.rmi.PortableRemoteObject.narrow(obj,UserHome.class);



UserRemote usr =userObj.findByPrimaryKey("Ram");

out.println("Phone :"+ usr.getPhone());

}
catch( Exception e )
{
out.println(e);
}
}
public static Context getInitialContext()
throws javax.naming.NamingException {
Properties p =new Properties();
p.setProperty( "java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory" );
p.setProperty( "java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces" );
p.setProperty( "java.naming.provider.url", "localhost:1099" );
return new javax.naming.InitialContext(p);
}
}




This is the Client Servlet accessing the entity bean.... Entity bean has been deployed and working fine...
 
Ram Narayan.M
Ranch Hand
Posts: 247
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please Reply... I am unable to fix this issue...
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First, please use the code tags - they make it easier to read source code.

java.security.AccessControlException: access denied (java.io.FilePermission G:\j
boss-5.1.0.GA\server\default\deploy\sqlexception-service.xml read)


Have you checked that the file mentioned exists? Have you checked the security settings for that file? (What exact version and variant of Windows are you using? Example: XP Professional) This error means that the account used to run JBoss AS does not have sufficient permission to open and read that file (if it exists).
 
Ram Narayan.M
Ranch Hand
Posts: 247
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That file exists in deploy folder of JBOSS itself... Its got RW Permission... I am using Windows 7... Is this exception related to OS I use?
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

at java.security.AccessControlContext.checkPermission(AccessControlConte
xt.java:323)
at java.security.AccessController.checkPermission(AccessController.java:
546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.SecurityManager.checkRead(SecurityManager.java:871)



Are you running JBoss AS under a security manager?
 
Ram Narayan.M
Ranch Hand
Posts: 247
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes... Running under RMISecurityManager
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To be sure, how exactly are you doing that? And what policy file are you using for the security manager? What are it's contents?
 
Ram Narayan.M
Ranch Hand
Posts: 247
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In ClientServlet Program i have included this code snippet since i got an exception saying "No SecurityManager found unable to find the EJBObject"...




And i am not using any security policy files...

Still now where i am missing out the config...
 
Ram Narayan.M
Ranch Hand
Posts: 247
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please Reply... I am unable to identify the root cause... please give suggestions it will be very useful for me as well as those who get this error also
 
Ram Narayan.M
Ranch Hand
Posts: 247
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please give me a suggestion for this...
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ram Narayan.M wrote:In ClientServlet Program i have included this code snippet since i got an exception saying "No SecurityManager found unable to find the EJBObject"...






Don't do that. Remove that and whatever exception you get after removing that, post that entire exception stacktrace here.
 
Peter Johnson
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you using EJB 2.1 or 3? If 2.1, why not 3? I very strongly recommend using 3 for any new apps. It's been ages since I did anything with 2.1.

How simple is your EJB? Does it do anything with a database? If it does, then t think that the issue is that you are attempting to do too much at one time (this opinion is based on your other post that says you are new to JBoss AS). I recommend starting off with a simple "hello" EJB and a simple servlet that calls it. You could change your existing EJB to not do any persistence and return a hard-coded string for the getPhone() method. Once you have that working correctly, you can add in more and more of your existing code, which will hopefully narrow down the problem.

I have never had to provide an RMI security manager for a servlet accessing an EJB. I have seen RMI security-related errors from stand-alone clients, but those issues were always solved by providing the necessary client JAR files in the client's classpath.

How are you starting the app server?
 
Ram Narayan.M
Ranch Hand
Posts: 247
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi..... Its perfectly working now... What the mistake i have done is i separately deployed war file and jar file (contains EJB Comp) . So it was not working since no link between these two Components.

When i deployed as an EAR file linking together, i got it working... Really nice working in JBOSS... I learn something core things from JBOSS... Most configs has to be done manually which gives a very good scope of learning behind the screen concepts...
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic