I am developing a JavaEE application with GlassFish 5.1, Java 1.8, JavaMail, JavaFaces 2.2, in the application I need to send emails as the method to do it is invoked, but when I run it from the server it shows me the following error:
Warning: javax.ejb.EJBException
at com.sun.ejb.containers.EJBContainerTransactionManager.processSystemException(EJBContainerTransactionManager.java:728)
at com.sun.ejb.containers.EJBContainerTransactionManager.completeNewTx(EJBContainerTransactionManager.java:678)
at com.sun.ejb.containers.EJBContainerTransactionManager.postInvokeTx(EJBContainerTransactionManager.java:483)
at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4576)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2084)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2054)
at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:188)
at com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:55)
at com.sun.proxy.$Proxy268.preInscripcion(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie.dispatchToMethod(ReflectiveTie.java:113)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:143)
at com.sun.corba.ee.impl.protocol.ServerRequestDispatcherImpl.dispatchToServant(ServerRequestDispatcherImpl.java:490)
at com.sun.corba.ee.impl.protocol.ServerRequestDispatcherImpl.dispatch(ServerRequestDispatcherImpl.java:161)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequestRequest(MessageMediatorImpl.java:1520)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequest(MessageMediatorImpl.java:1396)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleInput(MessageMediatorImpl.java:901)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:183)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequest(MessageMediatorImpl.java:665)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.dispatch(MessageMediatorImpl.java:467)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.doWork(MessageMediatorImpl.java:2193)
at com.sun.corba.ee.impl.threadpool.ThreadPoolImpl$WorkerThread.performWork(ThreadPoolImpl.java:467)
at com.sun.corba.ee.impl.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:510)
Caused by: java.lang.NoClassDefFoundError: sun/security/ssl/HandshakeStateManager
at sun.security.ssl.Handshaker.init(Handshaker.java:282)
at sun.security.ssl.Handshaker.<init>(Handshaker.java:242)
at sun.security.ssl.ClientHandshaker.<init>(ClientHandshaker.java:160)
at sun.security.ssl.SSLSocketImpl.initHandshaker(SSLSocketImpl.java:1329)
at sun.security.ssl.SSLSocketImpl.doneConnect(SSLSocketImpl.java:690)
at sun.security.ssl.SSLSocketImpl.<init>(SSLSocketImpl.java:569)
at sun.security.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:110)
at com.sun.mail.util.SocketFetcher.startTLS(SocketFetcher.java:528)
at com.sun.mail.smtp.SMTPTransport.startTLS(SMTPTransport.java:2126)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:728)
at javax.mail.Service.connect(Service.java:342)
at javax.mail.Service.connect(Service.java:222)
at javax.mail.Service.connect(Service.java:243)
at com.prueba.dao.UsuarioDAO.enviarEmail(UsuarioDAO.java:80)
at com.prueba.model.Estudiante.agregarUsuario(Estudiante.java:19)
at com.prueba.sessionbeans.EstudianteBean.preInscripcion(EstudianteBean.java:12)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1057)
at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1129)
at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:4796)
at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:632)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800)
at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:584)
at org.jboss.weld.module.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:81)
at org.jboss.weld.module.ejb.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:52)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:859)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:799)
at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:584)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCall(SystemInterceptorProxy.java:139)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:116)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:859)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:799)
at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:345)
at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:4768)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4756)
at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:181)
... 19 more
I was testing the code fragment in a separate project and it works perfectly, but at the moment of executing it from the server the error happens. The code fragment is the following:
try{
Properties props=new Properties();
props.setProperty("mail.smtp.host", "smtp.gmail.com");
props.setProperty("mail.smtp.starttls.enable", "true");
props.setProperty("mail.smtp.port", "587");
props.setProperty("mail.smtp.aunth", "true");
Session session=Session.getDefaultInstance(props);
MimeMessage message=new MimeMessage(session);
message.setFrom(new InternetAddress(mailSender));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(mailReceptor));
message.setSubject(asunto);
message.setText(mensaje);
Transport transport=session.getTransport("smtp");
transport.connect(mailSender, passwordSender);
transport.sendMessage(message, message.getRecipients(Message.RecipientType.TO));
transport.close();
return true;
}
catch(AddressException e){
e.printStackTrace();
}
catch(MessagingException e){
e.printStackTrace();
}
When I execute the code the error marks it in the following line transport.connect(mailSender, passwordSender);
I have been trying with different versions of JavaMail (1.4.5 - 1.6.2), I was using JDK8u111 and updated it to JDK8u261 but nothing, I also tried to change the JAR of the glizzly-npn-bootstrap.jar from version 1.5 to 1.9 (As they say in the following error) but it still gives me the same error. I don't understand what is wrong, nor how to solve it.
I could not find a solution to the problem presented in the GlassFish 5.1 server, but when running the application from the Payara 5.2 server there was no error and everything worked perfectly, however I decided to leave the application with the JDK8u261 to avoid a possible problem of compatibility with the versions.
The download link for the Payara I used is this.
Related
I am new to Sentry followed this
and this
and followed the same steps and the code I have an sbt project in which I created sentry.properties file its contents are
dsn=https://public:private#host:port/1
and placed it under src/main/resources when the code runs (the same code given the link above ) following exception is thrown'
18:19:26.745 [run-main-1] DEBUG io.sentry.config.Lookup - Found dsn=https://public:private#host:port/1 in sentry.properties.
18:19:26.754 [run-main-1] ERROR io.sentry.SentryClientFactory - Error creating valid DSN from: 'https://public:private#host:port/1'.
io.sentry.dsn.InvalidDsnException: Invalid DSN, the following properties aren't set '[host, public key]'
at io.sentry.dsn.Dsn.validate(Dsn.java:209) ~[sentry-1.7.16.jar:na]
at io.sentry.dsn.Dsn.<init>(Dsn.java:66) ~[sentry-1.7.16.jar:na]
at io.sentry.dsn.Dsn.<init>(Dsn.java:41) ~[sentry-1.7.16.jar:na]
at io.sentry.SentryClientFactory.resolveDsn(SentryClientFactory.java:73) [sentry-1.7.16.jar:na]
at io.sentry.SentryClientFactory.sentryClient(SentryClientFactory.java:42) [sentry-1.7.16.jar:na]
at io.sentry.Sentry.init(Sentry.java:81) [sentry-1.7.16.jar:na]
at io.sentry.Sentry.init(Sentry.java:44) [sentry-1.7.16.jar:na]
at sentry.SentryDemo$.main(SentryDemo.scala:16) [classes/:na]
at sentry.SentryDemo.main(SentryDemo.scala) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
at sbt.Run.invokeMain(Run.scala:67) [run-0.13.16.jar:0.13.16]
at sbt.Run.run0(Run.scala:61) [run-0.13.16.jar:0.13.16]
at sbt.Run.sbt$Run$$execute$1(Run.scala:51) [run-0.13.16.jar:0.13.16]
at sbt.Run$$anonfun$run$1.apply$mcV$sp(Run.scala:55) [run-0.13.16.jar:0.13.16]
at sbt.Run$$anonfun$run$1.apply(Run.scala:55) [run-0.13.16.jar:0.13.16]
at sbt.Run$$anonfun$run$1.apply(Run.scala:55) [run-0.13.16.jar:0.13.16]
at sbt.Logger$$anon$4.apply(Logger.scala:84) [logging-0.13.16.jar:0.13.16]
at sbt.TrapExit$App.run(TrapExit.scala:248) [run-0.13.16.jar:0.13.16]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_181]
[error] (run-main-1) io.sentry.dsn.InvalidDsnException: Invalid DSN, the following properties aren't set '[host, public key]'
io.sentry.dsn.InvalidDsnException: Invalid DSN, the following properties aren't set '[host, public key]'
at io.sentry.dsn.Dsn.validate(Dsn.java:209)
at io.sentry.dsn.Dsn.<init>(Dsn.java:66)
at io.sentry.dsn.Dsn.<init>(Dsn.java:41)
at io.sentry.SentryClientFactory.resolveDsn(SentryClientFactory.java:73)
at io.sentry.SentryClientFactory.sentryClient(SentryClientFactory.java:42)
at io.sentry.Sentry.init(Sentry.java:81)
at io.sentry.Sentry.init(Sentry.java:44)
at sentry.SentryDemo$.main(SentryDemo.scala:16)
at sentry.SentryDemo.main(SentryDemo.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
Is there anything I need to add in place of dsnin the properties file ? i am using sentry in my project which is not a web based project
The DSN tells the Sentry SDK which instance of sentry to hit (for example sentry.io) and which project within Sentry the events belong to.
You need to get the DSN from Sentry and add to your project.
In Sentry, in the project settings page, you'll see: Client keys (DSN):
You'll then see the DSN like so:
Copy this (the button on the right), and paste on your sentry.properties replacing the placeholder: https://public:private#host:port/1
Trying to access HDFS location using Kerberose authentication, but getting below error message:
java.io.IOException: failure to login
at org.apache.hadoop.security.UserGroupInformation.loginUserFromSubject(UserGroupInformation.java:839)
at org.apache.hadoop.security.UserGroupInformation.getLoginUser(UserGroupInformation.java:775)
at org.apache.hadoop.security.UserGroupInformation.getCurrentUser(UserGroupInformation.java:648)
at org.apache.hadoop.fs.FileSystem$Cache$Key.<init>(FileSystem.java:2859)
at org.apache.hadoop.fs.FileSystem$Cache$Key.<init>(FileSystem.java:2851)
at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:2714)
at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:382)
at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:181)
at com.xyz.module.submodule.common.utils.HDFSPropertyLookup.loadProperties(HDFSPropertyLookup.java:75)
at com.xyz.module.submodule.common.utils.HDFSPropertyLookup.initialize(HDFSPropertyLookup.java:37)
at com.xyz.module.submodule.common.utils.HDFSPropertyLookupTest.initializePropertiesFile(HDFSPropertyLookupTest.java:16)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: javax.security.auth.login.LoginException: unable to find LoginModule class: com.sun.security.auth.module.UnixLoginModule
at javax.security.auth.login.LoginContext.invoke(LoginContext.java:794)
at javax.security.auth.login.LoginContext.access$000(LoginContext.java:195)
at javax.security.auth.login.LoginContext$4.run(LoginContext.java:682)
at javax.security.auth.login.LoginContext$4.run(LoginContext.java:680)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:680)
at javax.security.auth.login.LoginContext.login(LoginContext.java:587)
at org.apache.hadoop.security.UserGroupInformation.loginUserFromSubject(UserGroupInformation.java:813)
... 31 more
Cause: LoginModule class: com.sun.security.auth.module.UnixLoginModule not found.
Want to know in which .jar file com.sun.security.auth.module.UnixLoginModule is present?
If someone might have faced this issue before, then please let help!
This issue got resolved!
Let me share the real cause and how it got resolved?
In unit test code, I was setting the os.name system property value to different operating system for my test case scenario as below:
System.setProperty("os.name", "Windows");
I was setting above properties value with Windows/Unix/MAC etc, but I missed to reset to its original value.
In same project there I was executing FileSystem.get(new Configuration()); from Hadoop API, in which Kerberose authentication was set.
So while execution operating system name was getting changed to some other name and it was not reset to original name.
Solution:
So in setup method I collected the original OS name to some other variable and after all test case completion reset to original name as below:
#BeforeClass
public static void setup() throws IOException {
System.setProperty("os.name.orig", System.getProperty("os.name"));
}
// other test case methods continue...
#AfterClass
public static void clearProperties() throws IOException {
System.setProperty("os.name", System.getProperty("os.name.orig"));
System.clearProperty("os.name.orig");
}
After above setting OS was reverted back to its original name and everything started working properly.
Hope this will help others in future!!!
This has been extremely frustrating, especially since I've been all over the forums and have followed all the directions, as far as I can tell.
I am trying to create a connection to a local mysql database. First I downloaded the mysql driver from http://dev.mysql.com/downloads/connector/j using the platform independent TAR (I'm on ubuntu). Then I placed the resultant JAR into a new folder I created for my project call /lib, and then right-clicked and selected "Add to Build Path". It now shows up as a Referenced Library.
For the code, I am doing the typical things you would do:
try {
Class.forName("com.mysql.jdbc.Driver");
String db_url = "jdbc:mysql://localhost/project";
connect = DriverManager.getConnection(db_url, "user", "password");
statement = connect.createStatement();
resultSet = statement.executeQuery("select * from database.table");
while (resultSet.next()) {
int id = resultSet.getInt("ID");
String name = resultSet.getString("Name");
System.out.println("(ID: " + id + ") (Name: " + name + ")");
}
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
}
But for whatever reason, I still get "java.lang.ClassNotFoundException: com.mysql.jdbc.Driver cannot be found"
I'm sure it's something completely idiotic on my part, but any pointers as to what I'm missing?
Here is the stack trace:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver cannot be found by com.personal.recipes_1.0.0.qualifier
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:501)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at com.personal.recipes.test.TestUtils.execute(TestUtils.java:22)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:243)
at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:224)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:132)
at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:167)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:499)
at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:213)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.executeItem(HandledContributionItem.java:850)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.handleWidgetSelection(HandledContributionItem.java:743)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.access$7(HandledContributionItem.java:727)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem$4.handleEvent(HandledContributionItem.java:662)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1392)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3742)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3363)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:138)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:162)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
So I probably didn't explain my problem well enough before. The question specifically related to getting my Eclipse RCP application to see the driver. After talking to a friend he reminded me that I needed to add the mysql jar to the .MF file directly. Once I knew that I found a ton of posts on various forums answering my question.
I added the following line and I'm able to make the connection to the database without issue:
"Bundle-ClassPath: lib/mysql-connector-java-5.1.30-bin.jar, ."
The (.) at the end also was very important and stymied me for a few minutes.
I just made a quick copy / paste of your code into a fresh project, installed the driver in lib... works like a charm. So did you do something before the code snippet?
I don't understand, why am I getting this error in Scala Play REPL, but everything seems to be fine on Play project. This is after I run play console:
scala> import play.api.libs.Crypto
import play.api.libs.Crypto
scala> Crypto.encryptAES("password")
#6gd0e7jca: Configuration error
at play.api.libs.Crypto$$anonfun$encryptAES$2.apply(Crypto.scala:156)
at play.api.libs.Crypto$$anonfun$encryptAES$2.apply(Crypto.scala:156)
at scala.Option.getOrElse(Option.scala:120)
at play.api.libs.Crypto$.encryptAES(Crypto.scala:155)
at .<init>(<console>:19)
at .<clinit>(<console>)
at .<init>(<console>:7)
at .<clinit>(<console>)
at $print(<console>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.call(IMain.scala:734)
at scala.tools.nsc.interpreter.IMain$Request.loadAndRun(IMain.scala:983)
at scala.tools.nsc.interpreter.IMain.loadAndRunReq$1(IMain.scala:573)
at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:604)
at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:568)
at scala.tools.nsc.interpreter.ILoop.reallyInterpret$1(ILoop.scala:745)
at scala.tools.nsc.interpreter.ILoop.interpretStartingWith(ILoop.scala:790)
at scala.tools.nsc.interpreter.ILoop.command(ILoop.scala:702)
at scala.tools.nsc.interpreter.ILoop.processLine$1(ILoop.scala:566)
at scala.tools.nsc.interpreter.ILoop.innerLoop$1(ILoop.scala:573)
at scala.tools.nsc.interpreter.ILoop.loop(ILoop.scala:576)
at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply$mcZ$sp(ILoop.scala:867)
at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:822)
at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:822)
at scala.tools.nsc.util.ScalaClassLoader$.savingContextLoader(ScalaClassLoader.scala:135)
at scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:822)
at scala.tools.nsc.interpreter.ILoop.main(ILoop.scala:889)
at xsbt.ConsoleInterface.run(ConsoleInterface.scala:69)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:102)
at sbt.compiler.AnalyzingCompiler.console(AnalyzingCompiler.scala:77)
at sbt.Console.sbt$Console$$console0$1(Console.scala:23)
at sbt.Console$$anonfun$apply$2$$anonfun$apply$1.apply$mcV$sp(Console.scala:24)
at sbt.TrapExit$.sbt$TrapExit$$executeMain$1(TrapExit.scala:33)
at sbt.TrapExit$$anon$1.run(TrapExit.scala:42)
I want to use this for encrypting strings in the console. What exactly does this error mean?
Play Framework 2.2.1 / Scala 2.10.3 / Java 8 64bit
You need a running Play application to encrypt anything with that method, because it needs to get the application secret to use to encrypt the data.
Two solutions:
Use the other version of encryptKey, and pass in your application secret, eg:
Crypto.encryptAES("password", "yourapplicationsecret".substring(0, 16))
Instead of running play console, run play test:console, and then execute the following code in order to ensure that there is a running application:
import play.api.test._
Helpers.running(FakeApplication()) { Crypto.encryptAES("password") }
I'm trying to create a simple admin client application for websphere:
my code:
Properties connectProps = new Properties();
connectProps.setProperty(AdminClient.CONNECTOR_TYPE,
AdminClient.CONNECTOR_TYPE_SOAP);
connectProps.setProperty(AdminClient.CONNECTOR_SECURITY_ENABLED,
"true");
connectProps.setProperty(AdminClient.CONNECTOR_HOST, "XXXXX");
connectProps.setProperty(AdminClient.CONNECTOR_PORT, "8879");
connectProps.setProperty(AdminClient.USERNAME, "admin");
connectProps.setProperty(AdminClient.PASSWORD, "admin");
connectProps.setProperty("javax.net.ssl.trustStore","C:\Users\DummyClientTrustFile.jks");
connectProps.setProperty("javax.net.ssl.keyStore",
"C:\Users\DummyClientKeyFile.jks");
connectProps.setProperty("javax.net.ssl.trustStorePassword", "admin");
connectProps.setProperty("javax.net.ssl.keyStorePassword", "admin");
AdminClient adminClient = null; try {
adminClient = AdminClientFactory.createAdminClient(connectProps); } catch
(ConnectorException e) {
System.out.println("Exception creating admin client: " + e);
e.printStackTrace(); }
}
the error message I receive:
com.ibm.websphere.management.exception.ConnectorException:
ADMC0016E:The system cannot create a SOAP connector to connect to
host xxxx at port 8879.
at com.ibm.websphere.management.AdminClientFactory.createAdminClientPriv
ileged(AdminClientFactory.java:635)
at com.ibm.websphere.management.AdminClientFactory.access$000(AdminClien
tFactory.java:127)
at com.ibm.websphere.management.AdminClientFactory$1.run(AdminClientFact
ory.java:210)
at com.ibm.ws.security.util.AccessController.doPrivileged(AccessControll
er.java:63)
at com.ibm.websphere.management.AdminClientFactory.createAdminClient(Adm
inClientFactory.java:206)
at TryConnection1.main(TryConnection1.java:42) Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Sou
rce)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.ibm.websphere.management.AdminClientFactory.createAdminClientPriv
ileged(AdminClientFactory.java:457)
... 5 more Caused by: java.lang.NoSuchMethodError: org.apache.soap.rpc.Call.WASinvoke(Ljava
/net/URL;Ljava/lang/String;)Lorg/apache/soap/rpc/Response;
at com.ibm.ws.management.connector.soap.SOAPConnectorClient$4.run(SOAPCo
nnectorClient.java:373)
at com.ibm.ws.security.util.AccessController.doPrivileged(AccessControll
er.java:118)
at com.ibm.ws.management.connector.soap.SOAPConnectorClient.reconnect(SO
APConnectorClient.java:366)
at com.ibm.ws.management.connector.soap.SOAPConnectorClient.(SOAPC
onnectorClient.java:222)
... 10 more
---- Begin backtrace for nested exception java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Sou
rce)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.ibm.websphere.management.AdminClientFactory.createAdminClientPriv
ileged(AdminClientFactory.java:457)
at com.ibm.websphere.management.AdminClientFactory.access$000(AdminClien
tFactory.java:127)
at com.ibm.websphere.management.AdminClientFactory$1.run(AdminClientFact
ory.java:210)
at com.ibm.ws.security.util.AccessController.doPrivileged(AccessControll
er.java:63)
at com.ibm.websphere.management.AdminClientFactory.createAdminClient(Adm
inClientFactory.java:206)
at TryConnection1.main(TryConnection1.java:42) Caused by: java.lang.NoSuchMethodError: org.apache.soap.rpc.Call.WASinvoke(Ljava
/net/URL;Ljava/lang/String;)Lorg/apache/soap/rpc/Response;
at com.ibm.ws.management.connector.soap.SOAPConnectorClient$4.run(SOAPCo
nnectorClient.java:373)
at com.ibm.ws.security.util.AccessController.doPrivileged(AccessControll
er.java:118)
at com.ibm.ws.management.connector.soap.SOAPConnectorClient.reconnect(SO
APConnectorClient.java:366)
at com.ibm.ws.management.connector.soap.SOAPConnectorClient.(SOAPC
onnectorClient.java:222)
... 10 more
Seems like you're mixing the wrong jars/jre's in your classpath. Probably IBM adminclient jars and sun JRE? Or wrong xml/soap jars?
I never actually tried to call the adminclient jars directly. A better supported way is to use IBM's wsadmin.sh script and call the AdminClient interface via jython. Behind the screens, this will also do what you did from java, so you could reverse engineer that script to see which jre and which jars are actually used to make the magic work.
See http://pic.dhe.ibm.com/infocenter/wasinfo/v6r1/topic/com.ibm.websphere.base.doc/info/aes/ae/rxml_commandline.html for websphere v6.1 documentation on wsadmin.