Using Flyway set variable statement throws error - flyway

In my EBevar SQL is working well:
BUT ....
Spring boot flyway application runs, it throws an error:
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'flywayInitializer' defined in class path
resource
[org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]:
Invocation of init method failed; nested exception is
org.flywaydb.core.internal.command.DbMigrate$FlywayMigrateException:
Migration V1__obsolete.sql failed
-------------------------------------- SQL State : 42601 Error Code : 0 Message : ERROR: syntax error at or near "#" Position: 1
Location : db/migration/pgsql/_env/V1__obsolete.sql
(C:\workspace\t-flyway\target\classes\db\migration\pgsql_env\V1__obsolete.sql)
Line : 1 Statement : #set TESTINGE = te
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796)
~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE] at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595)
~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE] at org.springframe
I also check with different cases with JDBC.
CASE 1: I got error when I execute this code:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class MysqlCon {
public static void main(String args[]) throws Exception{
Class.forName("org.postgresql.Driver");
Connection con=DriverManager.getConnection(
"jdbc:postgresql://localhost:5432/test1?createDatabaseIfNotExist=true&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true","postgres","postgres");
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("#set TESTINGE = te");
}
}
Error:
Exception in thread "main" org.postgresql.util.PSQLException: ERROR:
syntax error at or near "#" Position: 1 at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2532)
at
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2267)
at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:312)
at
org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:448)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:369) at
org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:310)
at
org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:296)
at
org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:273)
at org.postgresql.jdbc.PgStatement.executeQuery(PgStatement.java:226)
at com.techgeeknext.MysqlCon.main(MysqlCon.java:14)
I also checked another way:
CASE 2:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class MysqlCon {
public static void main(String args[]) throws Exception{
Class.forName("org.postgresql.Driver");
Connection con=DriverManager.getConnection(
"jdbc:postgresql://localhost:5432/test1?createDatabaseIfNotExist=true&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true","postgres","postgres");
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SET TESTINGE TO te");
}
}
Error:
Exception in thread "main" org.postgresql.util.PSQLException: ERROR:
unrecognized configuration parameter "testinge" at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2532)
at
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2267)
at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:312)
at
org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:448)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:369) at
org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:310)
at
org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:296)
at
org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:273)
at org.postgresql.jdbc.PgStatement.executeQuery(PgStatement.java:226)
at com.techgeeknext.MysqlCon.main(MysqlCon.java:14)
Thanks in advance

