Why does Glassfish drop tables on deploy? - java

I used the following command to deploy updates of my *.ear file on Glassfish 3/4 and to keep (but disable) the old version of the *.ear file:
./asadmin --user admin deploy --name MyProject:0.9.2 --createtables=false --dropandcreatetables=false --enabled=true --force=true /home/updates/MyProject.ear
This always worked without touching the database. I have applied database changes manually by a script.
But suddenly this does not work anymore. The application deploys correctly, but the database is being dropped and newly created...
My Glassfish version is currently 4.0/b89. Does anybody know if there's a bug in with the asadmin deploy command ? Any other ideas how to deploy without dropping the database?
EDIT1: Btw: I'm using Eclipse-Link 2.4 as JPA-provider (if this helps...)
EDIT2: I now tried every possible combination (using only --createtables=false OR --dropandcreatetables=false), but nothing seems to work. The database is dropped everytime. I realized, that if the table-creation-strategy is set to "none" in the persistence.xml, it does work for subsequent deployments (without dropping the database). But the asadmin/deploy or also redeploy command should override the persistence.xml settings as described here and here when the --dropandcreatetables option is set to false.

According to
asadmin help deploy
and
asadmin help redeploy
for 4.0/b89, you should only use one of these? Indicated by the | in the help.
"The --createtables and --dropandcreatetables options are mutually exclusive; only one should be used."
Iain

Related

Unable to connect to HIVE through JDBC from a webapp

I have used the JDBC api to connect to HIVE2 referring here, it was successful so for easy of access I thought of creating a webapp around it using JSP as front-end page to enter server name and query. While all parameters are resolved correctly from JSP page to servlet it throws an error while connecting to HIVE server its required
to place libthrift and hive JARS in WEB-INF/lib directory I placed in both WEB-INF/lib and classpath.
Issue is as hive jar comes first in WEB-INF/lib and as it does not have "org.apache.thrift.protocol.TProtocol.getScheme()" method I keep getting no such method error. I referred here and here and moved the libthrift jar to WEB-INF/classes but it dint help:
Jar versions: libthrift-0.9.3 and hive-0.4.1
If only your Hive version was more recent, you could...
get a recent driver such as
http://central.maven.org/maven2/org/apache/hive/hive-jdbc/2.0.0/
I mean the standalone JAR, to get rid of your CLASSPATH issues
although that "standalone" promise is not 100% true because you still need a couple of extra Hadoop JARS, cf. Where is Apache Hive JDBC driver for download?
But alas, you cannot user a driver that is more recent that your server -- here V0.13, i.e. the last version without a "standalone" driver JAR.
So you've got a whole bunch of Hive JARs to collect, plus a couple of Hadoop JARs and various dependencies such as libfb303-*.jar and libthrift-*.jar
$ unzip -l libthrift-0.9.2.jar | grep
org.apache.thrift.protocol.TProtocol.class
2958 11-05-2014 03:47 org/apache/thrift/protocol/TProtocol.class

Switch java spring maven project from linux to windows

I am new to spring development so i am stuck here. Is there any configuration while switching spring + maven project from linux to windows. I am running on tomcat server 7. The project is initially developed in linux. I have moved all the file from linux to wondows. While running on server, i get error The requested resource (/myproject/login/) is not available. Do i need to make any changes or add add in configuation.
Thanks in advance.
I think you have missed something.
Try this.but i'am not sure this is working or not.
Tomcat, by default invoker servlet disabled (commented out in the web.xml file). You have to create a 'servlet' and a 'servlet-mapping' entry in your web.xml.
Once you do, you can get rid of the "servlet/" part of your url.
Check out the following URL for more information regarding the invoker servlet:
http://faq.javaranch.com/view?InvokerServlet

How to Enable Java Persistence 2.0 for Weblogic 10.3.6

