AccessDeniedException in java - java

I'm developing a security mechanism to my project in java where I use AccessDeniedException to restrict access to users in some methods of project. I work with ws to publish this methods. I use tomcat 7 to deploy my ws. Now when I startup tomcat 7 to deploy my ws this is that show in console of my IDE Eclipse:
GRAVE: WSSERVLET11: failed to parse runtime descriptor: java.lang.NoClassDefFoundError: java/nio/file/AccessDeniedExceptionjava.lang.NoClassDefFoundError: java/nio/file/AccessDeniedException at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source)
at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.getImplementorClass(DeploymentDescriptorParser.java:545)
at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parseAdapters(DeploymentDescriptorParser.java:223)
at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parse(DeploymentDescriptorParser.java:147)
at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextInitialized(WSServletContextListener.java:108)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4887)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5381)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)Caused by: java.lang.ClassNotFoundException: java.nio.file.AccessDeniedException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
... 16 more
I use jre7 although I have imported jre6 and jre8 to my project too. I have imported java.nio.file.AccessDeniedException class in my code. I don't understand what is happened in this case. Is how if my project not found java.nio.file.AccessDeniedException class. Thanks ahead of time.

Related

Tomcat server won't start in Eclipse when running java class. Caused by: java.lang.NoClassDefFoundError: org/json/JSONException

When trying to run my java class in Eclipse, the Tomcat server won't start. There are several errors about java.lang.NoClassDefFoundError: org/json/JSONException and java.lang.ClassNotFoundException: org.json.JSONException. I have imported org.json.JSONException in my project, and have added org.json.jar in my project build path, as an external jar. Org.json.jar is also included in my CLASSPATH environment variable. Any advice is greatly appreciated.
The console error in Eclipse when attempting to start the server states:
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/URL6]]
at java.util.concurrent.FutureTask.report(Unknown Source)
at java.util.concurrent.FutureTask.get(Unknown Source)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:931)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1412)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1402)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/URL6]]
at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198)
... 6 more
Caused by: java.lang.NoClassDefFoundError: org/json/JSONException
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Unknown Source)
at java.lang.Class.getDeclaredFields(Unknown Source)
at org.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:110)
at org.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:269)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationServletAnnotations(WebAnnotationSet.java:137)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:69)
at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:328)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:779)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:299)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5063)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
... 6 more
Caused by: java.lang.ClassNotFoundException: org.json.JSONException
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1358)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1180)
... 19 more
Project Build Configuration
CLASSPATH
Open the project's Deployment Assembly property page and make sure the jar is set to be deployed as part of the app. The CLASSPATH environment variable doesn't affect Tomcat, and you should stop relying on it in general.
for me, what worked was this...
in the servlet program, I omitted the forward slash "/" in the annotation declaration
#WebServlet("/MyServlet") //correct✔️
public class MyServlet extends HttpServlet{
.
.
.}
#WebServlet("MyServlet") //wrong❌
public class MyServlet extends HttpServlet{
.
.
.}

Resteasy in seam application is not working