This is because #set is a DBeaver specific command. It‘s not handled on the server but on your DBeaver client.
see DBeaver handbook (https://dbeaver.com/doc/dbeaver.pdf) section Client Side Commands:
You can use special commands in the SQL scripts. These commands are executed on DBeaver's side, not on the server-side.
If you want to use Variables in Flyway you may want to have a look into Flyway placeholders: https://flywaydb.org/documentation/configuration/placeholder

Related

openqa selenium Session Not Created Exception. Flutter Automation

I am trying to automate flutter Apk by using valuekey locators. I used following code to automate Apk. I am trying to use Appium and flutter finder for the automation.
package io.github.ashwith.flutter.example;
import java.net.MalformedURLException;
import java.net.URL;
import java.time.Duration;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import io.appium.java_client.android.AndroidDriver;
import io.github.ashwith.flutter.FlutterFinder;
public class Flutter_Finder {
public static RemoteWebDriver driver;
public static void main(String[] args) throws MalformedURLException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "Android");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("noReset", true);
capabilities.setCapability("app", "E:\\Testsigma.apk");
capabilities.setCapability("automationName", "flutter");
driver = new AndroidDriver(new URL("http://localhost:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(30));
FlutterFinder finder = new FlutterFinder(driver);
WebElement element = finder.byValueKey("incrementButton");
element.click();
}
}
When I am trying to run the code I am getting following error code.
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException:
Could not start a new session.
Response code 500.
Message: An unknown server-side error occurred while processing the command.
Original error: Cannot read property 'match' of undefined
I have used following Appium java client version for this automation as my dependencies.
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>8.3.0</version>
</dependency>
Please help me to resolve this error.
Thank you very much!

TestNG, JavaFX Intellij An error occurred while instantiating class, Unable to make public <test class> accessible

I tried to call the test class programmatically and follow the instructor in the TestNG docs. When i called it in Eclipse, it worked, but when i switch to Intellij to be more convenient to use JavaFX so that i can make a UI program, it doesn't work and show this error.
This is my test call class
package com.vinh.testing.CallTest;
import org.testng.TestListenerAdapter;
import org.testng.TestNG;
import tests.LogOutTest;
public class TestLogOutCall {
public void callLogOutTest() {
TestListenerAdapter tla = new TestListenerAdapter();
TestNG testng = new TestNG();
testng.setTestClasses(new Class[] { LogOutTest.class });
testng.addListener(tla);
testng.run();
}
}
and this is my test class
package tests;
import static io.restassured.RestAssured.*;
import static org.testng.Assert.assertNotEquals;
import org.testng.annotations.Test;
import io.restassured.path.json.JsonPath;
import io.restassured.response.Response;
public class LogOutTest {
String ACCESS_TOKEN = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9hdWN0aW9uLWFwcDMuaGVyb2t1YXBwLmNvbVwvYXBpXC9sb2dpbiIsImlhdCI6MTY1NTUzNzg2OSwiZXhwIjoxNjU1ODk3ODY5LCJuYmYiOjE2NTU1Mzc4NjksImp0aSI6InJuejdrMHhSQmNUTHB2TnkiLCJzdWIiOjY1LCJwcnYiOiIyM2JkNWM4OTQ5ZjYwMGFkYjM5ZTcwMWM0MDA4NzJkYjdhNTk3NmY3In0.sX-pWrwDyGfCIhlqy_1huxTt3GSElXrQtnpKV53q4BM";
#Test
public void Test01() {
baseURI = "https://auction-app3.herokuapp.com/api";
Response response = given().
header("Authorization", "bearer" + ACCESS_TOKEN).
contentType("application/json").
when().
post("/logout");
response.then().statusCode(200);
System.out.println(response.getBody().asString());
JsonPath jpath = response.jsonPath();
int code = jpath.getInt("code");
System.out.println(code);
assertNotEquals(code, 1000);
}
}
and then i met this
C:\Users\Lenovo\.jdks\openjdk-18.0.1.1\bin\java.exe "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2022.1.1\lib\idea_rt.jar=50009:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2022.1.1\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\Lenovo\.m2\repository\org\openjfx\javafx-controls\18\javafx-controls-18.jar;C:\Users\Lenovo\.m2\repository\org\openjfx\javafx-graphics\18\javafx-graphics-18.jar;C:\Users\Lenovo\.m2\repository\org\openjfx\javafx-base\18\javafx-base-18.jar;C:\Users\Lenovo\.m2\repository\org\openjfx\javafx-fxml\18\javafx-fxml-18.jar;C:\Users\Lenovo\.m2\repository\org\apache\groovy\groovy\4.0.1\groovy-4.0.1.jar;C:\Users\Lenovo\.m2\repository\org\apache\groovy\groovy-xml\4.0.1\groovy-xml-4.0.1.jar;C:\Users\Lenovo\.m2\repository\org\apache\httpcomponents\httpclient\4.5.13\httpclient-4.5.13.jar;C:\Users\Lenovo\.m2\repository\org\apache\httpcomponents\httpcore\4.4.13\httpcore-4.4.13.jar;C:\Users\Lenovo\.m2\repository\commons-logging\commons-logging\1.2\commons-logging-1.2.jar;C:\Users\Lenovo\.m2\repository\commons-codec\commons-codec\1.11\commons-codec-1.11.jar;C:\Users\Lenovo\.m2\repository\org\apache\httpcomponents\httpmime\4.5.13\httpmime-4.5.13.jar;C:\Users\Lenovo\.m2\repository\org\hamcrest\hamcrest\2.1\hamcrest-2.1.jar;C:\Users\Lenovo\.m2\repository\org\ccil\cowan\tagsoup\tagsoup\1.2.1\tagsoup-1.2.1.jar;C:\Users\Lenovo\.m2\repository\org\apache\groovy\groovy-json\4.0.1\groovy-json-4.0.1.jar;C:\Users\Lenovo\.m2\repository\io\rest-assured\rest-assured-common\5.1.1\rest-assured-common-5.1.1.jar;C:\Users\Lenovo\.m2\repository\io\rest-assured\xml-path\5.1.1\xml-path-5.1.1.jar;C:\Users\Lenovo\.m2\repository\xml-apis\xml-apis\1.4.01\xml-apis-1.4.01.jar;C:\Users\Lenovo\.m2\repository\com\google\code\findbugs\jsr305\3.0.2\jsr305-3.0.2.jar;C:\Users\Lenovo\.m2\repository\org\slf4j\slf4j-api\1.7.36\slf4j-api-1.7.36.jar;C:\Users\Lenovo\.m2\repository\com\beust\jcommander\1.82\jcommander-1.82.jar;C:\Users\Lenovo\.m2\repository\org\webjars\jquery\3.6.0\jquery-3.6.0.jar;C:\Users\Lenovo\.m2\repository\junit\junit\4.10\junit-4.10.jar;C:\Users\Lenovo\.m2\repository\org\hamcrest\hamcrest-core\1.1\hamcrest-core-1.1.jar -p D:\Testing\target\classes;C:\Users\Lenovo\.m2\repository\org\testng\testng\7.6.0\testng-7.6.0.jar;C:\Users\Lenovo\.m2\repository\org\openjfx\javafx-base\18\javafx-base-18-win.jar;C:\Users\Lenovo\.m2\repository\org\apache\commons\commons-lang3\3.11\commons-lang3-3.11.jar;C:\Users\Lenovo\.m2\repository\org\openjfx\javafx-fxml\18\javafx-fxml-18-win.jar;C:\Users\Lenovo\.m2\repository\io\rest-assured\json-path\5.1.1\json-path-5.1.1.jar;C:\Users\Lenovo\.m2\repository\io\rest-assured\rest-assured\5.1.1\rest-assured-5.1.1.jar;C:\Users\Lenovo\.m2\repository\org\openjfx\javafx-graphics\18\javafx-graphics-18-win.jar;C:\Users\Lenovo\.m2\repository\com\googlecode\json-simple\json-simple\1.1.1\json-simple-1.1.1.jar;C:\Users\Lenovo\.m2\repository\org\openjfx\javafx-controls\18\javafx-controls-18-win.jar;C:\Users\Lenovo\.m2\repository\org\controlsfx\controlsfx\11.1.1\controlsfx-11.1.1.jar -m com.vinh.testing/com.vinh.testing.AutomationTesting
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at javafx.fxml#18/javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1857)
at javafx.fxml#18/javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1724)
at javafx.base#18/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at javafx.base#18/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:234)
at javafx.base#18/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at javafx.base#18/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at javafx.base#18/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at javafx.base#18/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base#18/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base#18/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base#18/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base#18/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base#18/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at javafx.base#18/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.base#18/javafx.event.Event.fireEvent(Event.java:198)
at javafx.graphics#18/javafx.scene.Scene$ClickGenerator.postProcess(Scene.java:3586)
at javafx.graphics#18/javafx.scene.Scene$MouseHandler.process(Scene.java:3890)
at javafx.graphics#18/javafx.scene.Scene.processMouseEvent(Scene.java:1874)
at javafx.graphics#18/javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2607)
at javafx.graphics#18/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:411)
at javafx.graphics#18/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:301)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at javafx.graphics#18/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:450)
at javafx.graphics#18/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:424)
at javafx.graphics#18/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:449)
at javafx.graphics#18/com.sun.glass.ui.View.handleMouseEvent(View.java:551)
at javafx.graphics#18/com.sun.glass.ui.View.notifyMouse(View.java:937)
at javafx.graphics#18/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics#18/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:119)
at java.base/java.lang.reflect.Method.invoke(Method.java:577)
at com.sun.javafx.reflect.Trampoline.invoke(MethodUtil.java:77)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:577)
at javafx.base#18/com.sun.javafx.reflect.MethodUtil.invoke(MethodUtil.java:275)
at javafx.fxml#18/com.sun.javafx.fxml.MethodHelper.invoke(MethodHelper.java:84)
at javafx.fxml#18/javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1854)
... 29 more
Caused by: org.testng.TestNGException:
An error occurred while instantiating class tests.LoginTest: Unable to make public tests.LoginTest() accessible: module com.vinh.testing does not "exports tests" to module org.testng
at org.testng#7.6.0/org.testng.internal.objects.SimpleObjectDispenser.createInstance(SimpleObjectDispenser.java:99)
at org.testng#7.6.0/org.testng.internal.objects.SimpleObjectDispenser.dispense(SimpleObjectDispenser.java:40)
at org.testng#7.6.0/org.testng.internal.objects.GuiceBasedObjectDispenser.dispense(GuiceBasedObjectDispenser.java:28)
at org.testng#7.6.0/org.testng.internal.ClassImpl.getDefaultInstance(ClassImpl.java:106)
at org.testng#7.6.0/org.testng.internal.ClassImpl.getInstances(ClassImpl.java:136)
at org.testng#7.6.0/org.testng.TestClass.getInstances(TestClass.java:129)
at org.testng#7.6.0/org.testng.TestClass.initTestClassesAndInstances(TestClass.java:109)
at org.testng#7.6.0/org.testng.TestClass.init(TestClass.java:101)
at org.testng#7.6.0/org.testng.TestClass.<init>(TestClass.java:66)
at org.testng#7.6.0/org.testng.TestRunner.initMethods(TestRunner.java:463)
at org.testng#7.6.0/org.testng.TestRunner.init(TestRunner.java:335)
at org.testng#7.6.0/org.testng.TestRunner.init(TestRunner.java:288)
at org.testng#7.6.0/org.testng.TestRunner.<init>(TestRunner.java:178)
at org.testng#7.6.0/org.testng.SuiteRunner$DefaultTestRunnerFactory.newTestRunner(SuiteRunner.java:639)
at org.testng#7.6.0/org.testng.SuiteRunner.init(SuiteRunner.java:225)
at org.testng#7.6.0/org.testng.SuiteRunner.<init>(SuiteRunner.java:115)
at org.testng#7.6.0/org.testng.TestNG.createSuiteRunner(TestNG.java:1349)
at org.testng#7.6.0/org.testng.TestNG.createSuiteRunners(TestNG.java:1325)
at org.testng#7.6.0/org.testng.TestNG.runSuitesLocally(TestNG.java:1167)
at org.testng#7.6.0/org.testng.TestNG.runSuites(TestNG.java:1099)
at org.testng#7.6.0/org.testng.TestNG.run(TestNG.java:1067)
at com.vinh.testing/com.vinh.testing.CallTest.TestLoginCall.CallTestLogin(TestLoginCall.java:16)
at com.vinh.testing/com.vinh.testing.Controller.Test(Controller.java:63)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
... 36 more
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make public tests.LoginTest() accessible: module com.vinh.testing does not "exports tests" to module org.testng
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Constructor.checkCanSetAccessible(Constructor.java:191)
at java.base/java.lang.reflect.Constructor.setAccessible(Constructor.java:184)
at org.testng#7.6.0/org.testng.internal.objects.SimpleObjectDispenser.instantiateUsingDefaultConstructor(SimpleObjectDispenser.java:177)
at org.testng#7.6.0/org.testng.internal.objects.SimpleObjectDispenser.createInstance(SimpleObjectDispenser.java:87)
... 59 more
Im new to TestNG, pls help me.

