Deploying war on linux - java

Hello I downloaded tomcat 8.5.4 when and I ve made some simple rest aplication with jersey. When I deploy war on tomcat on windows it works fine. When i copied whole directory to linux server(downloaded version is multiplatform) and I deploy application, Linux dont see my Rest Controller.
Same files of server, same war and windows working, linux not...
output from windows:
21-Aug-2016 19:12:52.370 INFO [localhost-startStop-2] com.sun.jersey.api.core.PackagesResourceConfig.init Scanning for root resource and provider classes in the packages:
com.test.rest
21-Aug-2016 19:12:52.414 INFO [localhost-startStop-2] com.sun.jersey.api.core.ScanningResourceConfig.logClasses Root resource classes found:
class com.test.rest.RestController
21-Aug-2016 19:12:52.414 INFO [localhost-startStop-2] com.sun.jersey.api.core.ScanningResourceConfig.init No provider classes found.
21-Aug-2016 19:12:52.568 INFO [localhost-startStop-2] com.sun.jersey.server.impl.application.WebApplicationImpl._initiate Initiating Jersey application, version 'Jersey: 1.18 11/22/2013 03:05 AM'
21-Aug-2016 19:12:53.773 INFO [localhost-startStop-2] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive D:\tomcat-8.5.4\webapps\RestServices.war has finished in 2,654 ms
output from linux
21-Aug-2016 19:17:01.343 INFO [localhost-startStop-1] com.sun.jersey.api.core.PackagesResourceConfig.init Scanning for root resource and provider classes in the packages:
com.test.rest
21-Aug-2016 19:17:01.398 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive /home/tomcat-8.5.4/webapps/RestServices.war has fished in 3,342 ms
and when I call rests:
Servlet.init() for servlet jersey-serlvet threw exception
...
java.lang.IllegalAccessError: tried to access method com.sun.jersey.core.reflection.ReflectionHelper.getContextClassLoader()Ljava/lang/ClassLoader; from class com.sun.jersey.spi.scanning.AnnotationScannerListener
Any ideas?

Did you look here if any of the answers might cover your problem?
java.lang.IllegalAccessError while trying to test a jersey REST webservice deployed on TomEE

Related

tomcat log not showing com.sun.jersey.api.core.ScanningResourceConfig.logClasses Root resource classes found

I am deploying war into two instances(containers), where same tomcat image was deployed.. when I deploy my war in first instance it showing the following log and working fine
25-Jan-2018 11:06:29.523 INFO [localhost-startStop-2]
com.sun.jersey.api.core.PackagesResourceConfig.init Scanning for root
resource and provider classes in the packages:
io.swagger.jaxrs.json
io.swagger.jaxrs.listing
com.example.metrics.service
com.example.batch.service
com.example.metrics.rest
25-Jan-2018 11:06:29.599 INFO [localhost-startStop-2]
com.sun.jersey.api.core.ScanningResourceConfig.logClasses Root resource
classes found:
class com.nuovo.streamseer.sentinel.metrics.service.SentinelMetricService
class com.example.batch.service.BatchDataService
class com.example.rest.ProcessorDataRS
class com.example.metrics.rest.DataRS
class io.swagger.jaxrs.listing.ApiListingResource
class com.example.metrics.rest.CombinedRS
class com.example.metrics.rest.AlterRS
25-Jan-2018 11:06:29.599 INFO [localhost-startStop-2]
com.sun.jersey.api.core.ScanningResourceConfig.logClasses Provider classes found:
class io.swagger.jaxrs.listing.SwaggerSerializers
class io.swagger.jaxrs.json.JacksonJsonProvider
25-Jan-2018 11:06:29.719 INFO [localhost-startStop-2]
com.sun.jersey.server.impl.application.WebApplicationImpl._initiate
Initiating Jersey application, version 'Jersey: 1.8-ea03 06/10/2011 03:17 PM'
25-Jan-2018 11:06:31.320 INFO [localhost-startStop-2]
org.apache.catalina.startup.HostConfig.deployWAR Deployment of web
application archive [/usr/local/tomcat/webapps/sat-metrics.war] has finished in [9,964] ms
But When I am trying to upload same war(sat-metrics.war) into another container, I am getting the following log and its not working
25-Jan-2018 11:05:38.056 INFO [localhost-startStop-3] com.sun.jersey.api.core.PackagesResourceConfig.init Scanning for root resource and provider classes in the packages:
io.swagger.jaxrs.json
io.swagger.jaxrs.listing
com.example.metrics.service
com.example.batch.service
com.example.metrics.rest
25-Jan-2018 11:05:38.112 INFO [localhost-startStop-3] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/usr/local/tomcat/webapps/sat-metrics.war] has finished in [7,462] ms
The difference I found is in first container log it is able to found 'root classes' but in second container log there is no root classes info.
what might the the issue and how can I solve it
I was able to find the issue, there were two versions of Jersey JAR files in WEB-INF/lib folder. After removing the conflict, it worked.

Cannot start Apache application after deployment on Windows