I am using eclipse with weblogic server. In order to add the project to the weblogic server, it needs to support Java Persistance 2.0, however when trying to install it, I keep getting this message
Error Enabling Java Persistence 2.0 in Weblogic Server installation
I tried to follow the Oracle documents to solve this but they make no sense since I'm pretty novice with Weblogic.
http://docs.oracle.com/cd/E17904_01/web.1111/e13720/using_toplink.htm#CIHDJHHI
Please help! I understand the second part of the manual but I have no idea how to configure this Top Link stuff. Any help is greatly appreciated. Thank you!
Probably, the WebLogic Server Monitor was locking the weblogic.jar, so you couldn't upgrade the server.
I had the same issue and solved it by switching to a new workspace. There, I could add the server again and upgrade it, without being disturbed by the WebLogic Server Monitor.
I have enabled JPA 2.0 on a Unix-based system using a variation on the 'Installing Manually' steps in the Oracle doc you referenced. The key is to add the two JPA jars at the beginning of the classpath. In my case, we wanted JPA 2.0 support for a single managed server in the domain, so I added the following hack at the beginning of the setDomainEnv.sh script:
if [ "${SERVER_NAME}" = "TEST_Server1" ] ; then
JPA20="path/modules/javax.persistence_1.1.0.0_2-0.jar${CLASSPATHSEP}path/modules/com.oracle.jpa2support_1.0.0.0_2-1.jar"
if [ "${PRE_CLASSPATH}" != "" ] ; then
PRE_CLASSPATH="${JPA20}${CLASSPATHSEP}${PRE_CLASSPATH}"
export PRE_CLASSPATH
else
PRE_CLASSPATH="${JPA20}"
export PRE_CLASSPATH
fi
fi
Adjust the TEST_Server1 name (or just remove the if) and path
references to align with your environment.
I ended up using the 'Smart Update' utility that was located in: start->program files->Oracle WebLogic->Smart Update (Windows server, obviously)
The hardest part was locating the Oracle patch number for JPA 2 for my version of WebLogic (10.3.6).
For those of you in the same boat this is the info for the patch for version 10.3.6:
Smart Update patch 7BWI for WebLogic Server 10.3.6
Content:
This patch contains Smart Update patch 7BWI for WebLogic Server 10.3.6.0
Description:
Enable JPA2.0 support on Weblogic server.
Patch Installation Instructions:
copy content of this zip file with the exception of README file to your SmartUpdate cache directory (MW_HOME/utils/bsu/cache_dir by default)
apply patch using Smart Update utility
I am not sure how to attach files to this post or I would just include the patch. Message me if you want me to email a copy to you.

using JDBC within dynamic web application

I have a dynamic web application using struts2 that works perfectly.
I have a JDBC application that works perfectly (all it does is print a table out in the console).
After I put the two together all that was left was to add authentication to the run configuration and I'd be done...
I've already put the sqljdbc_auth.dll to the WEB-INF/lib
I've tried to add this line to Tomcat v7.0 Server at localhost
-Djava.library.path="C:\Program Files (x86)\jdbc\sqljdbc_4.0\enu\auth\x86"
but it doesn't do anything
This driver is not configured for integrated authentication.
ClientConnectionId:6495...
It's the line that got my JDBC application working just fine.
Would there be some syntax error I'm missing or another method for me to pass an argument that I'm not aware of?
It looks like you are using the Microsoft SQL Server Driver which is pure java (type 4) so you dont need to mess with java.library.path. Set the Classpath as described here
Alternatively include the jdbc driver in WEB-INF/lib within your WAR file.

unable to redeploy web application on glassfish3

I m trying to deploy a web application using netbeans to glassfish 3.01 but i m not able to do so
Glassfish says
Inconsistent Module State
the web app has some jars and a ejb jar for a local ejb
Open the domain.xml file that you will find in this folder:
"your glassfish installation"/domains/"your domain"/config
In this file look for your application deployment configuration to manually remove it:
1) Remove the web-module tag
<applications>
...
<web-module availability-enabled="false" context-root="yourapplicatoinContext" ... />
...
</applications>
2) Also remove the application-ref to your application:
<server config-ref="server-config" lb-weight="100" name="server">
...
<application-ref ... ref="your application name" ... />
...
</server>
Just try this:
undeploy
stop Glassfish
start Glassfish
deploy
If you can't undeploy, try the other steps anyway. If you don't have any luck, you could try it this way:
stop Glassfish
edit domain.xml (probably in domains/domain1/config)- back it up first; remove all references to your app (probably under application / application-ref); just make sure it's still valid xml
start Glassfish
deploy
It should have solved it. If still no luck anyway, remove every file or directory related to your app, probably under domains/domain1/generated and domains/domain1/applications/....
You could always recreate a new domain, but above steps will solve your problem.
You could be in such a situation after stopping Glassfish middle in a deploiyment, for example.
The other answers are really extreme. There is no need to create a new domain or re-install if you cannot redeploy your web application during development.
If you app is very complex, then consider scripting any clean up needed in a Production environment. The below steps will keep you up and working in the short term.
To re-deploy a web app to a single domain on Glassfish 3.1, do the following:
Stop Glassfish from the command line.
Delete all the files in the following directories:
glassfish\domains\domain1\generated
glassfish\domains\domain1\applications
Start Glassfish from the command line.
Deploy your app via the Admin Tool or command line.
In Glassfish 5, I searched for my app name in the domain.xml and deleted all the tags mentioning it. There was one occurence in the beginning (<system-applications>) and one at the end at approx. line 460 (<applications>). Then redeploy worked!

Categories