After accidentally deleting Data Dictionary (app:dictionary) Alfresco doesn't start

One operator deleted Data Dictionary and restarted Alfresco 3.4.12 Enterprise Edition. The context /alfresco doesn't start with the following exception:
17:43:11,100 INFO [STDOUT] 17:43:11,097 ERROR [web.context.ContextLoader] Context initialization failed
org.alfresco.error.AlfrescoRuntimeException: 08050000 Failed to find 'app:dictionary' node
at org.alfresco.repo.action.scheduled.ScheduledPersistedActionServiceImpl.locatePersistanceFolder(ScheduledPersistedActionServiceImpl.java:132)
Looking at the source code in org.alfresco.repo.action.scheduled.ScheduledPersistedActionServiceImpl.java, the path is hardwired.
Then we followed the tip from https://community.alfresco.com/thread/202859-error-failed-to-find-appdictionary-node, editing bootstrap-context.xml, comment out the class.
After the change the error went over, now the RenditionService couldn't start.
We're looking for a way to recover the deleted node, since we can obtain the nodeid from the database. So we created a small class and invoke it through spring in bootstrap-context.xml, but it's failing due to permissions. Could you take a look at the code and tell us what's wrong. The code is:
package com.impulseit.test;
import javax.transaction.UserTransaction;
import org.alfresco.repo.node.archive.NodeArchiveService;
import org.alfresco.repo.node.archive.RestoreNodeReport;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.NodeRef;
public class RestoreNode {
private NodeArchiveService nodeArchiveService;
private ServiceRegistry serviceRegistry;
private String nodeName ="archive://SpacesStore/adfc0cfe-e20b-467f-ad71-253aea8f9ac9";
public void setNodeArchiveService(NodeArchiveService value)
{
this.nodeArchiveService = value;
}
public void setServiceRegistry(ServiceRegistry value)
{
this.serviceRegistry = value;
}
public void doRestore() {
RunAsWork<Void> runAsWork = new RunAsWork<Void>()
{
public Void doWork() throws Exception
{
NodeRef nodeRef = new NodeRef(nodeName);
//RestoreNodeReport restoreNodeReport =
UserTransaction trx_A = serviceRegistry.getTransactionService().getUserTransaction();
trx_A.begin();
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());
RestoreNodeReport restored = nodeArchiveService.restoreArchivedNode(nodeRef);
trx_A.commit();
return null;
}
};
AuthenticationUtil.runAs(runAsWork,AuthenticationUtil.getSystemUserName());
}
public RestoreNode() {
}
}
The exception is:
19:31:21,747 User:admin ERROR [node.archive.NodeArchiveServiceImpl] An unhandled exception stopped the restore
java.lang.NullPointerException
at org.alfresco.repo.security.permissions.impl.model.PermissionModel.getPermissionReference(PermissionModel.java:1315)
at org.alfresco.repo.security.permissions.impl.PermissionServiceImpl.getPermissionReference(PermissionServiceImpl.java:956)
at org.alfresco.repo.security.permissions.impl.PermissionServiceImpl.hasPermission(PermissionServiceImpl.java:976)
Thank you in advance.
Luis