Trying to deploy Midpoint OpenSource IDM software on Windows server
Runing JAVA 9.0.1 and Tomcat Apache 8.5
Deployment of the WAR file seems to succeed but application does not start
On Tomcat Web Application Manager I get the error:
FAIL - Application at context path [/midpoint] could not be started
In the Catalina logs all I can see is:
SEVERE [http-nio-8080-exec-38] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file
SEVERE [http-nio-8080-exec-38] org.apache.catalina.core.StandardContext.startInternal Context [/midpoint] startup failed due to previous errors

Why can't I access APIs deployed in a newly created Jetty base directory?

I am using Jetty server for my apps. I have a web app, and when I deploy it in ${JETTY_HOME}/webapps, it works fine: I can access the APIs I have created locally and remotely.
But when I create a new Jetty base directory, and deploy my web app there, I cannot access these APIs and I get a 404 error.
Any idea about things I might have done incorrectly? I am new in web development, so any help will be very much appreciated.
Update: So these are the steps I did when I created the new Jetty base directory:
mkdir /opt/web
cd /opt/web
java -jar $JETTY_HOME/start.jar --add-to-start=http,deploy
then I placed my WAR file in /opt/web/webapps. From the new jetty base directory, I started the server with
java -jar $JETTY_HOME/start.jar jetty.port=8000
This is the log when the server started.
WARNING: Property jetty.port in <command-line> already set in /opt/web/start.ini
2015-05-14 12:11:49.973:INFO::main: Logging initialized #659ms
2015-05-14 12:11:50.278:INFO:oejs.Server:main: jetty-9.2.10.v20150310
2015-05-14 12:11:50.310:INFO:oejdp.ScanningAppProvider:main: Deployment monitor [file:/opt/web/webapps/] at interval 1
2015-05-14 12:11:51.271:INFO:oejw.StandardDescriptorProcessor:main: NO JSP Support for /myapi, did not find org.eclipse.jetty.jsp.JettyJspServlet
2015-05-14 12:11:51.305:INFO:oejsh.ContextHandler:main: Started o.e.j.w.WebAppContext#47cdc2ce{/myapi,file:/tmp/jetty-0.0.0.0-8000-myapi.war-myapi-any-1456158384990153592.dir/webapp/,AVAILABLE}{/myapi.war}
2015-05-14 12:11:51.328:INFO:oejs.ServerConnector:main: Started ServerConnector#5171c41f{HTTP/1.1}{0.0.0.0:8000}
2015-05-14 12:11:51.329:INFO:oejs.Server:main: Started #2015ms

Mysql-connector-java jar creates No TLDs error

