WebSwing to Tomcat deployment (Configuration) - java

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.

Related

Java Debug won't unfold the WAR file On windows with netbeans

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

Apache Tomcat 8 not working. Throws HTTP Status 500 - java.lang.ClassNotFoundException: org.apache.jsp.index_jsp

I am using Apache Tomcat 8 and I've JDK 1.7.
Tomcat starts running after I run "startup.bat". But when I try to run "http://localhost:8080/", it shows an error: "HTTP Status 500 - java.lang.ClassNotFoundException: org.apache.jsp.index_jsp"
Please help me to fix this.
Click here to see the screenshot
IT'S WORKING!
What I did:
Opened command prompt using "Run as administrator"
Went to the "bin" directory of Tomcat folder.
cd C:\Program Files\apache-tomcat-8.0.3\bin'
Entered 'startup' to run 'startup.bat' and the server started
Opened a web browser entered http://localhost:8080/ and it worked like charm. This also started generating Tomcat log files too.
The only different thing I performed is "Run as administrator".
But I checked with Tomcat7 it did not require me to "Run as administrator" but it worked; not sure why
Check the lib folder of your tomcat installation. It must contain the JARs jasper-el.jar, jasper.jar, and jsp-api.jar. If they exist, maybe you should add Tomcat 8 in the Java Build Path for your project.
EDIT:
What you can do is to run shutdown.bat. Then look for a file called catalina.out in the logs folder of your tomcat installation. Open it in a text editor, delete all of its contents and save. Then try running startup.bat again. Next copy the contents of catalina.out and paste them here. This may help other people solve your problem.
I had the very same error attempting to reach the manager URL (actually, 404 then 500 after page refresh, each single time). I thought it was <SERVER_BASE_URL>/manager/. It turns out it was <SERVER_BASE_URL>/manager/html.
It’s worth mentioning it wouldn’t tell me I wasn’t using the right credentials either.
Simple, A ClassNotFoundException throws when some where a class that is used in the code is missing.
EG : If it is for servlet, then it means something servlet api that is regularly available to tomcat is now missing for some reason.
quite possibly the servlet-api.jar file in tomcat's lib folder (maybe other jar files in the tomcat lib folder) have become corrupted or removed.
Find it, you'll fix that.

How to set bootstrap entries of Tomcat without using Eclipse?

I am using Tomcat 7. JDK1.6.
I was trying to get the list of runtime JVM.
Code:
for (int i=0; i<VirtualMachine.list().size(); i++) {
VirtualMachineDescriptor vi = VirtualMachine.list().get(i);
System.out.println("**PID :"+vi.id()+" **DISPLAYNAME:"+vi.displayName());
}
It works fine when I compile it in Eclipse. But when I exported it in to a war package, and put the war file into webapps folders of Tomcat, it returns empty list.
And eclipse use the same tomcat too. I found that configuration files in eclipse are same with those files in tomcat. But there are bootstrap entries and user entries in eclipse. User entries are pointed to Tomcat 7. I want to try to set same configuration to Tomcat, but I don'
t know how to set bootstrap entries to Tomcat.
When I debugged the tools.jar code and found the root cause,
In short, what you need to do is just remove the all the following setting in catalina.bat or catalina.sh, before you start tomcat on windows or unix. Enjoy it! :-)
-Djava.io.tmpdir="%CATALINA_TMPDIR%"
Welcome discussion, maybe there are much earier way then mine.

Can't figure out cause for NoClassDefFoundError: aspose/pdf/Paragraph

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

ClassNotFoundException: BasicDataSourceFactory

I have a JAVA application that runs fine in my local Windows7 environment on Tomcat7. I am trying to put this into production in a Linux environment.
Everything is done and is working fine except when my application tries to access the DB. Operations where DB is not involved, it works fine.
The error I get is
java.lang.ClassNotFoundException: org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory
This class is part of tomcat-dbcp.jar. This is placed in my $CATALINA_HOME/lib folder. Why is this still not getting picked up? Please help!
UPDATE: I also opened up the .jar file and checked. The org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory.class file is present.
Was finally able to crack it. My mistake - I was relying only on echo $CATALINA_HOME to check its location. Turns out that this can be misleading.
It is better to use
ps aux | grep catalina
In the output that comes look for catalina.base and catalina.home. The path given in front of these variables is the path from where Tomcat libs are being fetched. I had done a default installation and found the libs under /usr/share/tomcat7. As it turns out, the default installation done using yum did not provide the tomcat-dbcp.jar file. Instead it provided the commons-dbcp.jar. Read about tomcat-dbcp vs commons-dbcp
Changing the lib files under the usr/share/tomcat7 folder required me to use sudo bash. Also you may notice that the lib folder under /usr/share/tomcat7 is a simlink. Just do ls /usr/share/tomcat7 -l to get the parent location. You will be able to make changes only in the parent location.
Similar things can be checked for server.xml which is also finally being picked from /usr/share/tomcat7 itself.
The best way to manage all these is to create your own simlinks so that you don't need to bother about going to various locations after the first time.
Thanks to everyone who tried to help.

Categories