war

How can I read file from classes directory in my WAR?

流过昼夜 提交于 2019-12-17 16:47:13
问题 I need to read text file from the classpath in Java WAR application. How can I read it as InputStream. File is located in /WEB-INF/classes/ folder, but when I use following code, it just returns null. InputStream input = servletContext.getClass().getClassLoader().getResourceAsStream("my_filename.txt"); 回答1: Prefix it with a forward slash to denote the root of the classpath: getResourceAsStream("/my_filename.txt") Alternatively, you can use the serlvetContext.getResourceAsStream(..) which

Why do I get a NoSuchMethodError on JodaTime.withYear()?

Deadly 提交于 2019-12-17 16:39:35
问题 I have a maven web app project, where I use JodaTime. JodaTime is not directly referenced in my maven project, but is a part of a transitive dependency. In other words, my web app war, has another project of mine as a direct dependency, and that jar contains JodaTime. I am getting an error after executing these two lines. It compiles fine though. DateTime firstDate = new DateTime(); firstDate = firstDate.withYear(2016); And here is my error: java.lang.NoSuchMethodError: org.joda.time.DateTime

Separating war application name from war file name

柔情痞子 提交于 2019-12-17 15:54:31
问题 Currently if i deploy a war file on tomcat named say myapp.war , I can access its url by http://localhost/myapp/MyServlet. However what I want is to deploy a war with a version number in the war file name and still have the same url. For eg, I want to deploy myapp-1.1.0.war and still have the url be http://localhost/myapp/MyServlet Of course I need to keep updating the war and the version number will keep changing, so I cant hardcode the war filename anywhere. Is there any setting in web.xml

EAR vs separate EJB + WAR

吃可爱长大的小学妹 提交于 2019-12-17 15:28:11
问题 What's the difference in deploying application as EAR (with 1 EJB and 1 WAR module) vs separate modules? I want to use GlassFish 3 web profile but it does not support EAR archive. Can I simply use EJB and WAR as separate modules? Any other options? 回答1: There seems to be some confusion between 3 variants of deployment: An EAR that includes an EJB and WEB module Deploying a separate EJB module and a separate WEB module Deploying a WEB module that includes EJB classes or an EJB jar. In the

Executable war file that starts jetty without maven

与世无争的帅哥 提交于 2019-12-17 15:00:08
问题 I'm trying to make an "executable" war file ( java -jar myWarFile.war ) that will start up a Jetty webserver that hosts the webapp contained in the WAR file I executed. I found a page that described how to make what I'm looking for: However, following that advice along with how I think I'm supposed to make an executable jar (war) isn't working. I have an Ant task creating a WAR file with a manifest that looks like: Manifest-Version: 1.0 Ant-Version: Apache Ant 1.7.1 Created-By: 1.5.0_18-b02

JBoss5: Cannot deploy due to java.util.zip.ZipException: error in opening zip file

爷,独闯天下 提交于 2019-12-17 10:54:37
问题 I have a web client and a EJB project, which I created with Eclipse 3.4. When I want to deploy it on Jboss 5.0.1, I receive the error below. I searched a lot but I wasn't able to find a solution to this. 18:21:21,899 INFO [ServerImpl] Starting JBoss (Microcontainer)... 18:21:21,900 INFO [ServerImpl] Release ID: JBoss [Morpheus] 5.0.1.GA (build: SVNTag=JBoss_5_0_1_GA date=200902231221) 18:21:21,900 INFO [ServerImpl] Bootstrap URL: null 18:21:21,900 INFO [ServerImpl] Home Dir: /Applications

Using the context-root from glassfish-web.xml in GlassFish 3

那年仲夏 提交于 2019-12-17 09:54:41
问题 We recently switched to Glassfish 3.1.2.2 and have several Web-Applications packaged as war files. At times the desired context-root for these applications differs from the filename. Back when we used Weblogic we achieved this by declaring the context-root in the weblogic.xml like this <context-root>path/to/our/App</context-root> We noticed that the same Tag exists in the glassfish-web.xml. But no matter what we define there, the server always determines the filename as the context-root. Now

“webxml attribute is required” error in Maven

前提是你 提交于 2019-12-17 06:22:18
问题 I am getting the following error: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) I have got web.xml in right place which is projectname\src\main\webapp\WEB-INF\web.xml What could be causing this? 回答1: It would be helpful if you can provide a code snippet of your maven-war-plugin. Looks like the web.xml is at right place, still you can try and give the location explicitly <plugin> <groupId>org.apache.maven.plugins</groupId>

“webxml attribute is required” error in Maven

僤鯓⒐⒋嵵緔 提交于 2019-12-17 06:21:50
问题 I am getting the following error: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) I have got web.xml in right place which is projectname\src\main\webapp\WEB-INF\web.xml What could be causing this? 回答1: It would be helpful if you can provide a code snippet of your maven-war-plugin. Looks like the web.xml is at right place, still you can try and give the location explicitly <plugin> <groupId>org.apache.maven.plugins</groupId>

Difference between jar and war in Java

∥☆過路亽.° 提交于 2019-12-17 02:03:08
问题 What is the difference between a .jar and a .war file? Is it only the file extension or is there something more? 回答1: From Java Tips: Difference between ear jar and war files: These files are simply zipped files using the java jar tool. These files are created for different purposes. Here is the description of these files: .jar files: The .jar files contain libraries, resources and accessories files like property files. .war files: The war file contains the web application that can be