I added a jar file mysql-connector-java-5.1.34-bin.jar to my $CATALINA_HOME/lib/ folder so I could use this library for connection pooling for mysql.
I running a dedicated server with Centos 6.6 X64 with Cpanel.
I installed jdk8 in /opt/jdk1.8.0_25 and installed tomcat 8 by untarring the download in the /home/username/ folder. I followed this tutorial:
http://tecadmin.net/install-tomcat-8-on-centos-rhel-and-ubuntu/
A simple "Hello World" servlet is running by deploying a .war file in the public_html folder
However now when I start up Tomcat (8.0.15) in the catalina.out file I see the error:
09-Dec-2014 17:45:49.152 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.15
09-Dec-2014 17:45:49.182 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive /home/username/public_html/J.war
09-Dec-2014 17:45:49.592 INFO [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
09-Dec-2014 17:46:04.623 INFO [localhost-startStop-1] org.apache.catalina.util.SessionIdGeneratorBase.createSecureRandom Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [14,997] milliseconds.
09-Dec-2014 17:46:04.657 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive /home/username/public_html/J.war has finished in 15,474 ms
And the connection pooling doesn't work. At my previous server the hosting company had setup tomcat with Cpanel and this worked just fine. I did not change the servlets so that cannot be the problem either.
My environment variables are:
CATALINA_HOME=/home/username/apache-tomcat-8.0.15
JRE_HOME=/opt/jdk1.8.0_25/jre
JAVA_PATH=/opt/jdk1.8.0_25/jre
PATH=/usr/local/jdk/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr
/bin:/opt/jdk1.8.0_25/jre/bin:/opt/jdk1.8.0_25/bin:/usr/local/bin:/usr/X11R6/bin
:/root/bin:/opt/jdk1.8.0_25/bin
JAVA_HOME=/opt/jdk1.8.0_25
CLASSPATH=.:/usr/local/jdk/lib/classes.zip
The last CLASSPATH I do not understand because there is no file classes.zip on the server.
I also tried adding the jar file directly in the WEB-INF/lib folder of the deployed war file but this also did not work (the error in catalina.out was gone though).
Can somebody explain what I'm doing wrong with adding the library?
Thanks

IntelliJ IDEA 13.0.3 and Tomcat 8.0.9. Cant get it to work

I'm trying to deploy a Java web application running on Tomcat. I got the book
Professional Java for Web Applications: Featuring Websockets, Spring Framework, JPA Hibernate, and Spring Security
and I've done everything said to get IntelliJ IDEA 13 work together with Tomcat 8.0.9. I've tested the server container manually and it works great, even deploying .war files works great. However when i move on to start/debug a web application - in this case the first example form the book - from IntelliJ the application wont start. The output in the Tomcat Log doesn't say much.
Server output tells me this:
Connected to server
[2014-08-08 09:17:35,075] Artifact Sample-Debug-IntelliJ:war exploded: Artifact is being deployed, please wait...
[2014-08-08 09:17:35,097] Artifact Sample-Debug-IntelliJ:war exploded: Error during artifact deployment. See server log for details.
[2014-08-08 09:17:35,098] Artifact Sample-Debug-IntelliJ:war exploded: com.intellij.javaee.oss.admin.jmx.JmxAdminException: com.intellij.execution.ExecutionException: L:\java-dev\java_web_apps_chapter_code\9781118656464 Full Code\Chapter 02\Sample-Debug- IntelliJ\target\sample-debug-intellij-1.0.0.SNAPSHOT not found for the web module.
08-Aug-2014 21:17:44.671 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory L:\java-dev\apache-tomcat-8.0.9\webapps\manager
08-Aug-2014 21:17:44.939 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory L:\java-dev\apache-tomcat-8.0.9\webapps\manager has finished in 268 ms
Tomcat Catalina Log output this:
08-Aug-2014 22:56:35.843 INFO [main] org.apache.catalina.core.AprLifecycleListener.init Loaded APR based Apache Tomcat Native library 1.1.30 using APR version 1.4.8.
08-Aug-2014 22:56:35.846 INFO [main] org.apache.catalina.core.AprLifecycleListener.init APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
08-Aug-2014 22:56:36.652 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized (OpenSSL 1.0.1g 7 Apr 2014)
08-Aug-2014 22:56:36.738 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-apr-8080"]
08-Aug-2014 22:56:36.746 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-apr-8009"]
08-Aug-2014 22:56:36.747 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 1060 ms
08-Aug-2014 22:56:36.771 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
08-Aug-2014 22:56:36.771 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.9
08-Aug-2014 22:56:36.778 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-apr-8080"]
08-Aug-2014 22:56:36.784 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-apr-8009"]
08-Aug-2014 22:56:36.785 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 38 ms
08-Aug-2014 22:56:46.785 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory L:\java-dev\apache-tomcat-8.0.9\webapps\manager
08-Aug-2014 22:56:47.035 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory L:\java-dev\apache-tomcat-8.0.9\webapps\manager has finished in 251 ms
I've tried on both Windows and OSX and it's the same story on both with the exact same error.
When i access http://localhost:8080/i can see that the server is up and running. However, the application isn't deployed.
Anyone experiencing the same error as me and/or know a solution?
I'm running IntelliJ IDEA 13.0.3, Java 1.8.0_11 and Tomcat 8.0.9.
EDIT: I've also tried with IntelliJ IDEA 13.1.4. Didn't make any difference.
Steps taken
Downloaded Java 1.8.0_11, installed it and added it to environment variables.
Downloaded Tomcat, unpacked it and made the following changes to it (step 2-4);
In conf/tomcat-users.xml i added this user:
<user username="admin" password="admin" roles="manager-gui,admin-gui" />
In conf/web.xml i added the code below beneath the org.apache.jasper.servlet.jspServlet element
<init-param>
<param-name>compilerSourceVM</param-name>
<param-value>1.8</param-value>
</init-param>
<init-param>
<param-name>compilerTargetVM</param-name>
<param-value>1.8</param-value>
</init-param>
<init-param>
<param-name>compiler</param-name>
<param-value>modern</param-value>
</init-param>
Downloaded apache-ant and added a setenv.bat file in the apache-tomcat/bin directory with the following script
export CLASSPATH=L:/java-dev/jdk8/lib/tools.jar:L:/java-dev/apache-ant/lib/ant.jar:L:/java-dev/apache-ant/lib/ant-launcher.jar
Started IntelliJ and added the Tomcat application server.
Then i imported the project and set it to use the Tomcat server that I just added.
UPDATE: 2014-08-09 16:22
I tried to deploy a JavaEE web application that IntelliJ created itself, and that worked right away. Seems like it's something wrong with the source code that the book references.
I had similar problem. The problem was in artifact configuration in Run/Debug Configurations. I had to remove the project artifact and readd it. The important thing is to choose Web Application: Exploded, From Modules...
You can read my blog post that contains screenshots about this issue.
For me it worked with:
File >Project Structure >Artifacts
In the
Output Layout on the right side >"Available Elements?"
right click on the available libraries ( for me it was "Spring MVC-4.2.4.RELEASE")
Put into Lib ( actually click on the fix warning button )
And it worked.
Open "Debug Configuration" in IntelliJ IDEA and make sure that "Deploy applications configured in Tomcat" checkbox is checked as it shown on the screenshot
open the artifact config dialog (artifact > edit...)
check 'Show contents of elements' in the dialogs bottom section
highlight the 'WEB-INF' directory
right click on the library container (on the right pane)
select from context menu 'put into /WEB-INF/lib'
the lib folder is added in the output layout
rebuild artifact
restart webserver
Hope it helps.

Categories