I get the following error when running tomcat with seam 2.1.2 (old I know), but
I'm trying to get the rest services working with it:
Apr 18, 2018 7:06:11 PM org.apache.catalina.core.StandardContext
listenerStart SEVERE: Exception sending context initialized event to
listener instance of class [org.jboss.seam.servlet.SeamListener]
java.lang.VerifyError: (class:
org/jboss/seam/resteasy/ResteasyBootstrap_$$_javassist_seam_0, method:
_d27sessionWillPassivate signature: (Ljavax/servlet/http/HttpSessionEvent;)V) Illegal use of nonvirtual
function call at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Unknown Source) at
java.lang.Class.getField0(Unknown Source) at
java.lang.Class.getField(Unknown Source) at
org.jboss.seam.util.ProxyFactory.setField(ProxyFactory.java:363) at
org.jboss.seam.util.ProxyFactory.createClass3(ProxyFactory.java:352)
at
org.jboss.seam.util.ProxyFactory.createClass2(ProxyFactory.java:325)
at
org.jboss.seam.util.ProxyFactory.createClass(ProxyFactory.java:284)
at org.jboss.seam.Component.createProxyFactory(Component.java:2426)
at org.jboss.seam.Component.getProxyFactory(Component.java:1513) at
org.jboss.seam.Component.wrap(Component.java:1504) at
org.jboss.seam.Component.instantiateJavaBean(Component.java:1442) at
org.jboss.seam.Component.instantiate(Component.java:1359) at
org.jboss.seam.Component.newInstance(Component.java:2122) at
org.jboss.seam.contexts.Contexts.startup(Contexts.java:304) at
org.jboss.seam.contexts.Contexts.startup(Contexts.java:278) at
org.jboss.seam.contexts.ServletLifecycle.endInitialization(ServletLifecycle.java:113)
at org.jboss.seam.init.Initialization.init(Initialization.java:740)
at
org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:36)
at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4637)
at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5099)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1425)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1415)
at java.util.concurrent.FutureTask.run(Unknown Source) at
org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(Unknown
Source) at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:941)
at
org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:839)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1425)
at
org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1415)
at java.util.concurrent.FutureTask.run(Unknown Source)
When I remove the resteasy jars I get the following error:
Caused by: java.lang.NoClassDefFoundError:
org/jboss/resteasy/specimpl/UriInfoImpl at
java.lang.Class.getDeclaredMethods0(Native Method) at
java.lang.Class.privateGetDeclaredMethods(Unknown Source) at
java.lang.Class.getDeclaredMethods(Unknown Source) at
org.jboss.seam.Component.initMembers(Component.java:550) at
org.jboss.seam.Component.(Component.java:244) at
org.jboss.seam.Component.(Component.java:205) at
org.jboss.seam.init.Initialization.addComponent(Initialization.java:1186)
So I guess I need to know the exact dependencies ?
This is the jars list:
I've solved the problem by downgrade from tomcat 9 to tomcat 7 and by using the original jars came with the seam package.

Exception starting filter ApplicationInsightsWebFilter

I followed below article to set up appinsights to java dynamic web project:
Quickstart: Get started with Application Insights in a Java web project
However I get the below mentioned error. Error Stack trace:
Jan 05, 2017 5:40:07 PM org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter ApplicationInsightsWebFilter
java.lang.ClassNotFoundException: com.microsoft.applicationinsights.web.internal.WebRequestTrackingFilter
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:532)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:514)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:133)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:257)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:383)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:104)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4650)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5306)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
As a summary, seems that you had resolved the issue which might be caused by not automatically loading the added jar files on Tomcat via Eclipse. The solution is that as below.
Move to the Properties > Deployment Assembly of the current project, and check whether the dependencies exists there as Build Path entries or Archives.
Select the current project, and click Project > Clean at the menu bar, then restart the server.

Developing a web App in Spring Tool Suit

I have developed a dynamic web application in spring tool suit using Spring MVC architecture. I added the required jars to develop the application and even installed the tomcat 7.0 to make the application run on server. However, when I try to run the application on server I am unable to run the Application. I am unable to understand what may be the reason. I am also getting an error that the dispatcher servlet is not found.
java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:529)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:511)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:139)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1148)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5210)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5493)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
The jars are:
commons-logging-api-1.1.1
jstl-1.1.2 (1)
org.springframework.web.servlet.view.xdocreport-1.0.4
org.springframework.web.servlet-3.0.5.RELEASE
servlet-api-2.5
spring-asm-3.0.7.RELEASE
spring-beans-4.0.6.RELEASE
spring-context-4.0.6.RELEASE
spring-core-4.0.6.RELEASE
spring-expression-4.0.6.RELEASE
spring-web-4.0.6.RELEASE
spring-webmvc-3.1.1.RELEASE

Exception starting filter MPIJSP Filter

I am trying to set up a local tomcat (Apache Tomcat/7.0.47) server from eclipse.
I get my project from svn.
I set up the server and add the project into it.
Now I keep getting:
SEVERE: Exception starting filter MPIJSPFilter
java.lang.ClassNotFoundException: moreservlets.filters.MPIJSPFilter
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:532)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:514)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:142)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:107)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4775)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5452)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
and can not run the project or even when I run: localhost:8080/
I get: HTTP Status 404 - /
Any suggestions on how to solve this?

Categories

Resources