I'm trying to make a REST web service.
My project looks like :
The traceback is :
8 déc. 2011 18:31:36 org.apache.catalina.core.AprLifecycleListener init
INFO: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\MyEclipse\Common\binary\com.sun.java.jdk.win32.x86_1.6.0.013\bin;C:\Program Files\MyEclipse\Common\plugins\com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201109141806\tomcat\bin
8 déc. 2011 18:31:36 org.apache.coyote.http11.Http11Protocol init
INFO: Initialisation de Coyote HTTP/1.1 sur http-8080
8 déc. 2011 18:31:36 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 394 ms
8 déc. 2011 18:31:37 org.apache.catalina.core.StandardService start
INFO: Démarrage du service Catalina
8 déc. 2011 18:31:37 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.13
8 déc. 2011 18:31:37 org.apache.catalina.startup.HostConfig deployWAR
INFO: Déploiement de l'archive Test-0.0.1-SNAPSHOT.war de l'application web
8 déc. 2011 18:31:37 org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(C:\Documents and Settings\Naya\Workspaces\MyEclipse 10\.metadata\.me_tcat\webapps\Test-0.0.1-SNAPSHOT\WEB-INF\lib\javax.servlet-3.0.1.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
8 déc. 2011 18:31:37 org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(C:\Documents and Settings\Naya\Workspaces\MyEclipse 10\.metadata\.me_tcat\webapps\Test-0.0.1-SNAPSHOT\WEB-INF\lib\servlet-api-2.5.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
8 déc. 2011 18:31:38 org.apache.catalina.core.ApplicationContext log
INFO: La servlet Test JAX-RS REST Servlet est marqué comme indisponible
8 déc. 2011 18:31:38 org.apache.catalina.core.ApplicationContext log
GRAVE: Error loading WebappClassLoader
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader#19e8329
com.sun.jersey.spi.container.servlet.ServletContainer
java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1083)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4042)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4348)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:825)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:714)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:490)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
My web.xml :
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<display-name></display-name>
<servlet>
<display-name>Test JAX-RS REST Servlet</display-name>
<servlet-name>Test JAX-RS REST Servlet</servlet-name>
<servlet-class>
com.sun.jersey.spi.container.servlet.ServletContainer
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Test JAX-RS REST Servlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
Can anyone help me ?
Solution:
Only add the dependency in pom.xml:
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
<version>1.13</version>
</dependency>
Now your application will have the class com.sun.jersey.spi.container.servlet.ServletContainer
ps: Remember to check if the libraries are being sent to the tomcat deploy.
To check:
Right-click on your project -> Properties -> Deployment Assembler
and make sure the Source tab contains Maven Dependecies.
Otherwise:
Click on button Add -> Java Build Path -> Maven Dependecies -> Finish.
Ready whenever you run the application all the libs will be imported in the deploy.
ps: Where the Maven project is updated, you must remake these steps.
I have encountered the same issue. I was using Version 1.12.
I could not find the class com.sun.jersey.spi.container.servlet.ServletContainer in the "jersey-server-1.12.jar" or "jersey-core-1.12.jar" as suggested in some other forums.
You can easily check this in Eclipse, when you add it to the Build Path and notice that you do not have that class in the above mentioned jar files.
I searched around and found the following:
It looks like the class com.sun.jersey.spi.container.servlet.ServletContainer is in a different jar file ("jersey-servlet-1.12.jar").
I did not find any documentation about this. However having this file in my WEB-INF/lib resolved this issue.
Hope this helps.
If you're working with Maven then the possible issue might be that your jars don't get deployed to your Tomcat.
So, you have your Maven Dependencies in the Java Build Path (Project > Properties > Build path), but when running the project on your Tomcat from Eclipse Maven Dependencies don't get deployed to TOmcat. To solve this you have to: right click > properties and select "Deployment Assembly". And add Java Build Path Entries. This way you're telling the WTP plugin (the one running Tomcat within Eclipse) that it should also copy the Maven's jars
In Jersey 2.0, the servlet container implementation changed. You need to use org.glassfish.jersey.servlet.ServletContainer instead of the old com.sun.jersey.spi.container.servlet.ServletContainer
The class is in
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>2.0-m11</version>
</dependency>
You can create a skeletal project using:
mvn archetype:generate -DarchetypeArtifactId=jersey-quickstart-webapp -DarchetypeGroupId=org.glassfish.jersey.archetypes -
DinteractiveMode=false -DgroupId=com.example -DartifactId=simple-service -Dpackage=com.example -DarchetypeVersion=2.0-m11
You need to put the Jersey JAR in your WEB-INF/lib directory, whether you are running Tomcat separately or running with Eclipse.
This worked for me.
The class loader can't find the class com.sun.jersey.spi.container.servlet.ServletContainer.
You need to put the Jersey JAR in your WEB-INF/lib directory.
This might help:
http://www.suryasuravarapu.com/2009/02/rest-jersey-configuration-on-tomcat.html
Now I've looked at the image you posted and I see your problem: You're using Eclipse and Maven, but you don't really understand what they're doing.
You have to end up with a WAR file in the Tomcat /webapps directory that has all the 3rd party JARs you need in the WEB-INF/lib directory. If you don't, Tomcat won't find them.
I'd recommend simplifying your problem. Create a WAR file by hand; leave Eclipse and Maven out of it. Once you've got it working, add in the things that are supposed to be making your life easier. You'll understand what they need to do, because you'll have already made it work without them.
luigi7up's post above worked for me. I'm using tomcat 7.0.37, maven 3.1.1, and jersey 1.17.1. I did the right click -> properties -> Deployment Assembly -> Click Add -> Java Build Path Entries -> selected Maven Dependencies. I then clicked ok.
When I first tried this, I noticed that I no longer received the "java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer" error, but I then noticed that I was getting other 'class not found' messages (unfortunately, I didn't document what messages those were). I was using the following jersey dependency:
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-bundle</artifactId>
<version>1.17.1</version>
</dependency>
I took that out and put in the following dependencies:
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.17.1</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>1.17.1</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
<version>1.17.1</version>
</dependency>
Things began to work after that.
Hope this helps someone!
Anjaneya Reddy, as you've pointed out, the class isn't even in the JAR it's supposed to be in. What baffles me, where is it and where in the documentation does it touch on this?!?
With everything being so Maven friendly now, it's difficult to bang out a simple tutorial without needing to depend on it.
I added it to the WEB-INF/lib directory but it did not work until I refreshed the lib folder from Eclipse and then it started working.
You are apparently required missing libraries from your deployment classpath.
Copy the following jars in the WEB-INF/lib directory
asm-3.1.jar
jackson-core-asl-1.9.2.jar
jackson-jaxrs-1.9.2.jar
jackson-mapper-asl-1.9.2.jar
jackson-xc-1.9.2.jar
jersey-client-1.15.jar
jersey-core-1.15.jar
jersey-json-1.15.jar
jersey-server-1.15.jar
jersey-servlet-1.15.jar
jettison-1.1.jar
jsr311-api-1.1.1.jar
from: http://jersey.java.net/nonav/documentation/latest/chapter_deps.html#d4e1687
Deploying an application on a servlet container requires a deployment dependency with that container.
See the Java documentation here on how to configure the servlet container.
Using servlet: com.sun.jersey.spi.container.servlet.ServletContainer requires a dependency on the jersey-servlet module.
Maven developers using servlet: com.sun.jersey.server.impl.container.servlet.ServletAdaptor in a non-EE 5 servlet require a dependency on the persistence-api module in addition.
Non-Maven developers require: persistence-api.jar
The following dependency helps:
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.8</version>
</dependency>
See: http://www.mkyong.com/webservices/jax-rs/classnotfoundexception-com-sun-jersey-spi-container-servlet-servletcontainer/
Related
I am using Oracle's ORDS 20.2 which has jetty/9.4.28.v20200408 embedded, APEX 20.1, Database 18c XE, Google Chrome Version 84.0.4147.135 (Official Build) (64-bit), opera Version:70.0.3728.106
and Windows 7 Ultimate.
In APEX there is a directory that has APEX's static files - CSS and Javascript files and image files. I need to enable gzip for that directory and tell the browser to cache it for at least 12 hours in order to improve performance for APEX development environment and my APEX applications according to Oracle's documentation here, https://docs.oracle.com/en/database/oracle/application-express/19.2/htmig/performance-optimization-tasks.html#GUID-668ED330-AFDC-4A43-AA11-D67FCCA58DA1
I've created a folder named "etc" under the "standalone" folder of my ORDS configuration directory. That's the folder where I should put any Jetty's Xml configuration files. Then created a file called "jetty.xml" with the following contents to implement what is in the Jetty's documentation about sending Cache-Control header,
https://www.eclipse.org/jetty/documentation/current/header-filter.html And
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN"
"http://www.eclipse.org/jetty/configure.dtd">
<filter>
<filter-name>HeaderFilter</filter-name>
<filter-class>org.eclipse.jetty.servlets.HeaderFilter</filter-class>
<init-param>
<param-name>headerConfig</param-name>
<param-value>
"add Cache-Control: max-age=43200"
</param-value>
<init-param>
<param-name>includedPaths</param-name>
<param-value>
"D:\ords\images"
</param-value>
</init-param>
</filter>
But when I run ORDS through a batch file which has
cd D:\Original\Oracle_ORDS_Editions\ords-20.2.0.178.1804
d:
java -jar ords.war standalone
the cmd window opens then vanishes automatically.
I need to know why the code fails and still need to enable gzip for that directory. Thank you.
The HeaderFilter is for use with webapps that are traditionally deployed via a webapp archive (WAR file).
The documented configuration for HeaderFilter is for the war internal WEB-INF/web.xml servlet descriptor that is specific to the webapp being deployed (typically found within a WAR file).
Arbitrarily creating etc directories and jetty.xml files are never a relevant form of configuration for Jetty.
The etc directory and the jetty.xml concepts are only relevant if you are using the standalone Jetty techniques (such as what's seen in jetty-home or the older jetty-distribution archives). More specifically, the start.jar within the jetty-home archive is the only one that looks for and uses either the etc directory or the jetty.xml file.
The jetty.xml, that the start.jar is aware, of is never managed by manually creating it or editing it. In fact it's a typically a read-only file that comes with the jetty-home archive, and is used in-place. The etc directory is found within the jetty-home archive, and can also be seen in the application specific configuration of Jetty standalone known as the ${jetty.base} directory.
You mentioned "jetty/9.4.28.v20200408 embedded" which typically means it's not using the standalone Jetty concepts. In an embedded Jetty scenario, the configuration of the Jetty server is typically done within the configuration techniques of the parent project (Oracle ORDS in your case). You'll need to know how that Jetty server is configured, and work within the limits of whatever configuration that parent project provides to you.
screenshot of the error
I am getting this error:"App installer failed to install package dependencies.Ask the developer for Microsoft.VCLibs.140.00.Debug package" while side loading .appxbundle file via App installer in windows10 client machine, however the same was sideloaded in my (developer) machine without any issue. I am using Visual Studio 2017 for development. Couldn't find anything relevant in google. Somebody help..!!
Try to add it to Dependencies section into .appinstaller file:
<Dependencies>
<Package Name="Microsoft.VCLibs.140.00" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" Version="14.0.24605.0" ProcessorArchitecture="x86" Uri="http://foobarbaz.com/fwkx86.appx" />
<Package Name="Microsoft.VCLibs.140.00" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" Version="14.0.24605.0" ProcessorArchitecture="x64" Uri="http://foobarbaz.com/fwkx64.appx" />
</Dependencies>
To read more about App Installer file, please visit microsoft docs:
https://learn.microsoft.com/en-us/windows/uwp/packaging/install-related-set
Actually, you can install this application via ps1 script (run it from context menu -> Run with PowerShell):
It has already created script which will install all of dependencies.
Edit:
Actually, I found solution for me: if you build the app in Release (instead of Debug) it should be contain all of needed dependencies into itself. So, I think it could be some kind of workaround for somebody.
"App installer failed to install package dependencies. Ask the developer for Microsoft.VCLibs.140.00.Debug package"
From this prompt, we can know that this can be fixed by installing this Microsoft.VCLibs.140.00.Debug package. Usually, you can find it in your completed package. So you may install this file independently.
Or you could package your app under Release mode and then sideload the new file in this new package to your client machine.
We're migrating an application from JBoss AS 5.1 to JBoss AS 7.4 (EAP 6.3). In there, we consume an RPC encoded web service.
We had used the Sun XML RPC lib to autogenerate Java source from the WSDL, which was awfully old even back then, and some SAAJ version related conflicts occurred which were just so resolvable in the JBoss environment. So we ruled out using the Sun RPC lib in the JBoss 7 environment.
It was suggested to us to use Axis 1.4 to generate classes from the WSDL. However, it is also ancient (2006), so I'm afraid we'd just end up with a similar conflict as with Sun RPC.
So I'm wondering whether anyone has sucessfully deployed classes autogenerated from Axis 1.4 in JBoss 7 (on Java 7) and whether they encountered library conflicts?
It worked. I had to add these artifacts:
<dependency>
<groupId>org.apache.axis</groupId>
<artifactId>axis</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>axis</groupId>
<artifactId>axis-wsdl4j</artifactId>
<version>1.5.1</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>commons-discovery</groupId>
<artifactId>commons-discovery</artifactId>
<version>0.5</version>
</dependency>
which didn't cause any conflicts in JBoss EAP 6.3. I was kinda expecting a SAAJ conflict, but it appears to serve as a client for the webservice, Axis doesn't need SAAJ (or it's content to use the SAAJ it finds in the platform)
I'm implementing a custom Mediator for wso2esb-4.7.0. Obviously as my classes will be running within the context of wso2esb, I expect them to utilise the same deps.
wso2esb has, for whatever curious reason, been deployed with custom builds of its dependencies. Eg. They expect you to point at their custom mvn repostiory and use artefacts suffixed with "-wso2vn" Eg. axis2-kernel/1.6.1-wso2v9
This has worked for most of the dependencies which get shared with the wso release, however wso2esb uses its own logging artefact with its own versions of sl4j and commons-logging:
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>logging</artifactId>
<version>4.1.0</version>
</dependency>
The problem is that this doesn't exist in their mvn repo, which contains the pom files but not the jar:
http://dist.wso2.org/maven2/org/wso2/carbon/logging/4.1.0/
I'm going to use the non-wso2 specific versions of those jars for now, but will need to resolve this for deployment.
Suggestions welcome.
AFAIK the above dependency is the aggregate module of the logging related dependencies used in WSO2 carbon products. Therefore it will have a pom file only.
Use the following dependency for your requirement.
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.logging</artifactId>
<version>4.1.0</version>
</dependency>
The maven repo link can be found here.
I want to use Jetty 8.0 Server for my application. Which IDE i will use for simple configuration.
Presently i am using Eclipse. How to configure jetty in Eclipse. Any best example?
I use run-jetty-run, and jetty with maven in eclipse.
http://code.google.com/p/run-jetty-run/
More on jetty maven plugins:
http://wiki.eclipse.org/Jetty/Feature/Jetty_Maven_Plugin
I use run-jetty-run with DCEVM for hotdeploy.
Here's my tutorial, Spring-mvc + Velocity + DCEVM
Most people I know simply write a small embedded usage of jetty for their application. It is dead simple to do and there are a number of examples in the example-jetty-embedded project in jetty git repository. It is also how most of our test cases are written, using jetty itself to test.
http://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/tree/example-jetty-embedded
If your using maven then the jetty-maven-plugin is a pretty simple way of testing and works with the eclipse plugin Webby which streamlines much of the pain and suffered that is called WTP.
https://docs.sonatype.org/display/M2ECLIPSE/Integration+with+Maven+WAR+Plugin
There is also a Jetty WTP plugin that many people use successfully.
http://wiki.eclipse.org/Jetty_WTP_Plugin
I also use run-jetty-run for Eclipse.
I tried the Jetty plugin for NetBeans, but it didn't work.
I think Jetty for Eclipse is better than Tomcat, cause its simpler to use and configure and a fast server.
Assuming you have setup M2Eclipse plugin within Eclipse correctly and your project is configured to use Maven, I've found Jetty Maven Plugin within Eclipse to be particularly useful. The beauty of this approach is that you can do your development really fast, especially if you have 3rd party dependencies. All you have to do is add the following plugin to your pom.xml:
<project>
...
<build>
<plugins>
...
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.8.v20121106</version>
<configuration>
<contextPath>/</contextPath>
</configuration>
</plugin>
...
</plugins>
</build>
...
</project>
To use this plugin successfully here some additional notes on installation and usage:
Eclipse Integration
Install the following Eclipse Plugins first
Maven Integration for Eclipse (Help > Eclipse Marketplace...)
A patch that makes it possible to debug source code at runtime. Eclipse Plugin Link
Next, create a "Maven Build" Eclipse Launcher
You also need to configure "Maven Build" launcher so that you can run the Jetty Server quickly. Follow the instructions below create this launcher:
Right-click on your current project and select (Run As/Debug As) > Maven Build...
Set Goals As rhubarb:start
Check Resolve Workspace artifacts
Save
Going forward, you can simply do: (Run As/Debug As) > Maven Build, and the goal will execute.