I have a Grails app that I am hooking up to a MongoDB instance. In my Datasource.groovy, I have the following declared:
grails {
mongo {
host = "localhost"
port = 27017
databaseName = "mmib-mongo"
}
}
Mongo is installed and starts just fine.
The problem is that when I am connected to a network, using grails run-app logs the following exception:
Packaging Grails application.....
| Running Grails application
Configuring Spring Security Core ...
... finished configuring Spring Security Core
Configuring Spring Security LDAP ...
... finished configuring Spring Security LDAP
| Error 2012-11-19 15:42:16,428 [localhost-startStop-1] ERROR context.GrailsContextLoader - Error executing bootstraps: Error creating bean with name 'mongoDatastore': FactoryBean threw exception on object creation; nested exception is org.springframework.dao.DataAccessResourceFailureException: can't call something : MBP-C02J91TWDKQ5.local/192.168.0.131:27017/mmib-mongo; nested exception is com.mongodb.MongoException$Network: can't call something : MBP-C02J91TWDKQ5.local/192.168.0.131:27017/mmib-mongo
Message: Error creating bean with name 'mongoDatastore': FactoryBean threw exception on object creation; nested exception is org.springframework.dao.DataAccessResourceFailureException: can't call something : MBP-C02J91TWDKQ5.local*/192.168.0.131:27017/mmib-mongo*; nested exception is com.mongodb.MongoException$Network: can't call something : MBP-C02J91TWDKQ5.local/192.168.0.131:27017/mmib-mongo
Any clue why when I'm connected to a network, Grails/Mongo wants to use that IP Address instead of localhost, which I verified is 127.0.0.1 in /etc/hosts
Homebrew tells MongoDB to listen on only on 127.0.0.1, not your public interface or a ".local" hostname:
https://github.com/mxcl/homebrew/blob/master/Library/Formula/mongodb.rb#L95
Try deleting the bind_ip line from your local copy of mongod.conf and simply protecting port 27017 with a firewall, or else change the "bind_ip" entry in mongod.conf.
Related
I have a project using spring-boot and added
the following dependency in my build.gradle:
compile group: 'org.springframework.boot', name: 'spring-boot-starter-mail', version: '1.5.7.RELEASE'
My application.properties contains
SMTP Configuration
spring.mail.host=mail.xxx
spring.mail.port=587
spring.mail.username=donotreply#xxx
spring.mail.password=xxx
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.from=donotreply#xxx
According to multiple answers here and documentations i found,that should be enought to create the bean with this settings.
I now want to use a mailer in a Service class
#Autowired
private JavaMailSender emailSender;
[...]
#Value("${spring.mail.host}")
private String mailHost;
When i try to send a message using emailSender i get the following error:
Mail server connection failed; nested exception is
com.sun.mail.util.MailConnectException: Couldn't connect to host,
port: localhost, 25; timeout -1; nested exception is:
java.net.ConnectException: Connection refused: connect. Failed
messages: com.sun.mail.util.MailConnectException: Couldn't connect to
host, port: localhost, 25; timeout -1; nested exception is:
java.net.ConnectException: Connection refused: connect
Obviously it is trying to connect to localhost instead of the configured host.
The variable mailHost does contain the correct value, so the properties are read correct.
EDIT:
The autowired class for emailSender is org.springframework.mail.javamail.JavaMailSenderImpl, which seems to be correct to me.
In my case, the reason was that I instantiated the bean myself like this:
#Bean
public JavaMailSender mailSender() throws IOException {
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
mailSender.setDefaultEncoding("UTF-8");
return mailSender;
}
Not sure why, but that way, it ignores the application.properties. Maybe the reason was, that I explicitly instantiated JavaMailSenderImpl to set a default encoding and possibly that implementation isn't application.properties aware?
However, removing that bean solved the problem.
[FOUND]
A co-worker was working on the same and had commited an incomplete bean definition. That bean was autowired.
I'm trying to do Remote EJB calls to my Wildfly 10/JBoss 7 EAP server, but keep getting Invalid User error messages on my Wildfly server (my EJB is called LoginManager):
23:04:02,872 ERROR [org.jboss.as.ejb3.invocation] (default task-6) WFLYEJB0034: EJB Invocation failed on component LoginManager for method public abstract java.lang.String ejbs.LoginManagerRemote.echo(java.lang.String): javax.ejb.EJBAccessException: WFLYSEC0027: Invalid User
at org.jboss.as.ejb3.security.SecurityContextInterceptor$1.run(SecurityContextInterceptor.java:69)
at org.jboss.as.ejb3.security.SecurityContextInterceptor$1.run(SecurityContextInterceptor.java:49)
at org.jboss.as.ejb3.security.SecurityContextInterceptor.processInvocation(SecurityContextInterceptor.java:97)
I've added my user to the application-users.properties file using the add-user.sh/bat scripts.
I've tried putting in breakpoints in the Wildfly server itself in the SecurityContextInterceptor class on line 54 and see that the principal is null:
if (holder.skipAuthentication == false) {
holder.securityManager.authenticate(holder.runAs, holder.runAsPrincipal, holder.extraRoles);
I'm not entirely sure if this runAs or runAsPrincipal is the principal/credentials passed by the remote EJB invocation, but I suspect it might be responsible for my problem.
I'm calling the remote ejb as:
Properties p = new Properties();
p.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
final Context context = new InitialContext(p);
LoginManagerRemote ejb = (LoginManagerRemote) context.lookup("ejb:ear-1.0/ejbs-1.0//LoginManager!ejbs.LoginManagerRemote");
return ejb.echo("test");
with my jboss-ejb-client.properties as:
remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
remote.connections=default
remote.connection.default.host=localhost
remote.connection.default.port=8080
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
remote.conncetion.default.connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS=JBOSS-LOCAL-USER
remote.connection.default.username=test
remote.connection.default.password=test
Am I doing something wrong? Am I missing something obvious somewhere? What do I need to do to successfully call a remote EJB?
There's a typo in your jboss-ejb-client.properties
remote.conncetion.default.connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS=JBOSS-LOCAL-USER
Should be remote.connection.default.connect.options etc etc
APPLICATION FAILED TO START
Description:
Cannot determine embedded database driver class for database type NONE
Action:
If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (the profiles "local" are currently active).
2016-11-10 18:36:52.335 ERROR 1288 --- [ main] o.s.test.context.TestContextManager : Caught exception while allowing TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener#d83da2e] to prepare test instance [com.example.DemoApplicationTests#1f68e4e8]
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124) ~[spring-test-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83) ~[spring-test-4.3.4.RELEASE.jar:4.3.4.RELEASE]
I have a simple application that uses hibernate to work with db. When i check connection and some methods in main method, everything is fine. But when i deploy it on server, it throws
javax.servlet.ServletException: Cant instantiate class: managed.ClientsBean.
javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)
root cause:
com.sun.faces.mgbean.ManagedBeanCreationException: Cant instantiate class: managed.ClientsBean.
...
root cause:
javax.persistence.PersistenceException: org.hibernate.exception.JDBCConnectionException: Could not open connection
...
root cause:
org.hibernate.exception.JDBCConnectionException: Could not open connection
root cause
java.sql.SQLException: No suitable driver found for jdbc:postgresql://localhost:5432/project
But I have that driver, in jboss\standalone\deployments too. How can I make jboss see it?
See here:
https://community.jboss.org/wiki/DataSourceConfigurationInAS7
And here
JDBC Postgresql driver on JBoss 7
We have a couple of jboss instances running on different machines. We needed a script to invoke a JMX console operation using twiddle utility available with JBoss.
For localhost the command is working fine but when we try to access the remote via:
twiddle.sh -s <servername>:<http port> -uadmin -p<password> serverinfo -c
but for remote servers we are facing following exception:
05:25:34,205 ERROR [Twiddle] Exec failed
org.jboss.util.NestedRuntimeException: - nested throwable: (javax.naming.CommunicationException [Root exception is java.rmi.NoSuchObjectException: no such object in table])
at org.jboss.console.twiddle.Twiddle$1.getServer(Twiddle.java:144)
at org.jboss.console.twiddle.command.MBeanServerCommand.getMBeanServer(MBeanServerCommand.java:59)
at org.jboss.console.twiddle.command.MBeanServerCommand.queryMBeans(MBeanServerCommand.java:66)
at org.jboss.console.twiddle.command.InvokeCommand.execute(InvokeCommand.java:274)
at org.jboss.console.twiddle.Twiddle.main(Twiddle.java:306)
Caused by: javax.naming.CommunicationException [Root exception is java.rmi.NoSuchObjectException: no such object in table]
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:780)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at org.jboss.console.twiddle.Twiddle.createMBeanServerConnection(Twiddle.java:251)
at org.jboss.console.twiddle.Twiddle.connect(Twiddle.java:269)
at org.jboss.console.twiddle.Twiddle.access$300(Twiddle.java:63)
at org.jboss.console.twiddle.Twiddle$1.getServer(Twiddle.java:140)
... 4 more
Caused by: java.rmi.NoSuchObjectException: no such object in table
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:675)
... 10 more
Any help?
We weren't able to find a solution for this and finally managed to do so using SSH only.