Error while running client code in EJB

Getting error while running client code in EJB:
Exception in thread "Main Thread" java.lang.NoClassDefFoundError:
weblogic/kernel/KernelStatus at
weblogic.jndi.Environment.(Environment.java:78) at
weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFactory.java:117)
at
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
at
javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.init(InitialContext.java:223) at
javax.naming.InitialContext.(InitialContext.java:197) at
User.main(User.java:21)
I added wlfullclient.jar, server's Remote interface jar, also I saw article in which I saw to add wlclient.jar and weblogic.jar but then also got same error.
Help highly appreciated.
Client code:
import com.amdocs.Stateful.*;
import java.util.Hashtable;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class User
{
public static void main(String args[]){
Hashtable<String,String> ht = new Hashtable<String,String>();
ht.put(InitialContext.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");// you have to start from root location to search for JNDI tree
//JNDI registry tree is normally maintained as Binary tree, JNDi is normally binary tree which have root node at top
ht.put(InitialContext.PROVIDER_URL,"t3://localhost:7001"); // address of registry
try{
System.out.println("Hello");
InitialContext ic = new InitialContext(ht); // start searching wrt what we set in ht , it's constructor takes HashTable only
System.out.println("Hello2");
MyCartRemote ref=(MyCartRemote)ic.lookup("MyCartBeanJNDI#com.amdocs.Stateful.MyCartRemote");
ref.add("Hi");
ref.add("Jeetendra");
MyCartRemote ref1=(MyCartRemote)ic.lookup("MyCartBeanJNDI#com.amdocs.Stateful.MyCartRemote");
ref1.add("Hi");
ref1.add("Subhash");
ref1.add("Ghai");
System.out.println("Object 1 data: "+ref.show());
System.out.println("Object 2 data: "+ref1.show());
}
catch (NamingException e){ e.printStackTrace(); }
}
}
Try removing WebLogic System Libraries from the Bootstrap Entries section. It worked for me when i got the same error.

servlet has to be reloaded everyday

I have created a servlet to access a database and giving response to a BB application...it was running fine during development...but after loading it on a tomcat server 6.0 after goining live the servlet has to be reloaded every morning on the tomcat server....after that it works fine during the whole day..but the next morning when i request something it gives a blank page as response and my server admin tells the servlet has to be reloaded ...
other application hosted on the server are working fine and do not need a restart...
what might be the problem....
adding the code ..if it helps
package com.ams.servlets;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.*;
import com.cms.dbaccess.DataAccess;
import com.cms.utils.ApplicationConstants;
import com.cms.utils.ApplicationHelper;
import java.sql.ResultSet;
public class BBRequestProcessorServlet extends HttpServlet {
/**
*
*/String userString;
private static final long serialVersionUID = 1L;
String jsonString = "";
ResultSet rs = null;
Connection connection = null;
Statement statement=null;
public enum db_name
{
//Test
resource_management_db,osms_inventory_db;
}
public void init(ServletConfig config)throws ServletException
{
super.init(config);
System.out.println("Inside init");
}
public void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
{
try{
connection = DataAccess.connectToDatabase("xxx", connection);
statement = DataAccess.createStatement(connection);
statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
rs = statement.executeQuery("query is here");
}
catch(SQLException e)
{
e.printStackTrace();
}
String db =request.getParameter("db");
System.out.println("DATABASE NAME :"+ db);
if(db.equalsIgnoreCase("xxx")){
//Call to populate JSONArray with the fetch ResultSet data
jsonString = ApplicationHelper.populateJSONArray(rs);
}
response.setContentType(ApplicationConstants.JSON_CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.print(jsonString);
out.flush();
out.close();
System.out.println("json object sent");
try {
rs.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
the only errors i could find was
Jul 20, 2012 9:57:24 AM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(/usr/local/tomcat/apache-tomcat-6.0.20/webapps/MobileServlet /WEB-INF/lib/servlet-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
The culprit is most likely the way how you handle external DB resources like the Connection. This problem can happen when you keep a DB Connection open all the time without closing it. When a DB Connection is been opened for a too long time, then the DB will timeout and reclaim it. This is most likely what was happening overnight.
You should redesign your DataAccess and BBRequestProcessorServlet that way so that you are nowhere keeping hold of Connection, Statement and ResultSet as an instance variable, or worse, a static variable of the class. The Connection should be created in the very same scope as where you're executing the SQL query/queries and it should be closed in the finally block of the very same try block as where you've created it.
By the way your jsonString should absolutely also not be declared as an instance variable of the servlet, it's not threadsafe this way.
See also:
Is it safe to use a static java.sql.Connection instance in a multithreaded system?
How do servlets work? Instantiation, sessions, shared variables and multithreading
As to the error which you're seeing in the log, you should definitely remove the offending JAR. See also How do I import the javax.servlet API in my Eclipse project?
I am guessing and will be more clear after seeing your logs.
Its seems like you have putted your servlet-api.jar in the WEB-INF lib but its already in tomcat's lib.

Resources