I'm currently developping an application using Spring Web MVC & Spring Security.
I can deploy it on Glassfish 3.1.2 but when I want to redeploy after some bug fixing, I get this error :
WARNING: Exception while locating sub archive: XXX.war
WARNING: DPL8031: Ignoring XXX_war/ because the containing archive C:\dev\apps\glassfish3\glassfish\domains\domain1\applications\XXX recorded it as a pre-existing stale file
.glassfishStaleFiles contains :
XXX_war/
XXX_war/WEB-INF/
XXX_war/WEB-INF/lib/
XXX_war/WEB-INF/lib/spring-web-3.2.2.RELEASE.jar
And indeed, spring-web-3.2.2.RELEASE.jar still exists and when I try to remove it, I get a message that says It's still in use by JVM.
I found this link :
https://www.java.net//forum/topic/glassfish/glassfish/stale-files-when-undeploying-web-app-glassfish-3
My question is : does someone have a workaround for this issue ?
It's really annoying while developping...
To correct this problem, I have an easier solution :
Assuming your EAR file is correct:
stop the server
goto your EAR directory :
C:\java_apps\glassfish3\glassfish\domains\domain1\applications\XXX_EAR
delete the file called .glassfishStaleFiles
restart server and re-deploy EAR file
It did the trick for me.
Ok, after some days of research...
I finally found how to get around.
My project hierarchy was :
XXX.ear
--- lib/
------ XXX_Entities.jar
--- XXX_Ejb.jar
--- XXX_EjbClient.jar
--- XXX_Web.war
------ WEB-INF/lib/
--------- *libraries*
Now :
XXX.ear
--- lib/
------ XXX_Entities.jar
------ *libraries*
--- XXX_Ejb.jar
--- XXX_EjbClient.jar
--- XXX_Web.war
Then add lib folder to EAR deployment assembly and it works. Glassfish unload correctly when undeploying.
Related
My application has application.yml in the main and test resources folder however application (Spring boot 2.4 with Maven) is complaining that application.properties is not found.
Below is the error.
2021-07-08 04:37:33.381 ERROR --- [ main] o.s.test.context.TestContextManager : Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener#bd4ee01] to prepare test instance [com.test.SomeTests#6a7aa675]
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:132)
...
Caused by: java.io.FileNotFoundException: class path resource [application.properties] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:187)
I have tried to find solution online but could not able to find one. Please help.
This is not a sufficient description for your problem, where did you put the application.yml file ? if you are in a maven projet project, you should put it under src/main/resources folder.
Also I'm not sure if spring is able to interpret .yml file extension of your file, try to change it to application.yaml instead.
Note from spring.io :
You can explicitly specify your application properties location by setting the program arguments with as :
--spring.config.location=your_properties_path
The projet work fine in tomcat localhost but when I upload it in a remote tomcat I get this bug :/ , I have the jar that contain the ImageReaderFactory class in classpath, I didn't understand what can be the problem,
I cleared the /tomcat/work/Catalina/localhost folder but always the same bug : java.lang.NoClassDefFoundError
07-Oct-2019 23:06:25.584 SEVERE [http-apr-8080-exec-267] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [UploadServlet] in context with path [/MyServer] threw exception [Servlet execution threw an exception] with root cause
java.lang.NoClassDefFoundError: org/dcm4che3/imageio/codec/ImageReaderFactory
at org.dcm4che3.imageio.plugins.dcm.DicomImageReader.setMetadata(DicomImageReader.java:794)
at org.dcm4che3.imageio.plugins.dcm.DicomImageReader.readMetadata(DicomImageReader.java:713)
at org.dcm4che3.imageio.plugins.dcm.DicomImageReader.read(DicomImageReader.java:452)
at com.project.dicomserver.UploadServlet.getFrameIcon(UploadServlet.java:86)
....
Does anyone have any ideas?
image
There is a bunch of things that could be go wrong in your specific case. So answering with the best of my knowledge. Make amendments, by adding as much details as possible, to the question and we can help you further.
Every application in tomcat needs to have a specific folder structure. The folder structure is documented here. In short, war files must be deployed into $CATALINA_BASE/webapps/ directory.
So if your application is "myapp", then there must be a $CATALINA_BASE/webapps/myapp directory.
Inside $CATALINA_BASE/webapps/myapp directory, we need to have WEB-INF. Not $CATALINA_BASE/webapps/myapp/WebContent/WEB-INF, but $CATALINA_BASE/webapps/myapp/WEB-INF ! And the case matters.
If this is not how your application is deployed into a vanilla tomcat, it will not work properly. Read the official documentation
Now about your development environment, see whether your eclipse configurations have been modified. The Export As War options can be modified at multiple locations and all of them can have impact on the war file you have generated. When in doubt, I look at this link
Use a build tool like maven or gradle. These tools bring standards for compiling, archiving, testing and deploying applications and makes you worry less on environment related issues.
I have a Spring REST application deployed to a Tomcat server. I had placed a schema.sql file inside the resources folder that I use to recreate database on local test/development scenarios.
However, when Tomcat starts up, it seemed to run this script against the database.
In the logs, I have the following entry for this:
2016-01-26 17:30:33.543 INFO 2105 --- [ost-startStop-1] o.s.jdbc.datasource.init.ScriptUtils : Executing SQL script from URL [file:/usr/share/tomcat8/apache-tomcat-8.0.30/webapps/xxxx/WEB-INF/classes/schema.sql]
I find it a bit strange and wonder why does this happen.
Can anybody provide insights into this?
I tried googling as usual, and could not find any satisfactory results.
See here: https://docs.spring.io/spring-boot/docs/current/reference/html/howto-database-initialization.html#howto-initialize-a-database-using-spring-jdbc
Spring JDBC has a DataSource initializer feature. Spring Boot enables it by default and loads SQL from the standard locations schema.sql and data.sql (in the root of the classpath).
I have been testing Spring Boot with embedded Tomcat for about a month now to build a REST API. Everything was working fine. We now want to deploy the API in a separate development environment which has a couple of other (non-Spring) applications running on a Tomcat container.
I made the changes specified in Converting a Spring Boot JAR Application to a WAR using Maven and Spring Boot Docs.
The deployment goes well (logs are fine, no errors) and looking at Tomcat management i see my application deployed. However, when I attempt to access http://localhost:8080/sophia/users in curl I get 404.
Any help is much appreciated.
UPDATE:
Here are my logs:
Netbeans:
NetBeans: Deploying on Apache Tomcat 8.0.17
profile mode: false
debug mode: false
force redeploy: true
In-place deployment at /home/bugz/workspace/pdcore/sophiaserver/target/sophia-server-1.0.0-SNAPSHOT
Deployment is in progress...
deploy?config=file%3A%2Ftmp%2Fcontext1845402702541504208.xml&path=/sophia
OK - Deployed application at context path /sophia
Start is in progress...
start?path=/sophia
OK - Started application at context path /sophia
Tomcat:
INFO 10:47:52:703 org.springframework.boot.context.embedded.ServletRegistrationBean - Mapping servlet: 'dispatcherServlet' to [/sophia/*]
INFO 10:47:54:042 org.springframework.boot.SpringApplication - Started application in 8.285 seconds (JVM running for 12087.301)
22-Jan-2015 10:47:54.060 INFO [http-nio-8080-exec-99] org.apache.catalina.startup.HostConfig.deployDescriptor Deployment of configuration descriptor /home/bugz/workspace/server/apache-tomcat-8.0.17/conf/Catalina/localhost/sophia.xml has finished in 12,091 ms
And in sophia.xml for Catalina localhost:
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" docBase="/home/bugz/workspace/pdcore/sophiaserver/target/sophia-server-1.0.0-SNAPSHOT" path="/sophia"/>
I've tried accessing
http://localhost:8080/sophia/users
http://localhost:8080/sophia-server-1.0.0-SNAPSHOT/users (name of WAR)
The first returns a 404 but with the CORS information from my CORS filter bean. The second return 404 without CORS information (which indicates the application has started and is configured but I do not seem to have access to the Controllers).
When running an application the path to call consists of a couple of parts.
The first is the base URL on which the application is deployed, in your case that is /sophia.
The second is the servlet mapping of the DispatcherServlet in your case that is /sohpia/*.
The third is the mapping of the controller inside the DispatcherServlet, in your example that is /users.
All those things combined create the URL /sophia/sophia/users.
The difference between the deployment as a WAR is that you included a separate URL to deploy on, when running as a jar it, by default, is deployed to / (the root).
You could fix it by putting /sophia as the server.context-path in the application.properties and map the DispatcherServlet to /* or /. That will in both situations give you the URL you want (and expected).
check java -version means the if you complied war in java 8 and tomcat is running on java 7 then it doesn't work.
Have you tried extending the SpringBootServletInitializer and overriding the configure method? As stated here
The entry point for jar file is different [Main Class] when compared to running your app as war file inside a container.
Hope this helps.
check the java version
version that exists in pom.xml must be the same that the version installed on the server
openjdk 11 works fine for me
https://adoptopenjdk.net/
Do you guys know why IntelliJ IDEA doesn't copy app server descriptor files to temporary folder on debug ?
I have gae+gwt project. I created gwt debug configuration that uses dev google app server as server.
When I launch debug session it fails with following error:
Connected to the target VM, address: '127.0.0.1:44527', transport: 'socket'
Initializing App Engine server
Apr 18, 2012 11:35:20 PM com.google.apphosting.utils.jetty.JettyLogger info
INFO: Logging to JettyLogger(null) via com.google.apphosting.utils.jetty.JettyLogger
Apr 18, 2012 11:35:20 PM com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml
SEVERE: Received exception processing C:\Users\root\.IntelliJIdea11\system\gwt\courierapp.courierapp23c0d1f4\Server.3565aa46\run\www\WEB-INF/appengine-web.xml
com.google.apphosting.utils.config.AppEngineConfigException: Could not locate C:\Users\root\.IntelliJIdea11\system\gwt\courierapp.courierapp23c0d1f4\Server.3565aa46\run\www\WEB-INF\appengine-web.xml
at com.google.apphosting.utils.config.AppEngineWebXmlReader.getInputStream(AppEngineWebXmlReader.java:108)
at com.google.apphosting.utils.config.AppEngineWebXmlReader.readAppEngineWebXml(AppEngineWebXmlReader.java:66)
And indeed neither appengine-web.xml nor web.xml are present in C:\Users\root\.IntelliJIdea11\system\gwt\courierapp.courierapp23c0d1f4\Server.3565aa46\run\www\WEB-INF. None of my htmls or other statis files are copied either.
If I copy them manually everything works fine.
So basically IDEA only copies java classes and depending jars.
Here is how my debug configuration looks like: i39.tinypic.com/nwzuvc.jpg
I using IDEA 117.216
I figured it out :) This mystery was bugging me for months!
I noticed this problem came up after I recreated all modules and project from sources.
The problem was that Target Web Faced wasn't set in GWT module.
Artifact is not necessary to make it work.
Please show us the screen capture of your artifacts. Open "Project Structure" window, then select "Artifacts" from left pane.
Sometimes deleting cache and rebuilding the project resolve IDEA's weird behavior. Try clearing cache then build & debug.
Thanks to #bjenkins01's comment on another answer I solved exactly this problem by checking the Build on make checkbox in the Project Structure/Artifacts tab.