I have a little complicated problem to explain;
I have a project that I write on Netbeans that will be used as intranet application. It was a dynamic web application. And it has some File.IO operations in it . My aim is create some files on the directory where index.html in. So I try to make the program find the directory by the code below :
Session.getServletContext().getRealPath("Index.jsp");
But because of java version it didn't work so I used:
Session.getServletContext().getContextPath();
Now it shows the right path on debug but not fullpath. After debug I can find my files under c:/ not under the directory where index.html in nor even nearby my projectfolder :)
So I looked at Apache folder under Programfiles under webapps and I saw that my applications folder is not there. It didn't unfold the war file actually it seems to virtualy opens it and creates a some numbered html file under temp folder . How can I make my Tomcat work like a Tomcat on a linux system and unfold the war file and find the right folder (the main web folder) and read write files, folders etc.
Additionally I want to add the server.xml unpack config below:
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
Even if you can give me a clue I would be pleased.
Thanks,
Kaan
I solved the problem . But there is a bunch of work to do . So I write down here one by one ;
Session.getServletContext().getRealPath("Index.jsp"); is not true . But not the main problem . in the brackets we must write a folder not a file to find the parent folder. After correct this, it will return null again . because Java EE 7 does not support getRealPath() method. but at the end this will be already solved by changing the version.
On Netbeans IDE , at toolbar , tools >> Servers , I removed the
tomcat server. and also uninstall the Apache Tomcat8 that comes with
Netbeans8 because there may be a version problem as I read from the
forums.
And I download Apache Tomcat7 from the official site of apache and
installed service.
I configured tomcat-users.xml config file for admin priviledges.
And I add the Tomcat7 server at netbeans from the same toolbar
(tools >> Servers)
What I saw was in the project the server was not there. I went inside
project properties , from the menu > Run , and Server combo-box was
empty. Because I was using Java EE7 and Tomcat7 needs at least Java
EE6. So I needed to change the java ee version.
What to do :
Click the files tab near projects tab. Under nbproject folder , select j2ee.platform , for Tomcat7 change the platform to 1.6 (Tomcat6 > Jave EE 1.5). than make a "clean and build" on the project .
Now the server will come at Project > properties > Run > Servers
After that I came across with another problem : (And also you may :) )
Tomcat logs from NetBeans says :
-" '127.0.0.1*' is not recognized as an internal or external command "
to correct that : Error starting Tomcat from NetBeans - '127.0.0.1*' is not recognized as an internal or external command
Related
I followed the steps given from the official source here.
To deploy Webswing to Tomcat, follow the following steps:
Create a new folder named webswing in Tomcat’s home folder and unzip
the Webswing distribution to this folder.
Move webswing-server.war from the distribution package to Tomcat’s
webapps folder.
In conf/catalina.properties file add the following properties.
webswing.warLocation=webapps/webswing-server.war
webswing.configFile=webswing/webswing.config
webswing.tempDirBase=webswing/tmp
I followed all the steps above. But the result seems it's ERROR.
Then i tried to access(but no luck):
localhost:8080/webswing
nor
localhost:8080/webswing-server
Please take note that I'm currently using Tomcat server normally.
My specs are:
Windows 7 with 64bit, 8gb ram
JDK 8 for 64bit
Tomcat8.5.31
I thought there's no tmp folder, but after i check it out, the folder still exists there. And i also check the catalina properties, it's exactly 3lines code written already. So, What should i do to resolve this case? Any other clues?
I just tried from scratch according to documentation and have the same result.
The issue is starting directly the startup.bat
When I start the tomcat from CATALINA_HOME everything works fine, I assume starting as a service would work.
This is how I started the tomcat:
c:\_DEV\apache-tomcat-8.5.31>.\bin\startup.bat
When you start the startup.bat directly, you will see this as root cause (notice the bin in the path):
Root Cause
org.webswing.server.model.exception.WsInitException: Invalid system property webswing.warLocation: File c:\_DEV\apache-tomcat-8.5.31\bin\webapps\webswing-server.war or c:\_DEV\apache-tomcat-8.5.31\bin\webapps\webswing-server.war not found.
First of all, I want to say that I know that this question is already has been asked but their solutions really did not help me. My problem occurs when I add Tomcat9.0 into my server part in console. When I click to add server and when I then click finish to configure Tomcat I got error:
Could not load the Tomcat server configuration at \Servers2\Tomcat
v9.0 Server at localhost-config. The configuration may be corrupt or
incomplete. The processing instruction target matching "[xX][mM][lL]"
is not allowed.
I tried everything(to copy files from tomcat instalation directory to folder Server2 in my workspace, to remove then to add server)... but nothing helps me. My tomcat instalation is on Desktop and that path is set into server-Run time enviroment in eclipse.
Could someone maybe helps me to fix this problem?
Try this:
Reinstall your Tomcat 9 (use the default location to start and see if it works).
Uninstall all the tomcat servers from your servers tab in Eclipse.
Restart Eclipse.
Then go to File -> New -> Other, select Server, select Apache -> Tomcat v9.0 Server and hit Next.
Select tomcat installation directory.
Hit Finish.
After it shows up in your servers tab, double click on it and select Use Tomcat installation and save the changes.
Make sure your service in windows services set to manual and not started.
Now you can start it inside the Eclipse.
The error includes 2 parts:
Could not load the Tomcat server configuration at \Servers2\Tomcat
v9.0 Server at localhost-config
You should check the server config file.
The processing instruction target matching "[xX][mM][lL]" is not
allowed.
This error usually occurs when a XML declaration (eg: <?xml version="1.0" encoding="...">) is NOT at the beginning of the file.
Try searching the file for stray <?xml. Also, remove everything before the first <?xml, even blanks or byte order mark.
In my web application, when I do new File(".").getAbsolutePath(), the path returned is <tomcat_home>/bin. I want to change it to <tomcat_home>/webapps/<app_name>.
The default directory for HTML ./path works fine and is the path I want. But the Java path ./Path is different in the same project.
I have tried to add a parameter like workDir="Path" in the <Host> area of the server.xml file on my Tomcat server, but it doesn't work.
How do I change it?
The general question of how to change the working directory of a java process has been asked before. The simple answer is that the java language and the java virtual machine don't provide a way to change the working directory of the JVM process. You won't be able to change the working directory after tomcat has started.
Tomcat's startup scripts (bin/startup.sh and so on) don't set a working directory. The tomcat process will normally inherit whatever the current directory was for the startup script. See this question. To make tomcat start in a different working directory, you'll have to figure out what is launching tomcat, and change that process to change to the desired directory before it runs startup.sh.
As a intern, I'm currently developping a java webapp for the first time. I access a Oracle database with Hibernate framework, and use javascript and Jquery on client side.
Everything works smoothly as long as I stay in Eclipse. However, in order to deploy my application, I need to be able to launch it outside Eclipse.
Here's what I did until now : Right-clic on my projet -> Export -> Java/Runnable JAR File (with "Copy required librairies into a sub-folder net to the generated JAR", or it won't works)
I got a jar file (and a folder with a lot of jar libraries), and it runs lovely when executing it with java -jar -myJar.jar with Windows command prompt.
If I try to load a web page from my browser, the server answers (important to notice !) with a 404 error : it can't find the html page.
I can't figure out where I shoul put my webapp folder, which contains every html, css and js file.
Can you help me ? Thank you very much ;)
I can't get any pages of my webapp to load (locally on Tomcat 7.0.2.6), due to this NoClassDefFound error. I'm at my wits end trying to figure out what the cause is, here is what I know:
My coworker has this project successfully running locally (on Tomcat) and on our development server (WebLogic).
I have done a fresh pulldown from svn so my code is exactly the same as his. I've verified that I have a shared library reference to Aspose (and that the required .jars are in there), and that weblogic.xml has an entry for it.
We saw this same error when initially deploying on WebLogic because the Aspose library was named incorrectly, but it ran fine locally on his Tomcat server.
I've tried cleaning and rebuilding the project to no effect.
As best as I can figure, it has to be either a Tomcat issue, or maybe an Eclipse setting.
Has anyone encountered a similar situation? Any ideas on what to try to resolve this?
First thing you need to do is determine if you are colliding with another class with the same name and package. The easiest way to do this is with the cygwin/linux console, save this shell script to a file say, findjar
find "$1" -name "*.jar" -exec sh -c 'jar -tf {}|grep -H --label {} '$2'' \;
put it in your path and navigate to the root of the server instance and run the script like this
findjar . yourclass
Note the period, dont forget it. this will return if you have multiple classes with the same name in your project.
once your sure the project is clean and there is only one copy of the class, i would try actually adding your shared libraries folder to the websphere server instances JVM arguments. to do that:
Go into the admin, click on servers
Open server types, click on websphere application servers
You should see your server listed there, click on it
On the right hand side, you will see a section “server infrastructure” and below that is a subsection “Java and process Management”
Open that section and click on “Process Definition”
On the process definition screen is another right hand column. Click on “Java Virtual Machine”
Yes, finally we are on the correct screen, there is an end in sight here, I promise
On the virtual machine page, there is a large text field labeled “Classpath” What you need to do is enter the full path to the shared libraries folder
its odd and makes no sense to have to do it, but i have had to do that in the past to allow my code to see the properties files in a shared resource.
It is possible that your colleague has java librarys installed within his Tomcat instance itself.
Take a look in the Tomcat directory for some lib folders (I cant remember the exact location and I think it changes based on the version) but something like ${CATALINE_HOME}/common/lib
Verify that he doesnt have differen JAR files in his tomcat installation as yours.
From this question: Does Tomcat load the same library file into memory twice if they are in two web apps?
They are apparently stored here:
Tomcat 6 $CATALINA_HOME/lib
Tomcat 5 $CATALINA_HOME/common/lib